From: Marcel T. <te...@us...> - 2002-11-27 12:41:12
|
Update of /cvsroot/openwince/xboot In directory sc8-pr-cvs1:/tmp/cvs-serv32563 Modified Files: ChangeLog sources wep.h Added Files: usb-pxa250.c usb-sa1110.c Removed Files: usb.c Log Message: 2002-11-27 Marcel Telka <ma...@te...> * usb-pxa250.c, wep.h: Added USB support for WEP (from Daniel Samek). * ucb.c, usb-sa1110.c: Renamed usb.c to usb-sa1110.c. * sources: Added usb-pxa250.c, renamed usb.c to usb-sa1110.c. --- NEW FILE: usb-pxa250.c --- /* * $Id: usb-pxa250.c,v 1.1 2002/11/27 12:41:08 telka Exp $ * * Copyright (C) 2002 ETC s.r.o. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * Written by Daniel Samek <da...@et...>, 2002. * */ #include "board.h" #if CPU == PXA250 #include <_windows.h> #include "download.h" #include "format.h" #if defined(USB_VID) && defined(USB_PID) #include <pxa2x0/gpio.h> #include <pxa2x0/udc.h> #include <pxa2x0/pmrc.h> #include "except.h" #include "usb.h" /* Standard Request Codes */ #define REQ_GET_STATUS 0 #define REQ_CLEAR_FEATURE 1 #define REQ_SET_FEATURE 3 #define REQ_SET_ADDRESS 5 #define REQ_GET_DESCRIPTOR 6 #define REQ_SET_DESCRIPTOR 7 #define REQ_GET_CONFIGURATION 8 #define REQ_SET_CONFIGURATION 9 #define REQ_GET_INTERFACE 10 #define REQ_SET_INTERFACE 11 #define REQ_SYNCH_FRAME 12 /* Descriptor Types Value */ #define DESC_TYPE_DEVICE 1 #define DESC_TYPE_CONFIGURATION 2 #define DESC_TYPE_STRING 3 #define DESC_TYPE_INTERFACE 4 #define DESC_TYPE_ENDPOINT 5 #define EP0_MAX_PACKETSIZE 16 #define EP1_MAX_PACKETSIZE 64 #define EP2_MAX_PACKETSIZE 64 #define UDCCR_STATUS_MASK (UDCCR_RESIR | UDCCR_SUSIR | UDCCR_RSTIR) #define UDCCR_SET( bit ) UDCCR = (UDCCR & (~UDCCR_STATUS_MASK)) | bit #define UDCCR_CLEAR( bit ) UDCCR = UDCCR & (~(UDCCR_STATUS_MASK | bit)) #define UDCCS0_STATUS_MASK (UDCCS0_OPR | UDCCS0_IPR | UDCCS0_FTF | UDCCS0_SST | UDCCS0_FST | UDCCS0_SA) #define UDCCS0_SET( bit ) UDCCS0 = (UDCCS0 & (~UDCCS0_STATUS_MASK)) | bit #define UDCCS0_CLEAR( bit ) UDCCS0 = UDCCS0 & (~(UDCCS0_STATUS_MASK | bit)) #define UDCCS1_STATUS_MASK (UDCCS1_TPC | UDCCS1_FTF | UDCCS1_TUR | UDCCS1_SST | UDCCS1_TSP) #define UDCCS1_SET( bit ) UDCCS1 = (UDCCS1 & (~UDCCS1_STATUS_MASK)) | bit #define UDCCS1_CLEAR( bit ) UDCCS1 = UDCCS1 & (~(UDCCS1_STATUS_MASK | bit)) #define UDCCS2_STATUS_MASK (UDCCS2_RPC | UDCCS2_SST) #define UDCCS2_SET( bit ) UDCCS2 = (UDCCS2 & (~UDCCS2_STATUS_MASK)) | bit #define UDCCS2_CLEAR( bit ) UDCCS2 = UDCCS2 & (~(UDCCS2_STATUS_MASK | bit)) #define EP0_IDLE 1 #define EP0_IN_DATA_PHASE 2 #define EP0_END_XFER 3 static int status; static uint8_t buffer[64]; static int index; static int count; static int usb_ready; static const struct usb_dev_desc wep_dev_desc = { 18, /* length */ DESC_TYPE_DEVICE, /* descriptortype */ 0x0110, /* usb */ -1, /* deviceclass */ -1, /* devicesubclass */ -1, /* deviceprotocol */ EP0_MAX_PACKETSIZE, /* maxpacketsize */ USB_VID, /* idvendor */ USB_PID, /* idproduct */ 0, /* device */ 0, /* manufacturer */ 0, /* product */ 0, /* serialnumber */ 1, /* numconfigurations */ }; static const struct usb_conf_desc wep_conf_desc = { { 9, /* length */ DESC_TYPE_CONFIGURATION, /* descriptortype (CONFIGURATION) */ 32, /* total length */ 1, /* numinterfaces */ 1, /* configurationvalue */ 0, /* configuration */ (char) 0xC0, /* attributes */ 0, /* maxpower */ } , { 9, /* length */ DESC_TYPE_INTERFACE, /* descriptortype (INTERFACE) */ 0, /* interfacenumber */ 0, /* alternatesetting */ 2, /* numendpoints */ (char) 0xFF, /* interfaceclass */ (char) 0xFF, /* interfacesubclass */ (char) 0xFF, /* interfaceprotocol */ 0, /* interface */ } , { 7, /* length */ DESC_TYPE_ENDPOINT, /* descriptortype (ENDPOINT) */ (char) 0x81, /* endpointaddress (ep1, in) */ 0x2, /* attributes (0010 = bulk) */ EP1_MAX_PACKETSIZE, /* maxpacketsize */ 0, /* interval (ignored for bulk) */ } , { 7, /* length */ DESC_TYPE_ENDPOINT, /* descriptortype (ENDPOINT) */ 0x02, /* endpointaddress (ep2, out) */ 0x2, /* attributes (0010 = bulk) */ EP2_MAX_PACKETSIZE, /* maxpacketsize */ 0, /* interval (ignored for bulk) */ } }; static int usbcable_wait( void ) { int i, in; uint32_t timeout = 0; EdbgOutputDebugString( "* Please connect USB cable between PC and wep.\n" ); for (i = 9, in = 0; i && !in; i--) { EdbgOutputDebugString( "%d\r", i ); for (timeout = 0x200000; timeout; timeout--) if (GPLR0 & GPIO0_GP11) { in = 1; break; } } return timeout ? 1 : 0; } static int usbcable_in( void ) { if (GPLR0 & GPIO0_GP11) return 1; UDCCR_CLEAR( UDCCR_UDE ); /* disable UDC */ /* high speed usb device disable */ GPDR2 &= ~GPIO2_GP79; return 0; } static int ep0_data_read( uint8_t * buffer, int length ) { int i; for (i = 0; (i < length) && (UDCCS0 & UDCCS0_RNE); i++) buffer[i] = (uint8_t) UDDR0; return (i == length) ? 1 : 0; } static void ep0_data_read_errata131( uint8_t * buffer ) { int i; for (i = 0; i < 8; i++) buffer[i] = (uint8_t) UDDR0; } static int /* 1 - IPR is set, 0 - IPR is not set */ ep0_data_write( void ) { int i; for (i = 0; (i < EP0_MAX_PACKETSIZE) && (index < count); i++, index++) UDDR0 = buffer[index]; if (i < EP0_MAX_PACKETSIZE) { UDCCS0_SET( UDCCS0_IPR ); return 1; } return 0; } static void ep0_init_data_write( uint8_t * data, int length ) { index = 0; count = length; memcpy( (uint8_t *) & buffer, data, count ); ep0_data_write(); status = EP0_IN_DATA_PHASE; } static void ep0_get_device_descriptor( struct usb_dev_req *req ) { if (req->length < wep_dev_desc.length) { UDCCS0_SET( UDCCS0_SA | UDCCS0_OPR | UDCCS0_IPR ); return; } ep0_init_data_write( (uint8_t *) & wep_dev_desc, wep_dev_desc.length ); } static void ep0_get_config_descriptor( struct usb_dev_req *req ) { if (req->length < wep_conf_desc.conf.total_length) { UDCCS0_SET( UDCCS0_SA | UDCCS0_OPR | UDCCS0_IPR ); return; } ep0_init_data_write( (uint8_t *) & wep_conf_desc, wep_conf_desc.conf.total_length ); } static void ep0_get_descriptor( struct usb_dev_req *req ) { switch (req->value_hi) { case DESC_TYPE_DEVICE: ep0_get_device_descriptor( req ); break; case DESC_TYPE_CONFIGURATION: ep0_get_config_descriptor( req ); break; case DESC_TYPE_STRING: EdbgOutputDebugString( "(USB) unworked: DESC_TYPE_STRING\n" ); break; case DESC_TYPE_INTERFACE: EdbgOutputDebugString( "(USB) unworked: DESC_TYPE_INTERFACE\n" ); break; case DESC_TYPE_ENDPOINT: EdbgOutputDebugString( "(USB) unworked: DESC_TYPE_ENDPOINT\n" ); break; default: EdbgOutputDebugString( "(USB) unknown descriptor type: 0x%x\n", req->value_hi ); } } static void ep0_set_configuration( struct usb_dev_req *req ) { if (req->value_lo != 1) { UDCCS0_SET( UDCCS0_SA | UDCCS0_OPR | UDCCS0_IPR ); return; } usb_ready = 1; } static void ep0_setup( void ) { struct usb_dev_req req; if (UDCCS0 == 0x81) ep0_data_read_errata131( (uint8_t *) & req ); else if (!ep0_data_read( (uint8_t *) & req, sizeof (struct usb_dev_req) )) return; switch (req.request) { case REQ_GET_STATUS: EdbgOutputDebugString( "(USB) unworked: REQ_GET_STATUS\n" ); break; case REQ_CLEAR_FEATURE: EdbgOutputDebugString( "(USB) unworked: REQUEST_CLEAR_FEATURE\n" ); break; case REQ_SET_FEATURE: EdbgOutputDebugString( "(USB) unworked: REQ_SET_FEATURE\n" ); break; case REQ_SET_ADDRESS: EdbgOutputDebugString( "(USB) unworked: REQ_SET_ADDRESS\n" ); break; case REQ_GET_DESCRIPTOR: ep0_get_descriptor( &req ); break; case REQ_SET_DESCRIPTOR: EdbgOutputDebugString( "(USB) unworked: REQ_SET_DESCRIPTOR\n" ); break; case REQ_GET_CONFIGURATION: EdbgOutputDebugString( "(USB) unworked: REQ_GET_CONFIGURATION\n" ); break; case REQ_SET_CONFIGURATION: ep0_set_configuration( &req ); break; case REQ_GET_INTERFACE: EdbgOutputDebugString( "(USB) unworked: REQ_GET_INTERFACE\n" ); break; case REQ_SET_INTERFACE: EdbgOutputDebugString( "(USB) unworked: REQ_SET_INTERFACE\n" ); break; case REQ_SYNCH_FRAME: EdbgOutputDebugString( "(USB) unworked: REQ_SYNC_FRAME\n" ); break; default: UDCCS0_SET( UDCCS0_SA | UDCCS0_OPR | UDCCS0_IPR ); } } static void ep0_interrupt( void ) { if (UDCCS0 & UDCCS0_OPR) { if (UDCCS0 & UDCCS0_SA) { ep0_setup(); UDCCS0_SET( UDCCS0_OPR | UDCCS0_SA ); return; } UDCCS0_SET( UDCCS0_OPR ); switch (status) { case EP0_IN_DATA_PHASE: UDCCS0_SET( UDCCS0_FTF ); status = EP0_IDLE; return; case EP0_END_XFER: status = EP0_IDLE; return; } } switch (status) { case EP0_IN_DATA_PHASE: if (ep0_data_write()) status = EP0_END_XFER; return; } } static int usb_init( void ) { /* high speed usb device enable */ GPSR2 = GPIO2_GP79; GPDR2 |= GPIO2_GP79; UDCCR_SET( UDCCR_UDE ); /* enable UDC */ if (!(UDCCR & UDCCR_UDA)) /* reset in progress */ UDCCR_SET( UDCCR_RSTIR ); UDCCR_SET( UDCCR_REM ); UICR0 &= ~UICR0_IM0; /* enable ep0 interrupt */ UICR0 &= ~UICR0_IM2; /* enable ep2 interrupt */ UDCCS2_CLEAR( UDCCS2_DME ); /* FIXME: turn off double buffer for ep0 and ep1 (intel driver) */ UDC_pointer->__reserved1[0] &= ~(0x06); usb_ready = 0; status = EP0_IDLE; while (!usb_ready) { if (!usbcable_in()) break; if (UDCCR & UDCCR_RSTIR) { if (UDCCR & UDCCR_UDA) status = EP0_IDLE; UDCCR_SET( UDCCR_RSTIR ); continue; } if (USIR0 & USIR0_IR0) { ep0_interrupt(); USIR0 = USIR0_IR0; } } return usb_ready ? 1 : 0; } static void usb_writechar( char c ) { uint32_t timeout; if (!usb_ready) Throw E_USBUNINITIALIZED; while (USIR0 & USIR0_IR0) { /* FIXME: read unkown request */ ep0_interrupt(); USIR0 = USIR0_IR0; } UDDR1 = c & 0xFF; UDCCS1_SET( UDCCS1_TSP ); UDCCS1_SET( UDCCS1_TPC ); UICR0 &= ~UICR0_IM1; /* enable ep1 interrupt */ for (timeout = 0x200000; timeout; timeout--) if (USIR0 & USIR0_IR1) break; UICR0 |= UICR0_IM1; /* disable ep1 interrupt */ USIR0 = USIR0_IR1; /* clear ep1 interrupt */ if (!timeout) Throw E_WRITETIMEOUT; } static char usb_readchar( void ) { uint32_t timeout; char c; if (!usb_ready) Throw E_USBUNINITIALIZED; for (timeout = 0x200000; timeout; timeout--) if ((USIR0 & USIR0_IR2) && (UDCCS2 & UDCCS2_RNE)) break; if (!timeout) Throw E_READTIMEOUT; c = (char) (UDDR2 & 0xFF); if (!(UDCCS2 & UDCCS2_RNE)) { UDCCS2_SET( UDCCS2_RPC ); USIR0 = USIR0_IR2; } return c; } int USB_download( struct imginfo *img ) { int i; struct fntable fn = { usb_writechar, usb_readchar }; /* init usb hw connection. See: 12.4 UDC Hardware Connection */ GPDR0 &= ~(GPIO0_GP11 | GPIO2_GP79); PSSR |= PSSR_RDH; EdbgOutputDebugString( "Ready to download image via USB\n" ); if (!usbcable_wait() || !usb_init()) return -2; EdbgOutputDebugString( "\nUSB ready.\n" ); for (i = 0; i < 10; i++) { EdbgOutputDebugString( "." ); Try { download( &fn, img, 0 ); } Catch_anonymous { continue; }; UDCCR_CLEAR( UDCCR_UDE ); /* disable UDC */ /* high speed usb device disable */ GPDR2 &= ~GPIO2_GP79; return 0; } EdbgOutputDebugString( "\nFail to synchonize with the host\n" ); return -2; } #endif /* defined(USB_VID) && defined(USB_PID) */ #endif /* CPU == PXA250 */ --- NEW FILE: usb-sa1110.c --- /* * $Id: usb-sa1110.c,v 1.1 2002/11/27 12:41:08 telka Exp $ * * Copyright (C) 2001, 2002 ETC s.r.o. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * Written by Marcel Telka <ma...@te...>, 2001, 2002. * */ #include "board.h" #if CPU == SA1110 #include <_windows.h> #include <sa11x0/gpio.h> #include <sa11x0/udc.h> #include "download.h" #include "format.h" #if defined(USB_VID) && defined(USB_PID) #include "except.h" #include "usb.h" #define MAX_PACKET_SIZE 16 #define RETRIES 100 #define EP0_PACKET_SIZE 8 /* if you want debug messages, remove this line */ #define DEBUG_OUT(s) #ifndef DEBUG_OUT #define DEBUG_OUT(s) EdbgOutputDebugString(s) #define DEBUG_OUT2(s,p) EdbgOutputDebugString(s,p) #else #define DEBUG_OUT2(s,p) #endif /* * state * -1: udc not initialized * 0: default * 1: sending data via ep0 */ static int state = -1; static int UDCService( void ); static void USB_writechar( char c ) { static int first = 1; int Timeout = 0x200000; if (state) Throw E_USBUNINITIALIZED; while (Timeout--) { UDCService(); if (!(first || (UDCCS2 & TPC))) continue; if (!first) while (UDCCS2 & TPC) UDCCS2 = TPC; first = 0; while (UDCIMP != 0) UDCIMP = 0; UDCDR = c; while (UDCCS2 & 0x10) UDCCS2 = 0x10; /* SST */ return; } Throw E_WRITETIMEOUT; } static char USB_readchar( void ) { int Timeout = 0x200000; if (state) Throw E_USBUNINITIALIZED; while (Timeout--) { UDCService(); if (!(UDCCS1 & RPC)) continue; if (UDCCS1 & RNE) return (char) UDCDR; else while (UDCCS1 & RPC) UDCCS1 = RPC; } Throw E_READTIMEOUT; } /* device descriptor */ static const struct usb_dev_desc wid_dev_desc = { 18, /* length */ 1, /* descriptortype */ 0x0100, /* usb */ -1, /* deviceclass */ -1, /* devicesubclass */ -1, /* deviceprotocol */ 0x08, /* maxpacketsize0 */ USB_VID, /* idvendor */ USB_PID, /* idproduct */ 0, /* device */ 0, /* manufacturer */ 0, /* product */ 0, /* serialnumber */ 1, /* numconfigurations */ }; /* configuration descriptor */ static const struct usb_conf_desc wid_conf_desc = { { 9, /* length */ 2, /* descriptortype (CONFIGURATION) */ 32, /* total length */ 1, /* numinterfaces */ 1, /* configurationvalue */ 0, /* configuration */ 0x40, /* attributes */ 1, /* maxpower */ } , { 9, /* length */ 4, /* descriptortype (INTERFACE) */ 0, /* interfacenumber */ 0, /* alternatesetting */ 2, /* numendpoints */ -1, /* interfaceclass */ -1, /* interfacesubclass */ -1, /* interfaceprotocol */ 0, /* interface */ } , { 7, /* length */ 5, /* descriptortype (ENDPOINT) */ 0x01, /* endpointaddress (ep1, out) */ 2, /* mattributes (0010 = bulk) */ MAX_PACKET_SIZE, /* maxpacketsize */ 0, /* interval (ignored for bulk) */ } , { 7, /* length */ 5, /* descriptortype (ENDPOINT) */ '\x82', /* endpointaddress (ep2, in) */ 2, /* attributes (0010 = bulk) */ MAX_PACKET_SIZE, /* maxpacketsize */ 0, /* interval (ignored for bulk) */ } }; /* FIXME: there are more possible neverending stories. discover & solve */ static void InitUDC( void ) { UDCCR = 0; /* enable UDC */ UDCSR = UDCSR; /* clear all interrupts */ GPDR &= ~GPIO_USP_MASK; /* set GPIO_USP as input */ /* TODO: add workaround with bit 7 of UDCCR for B5 stepping */ UDCIMP = MAX_PACKET_SIZE - 1; /* set in max packet size */ UDCOMP = MAX_PACKET_SIZE - 1; /* set out max packet size */ state = 0; } static void DeinitUDC( void ) { UDCCR = 1; state = -1; } static void EP0_SendData( int start, int len, const void *d, int maxlen ) { static int index = 0; static int reqlen = 0; static const char *data = NULL; unsigned int count; if (start) { index = 0; if ((reqlen = len) > maxlen) reqlen = maxlen; data = d; CLEAR_OPR( UDCCS0 ); } if (index == reqlen) { if (!(index % EP0_PACKET_SIZE)) { SET_IPR( UDCCS0 ); index++; DEBUG_OUT( "'" ); return; } index++; } if (index > reqlen) { state = 0; while (!(UDCCS0 & DE)) UDCCS0 = DE; DEBUG_OUT( "/" ); return; } DEBUG_OUT( "+" ); while (UDCWC) ; /* wait for empty FIFO */ while ((count = UDCWC) != EP0_PACKET_SIZE) { int retries = RETRIES; while ((count == UDCWC) && --retries) UDCD0 = data[index]; if (!retries) { while (!(UDCCS0 & FST)) UDCCS0 = FST; DEBUG_OUT( "F" ); state = 0; return; } if (++index == reqlen) break; } SET_IPR( UDCCS0 ); } static int EP0_State0( void ) { struct usb_dev_req req; char *p = (char *) &req; unsigned int count; /* wait for full FIFO */ while (UDCWC != EP0_PACKET_SIZE) ; /* read request */ while ((count = UDCWC) != 0) { while (count == UDCWC) *p = (char) UDCD0; p++; } switch (req.request) { case 0x05: /* SET_ADDRESS */ CLEAR_OPR_DE( UDCCS0 ); UDCAR = req.value_lo; UDCAR = req.value_lo; DEBUG_OUT( "A" ); return 0; case 0x06: /* GET_DESCRIPTOR */ switch (req.value_hi) { case 1: /* DEVICE */ if (req.length == 0x12) state = 1; DEBUG_OUT2( "D(%d)", req.length ); EP0_SendData( 1, req.length, &wid_dev_desc, sizeof wid_dev_desc ); return 0; case 2: /* CONFIGURATION */ state = 1; DEBUG_OUT2( "C(%d)", req.length ); EP0_SendData( 1, req.length, &wid_conf_desc, sizeof wid_conf_desc ); return 0; default: EdbgOutputDebugString( "EP0/GET_DESCRIPTOR/value_hi = 0x%B\n", req.value_hi ); break; } break; case 0x09: /* SET_CONFIG */ CLEAR_OPR_DE( UDCCS0 ); DEBUG_OUT( "N" ); return 1; default: EdbgOutputDebugString( "EP0/request = 0x%B\n", req.request ); break; } CLEAR_OPR_DE( UDCCS0 ); return 0; } static int EP0( void ) { if (UDCCS0 & SE) { while (UDCCS0 & SE) UDCCS0 = SSE; state = 0; DEBUG_OUT( "S" ); return 0; } if (UDCCS0 & SST) { DEBUG_OUT( "T" ); while (UDCCS0 & SST) UDCCS0 = SST; return 0; } switch (state) { case -1: EdbgOutputDebugString( "UDC not initialized\n" ); break; case 0: if (UDCCS0 & OPR) return EP0_State0(); else { DEBUG_OUT( "x" ); return 0; } case 1: EP0_SendData( 0, 0, NULL, 0 ); return 0; default: EdbgOutputDebugString( "Unknown state: %d\n", state ); break; } return 0; } static int UDCService( void ) { int ret = 0; DWORD udcsr; UDCSR; udcsr = UDCSR; /* read twice for correct value */ UDCSR = udcsr; /* clears whole interrupts */ if (udcsr & RSTIR) { /* reset */ /* TODO: see doc 11-66 */ while (UDCCR & SUSIM) UDCCR &= ~SUSIM; while (UDCIMP != MAX_PACKET_SIZE - 1) UDCIMP = MAX_PACKET_SIZE - 1; /* set in max packet size */ while (UDCOMP != MAX_PACKET_SIZE - 1) UDCOMP = MAX_PACKET_SIZE - 1; /* set out max packet size */ DEBUG_OUT( "!" ); state = 0; return 0; } if (udcsr & EIR) { ret |= EP0(); return ret; } #if 0 if (udcsr & RIR) { EdbgOutputDebugString( "EP1\n" ); } if (udcsr & TIR) { EdbgOutputDebugString( "EP2\n" ); } #endif /* 0 */ if (udcsr & RESIR) { while (!(UDCCR & RESIM)) UDCCR |= RESIM; while (UDCCR & RESIM) UDCCR &= ~RESIM; while (UDCCR & SUSIM) UDCCR &= ~SUSIM; DEBUG_OUT( "RESIR\n" ); } if (udcsr & SUSIR) { while (!(UDCCR & SUSIM)) UDCCR |= SUSIM; DEBUG_OUT( "SUSIR\n" ); } return ret; } int USB_download( struct imginfo *img ) { DWORD Timeout; int i; struct fntable fn = { USB_writechar, USB_readchar }; InitUDC(); EdbgOutputDebugString( "Ready to download image via USB\n" ); EdbgOutputDebugString( "* Please connect USB cable between PC and WID.\n" ); for (i = 4, Timeout = 0; i && !Timeout; i--) { EdbgOutputDebugString( "%d\r", i ); Timeout = 0x200000; while (Timeout) { if (GPLR & GPIO_USP_MASK) { if (UDCService()) break; } else Timeout--; } } if (!Timeout) { DeinitUDC(); return -2; } EdbgOutputDebugString( "\nUSB ready.\n" ); for (i = 0; i < 10; i++) { EdbgOutputDebugString( "." ); Try { download( &fn, img, 0 ); } Catch_anonymous { continue; }; return 0; } EdbgOutputDebugString( "\nFail to synchonize with the host\n" ); return -2; } #else /* defined(USB_VID) && defined(USB_PID) */ int USB_download( struct imginfo *img ) { UNREFERENCED_PARAMETER( img ); return -2; } #endif /* defined(USB_VID) && defined(USB_PID) */ #endif /* CPU == SA1110 */ Index: ChangeLog =================================================================== RCS file: /cvsroot/openwince/xboot/ChangeLog,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ChangeLog 8 Nov 2002 14:51:44 -0000 1.6 +++ ChangeLog 27 Nov 2002 12:41:08 -0000 1.7 @@ -1,3 +1,9 @@ +2002-11-27 Marcel Telka <ma...@te...> + + * usb-pxa250.c, wep.h: Added USB support for WEP (from Daniel Samek). + * ucb.c, usb-sa1110.c: Renamed usb.c to usb-sa1110.c. + * sources: Added usb-pxa250.c, renamed usb.c to usb-sa1110.c. + 2002-11-08 Marcel Telka <ma...@te...> Version 0.1.1 released. Index: sources =================================================================== RCS file: /cvsroot/openwince/xboot/sources,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sources 31 Oct 2002 12:54:13 -0000 1.1 +++ sources 27 Nov 2002 12:41:08 -0000 1.2 @@ -68,7 +68,8 @@ download.c \ parallel.c \ serial.c \ - usb.c \ + usb-sa1110.c \ + usb-pxa250.c \ memory.c \ flash.c \ main.c Index: wep.h =================================================================== RCS file: /cvsroot/openwince/xboot/wep.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- wep.h 4 Nov 2002 07:50:46 -0000 1.2 +++ wep.h 27 Nov 2002 12:41:08 -0000 1.3 @@ -66,4 +66,17 @@ #define MEM_VIRT_XBOOT_RUN (MEM_VIRT_SDRAM + 0x00036000) #define MEM_SIZE_XBOOT_RUN 0x00010000 +#if 0 +/* + * USB VID/PID + */ + +#define USB_VID value_VID +#define USB_PID value_PID +#endif + +/* configuration */ +#define HAVE_USB + + #endif /* WEP_H */ --- usb.c DELETED --- |