forked from len0rd/rockbox
		
	Sansa AMS USB driver : still not working
Implement usb_enable() Reorder/Modify usb_drv_init() to match closer the OF and remove a freeze (USB registers were accessed before the USB module was enabled) Add a panic in USB isr to be sure we notice when it's called Reset GPIOA direction for usb_detect() to notice extraction Add some comments git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23184 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
		
							parent
							
								
									5303ab101b
								
							
						
					
					
						commit
						8bd8d06842
					
				
					 2 changed files with 26 additions and 26 deletions
				
			
		|  | @ -22,6 +22,7 @@ | |||
| #include <stdbool.h> | ||||
| #include "config.h" | ||||
| #include "usb.h" | ||||
| #include "usb_core.h" | ||||
| #include "usb-target.h" | ||||
| #include "power.h" | ||||
| #include "as3525.h" | ||||
|  | @ -38,7 +39,10 @@ | |||
| 
 | ||||
| void usb_enable(bool on) | ||||
| { | ||||
|     (void)on; | ||||
|     if (on) | ||||
|         usb_core_init(); | ||||
|     else | ||||
|         usb_core_exit(); | ||||
| } | ||||
| 
 | ||||
| void usb_init_device(void) | ||||
|  |  | |||
|  | @ -26,6 +26,10 @@ | |||
| #include "ascodec.h" | ||||
| #include "as3514.h" | ||||
| #include <stdbool.h> | ||||
| #include "panic.h" | ||||
| //#define LOGF_ENABLE
 | ||||
| #include "logf.h" | ||||
| 
 | ||||
| 
 | ||||
| /* 4 input endpoints */ | ||||
| #define USB_IEP_CTRL(i)     *((volatile unsigned long*) USB_BASE + 0x0000 + (i*0x20)) | ||||
|  | @ -120,11 +124,6 @@ void usb_drv_init(void) | |||
|     ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) | 1<<2); | ||||
|     ascodec_write(AS3514_USB_UTIL, ascodec_read(AS3514_USB_UTIL) & ~(1<<4)); | ||||
| 
 | ||||
|     USB_GPIO_CSR |= 0x1C00000; //sleep(3)
 | ||||
|     sleep(1); | ||||
|     USB_GPIO_CSR |= 0x200000; //sleep(10)
 | ||||
|     sleep(1); | ||||
| 
 | ||||
|     /* PHY part */ | ||||
|     CGU_USB = 1<<5 /* enable */ | ||||
|         | (CLK_DIV(AS3525_PLLA_FREQ, 48000000) / 2) << 2 | ||||
|  | @ -133,37 +132,33 @@ void usb_drv_init(void) | |||
|     /* AHB part */ | ||||
|     CGU_PERI |= CGU_USB_CLOCK_ENABLE; | ||||
| 
 | ||||
|     USB_GPIO_CSR = 0x6180000; | ||||
|     USB_DEV_CFG = (USB_DEV_CFG & ~3) | 1; /* full speed */ | ||||
|     USB_DEV_CTRL |= 0x400; /* soft disconnect */ | ||||
| 
 | ||||
|     /* UVDD */ | ||||
|     ascodec_write(AS3514_USB_UTIL, ascodec_read(AS3514_USB_UTIL) | (1<<4)); | ||||
| 
 | ||||
|     sleep(10); | ||||
| 
 | ||||
|     USB_DEV_CFG |= (1<<31); /* soft reset */ | ||||
|     volatile int tmp = USB_DEV_CFG; | ||||
|     (void)tmp; | ||||
|     sleep(10); //msleep(100)
 | ||||
| 
 | ||||
|     USB_GPIO_CSR = 0x6180000; | ||||
| 
 | ||||
|     USB_DEV_CFG = (USB_DEV_CFG & ~3) | 1; /* full speed */ | ||||
|     USB_GPIO_CSR |= 0x1C00000; | ||||
|     sleep(1); //msleep(3)
 | ||||
|     USB_GPIO_CSR |= 0x200000; | ||||
|     sleep(1); //msleep(10)
 | ||||
| 
 | ||||
|     USB_DEV_CTRL |= 0x400; /* soft disconnect */ | ||||
| 
 | ||||
|     USB_GPIO_CSR &= ~0x1C00000; | ||||
|     sleep(1); //msleep(3)
 | ||||
|     USB_GPIO_CSR &= ~0x200000; | ||||
|     sleep(1); //msleep(10)
 | ||||
|     USB_DEV_CTRL &= ~0x400; /* clear soft disconnect */ | ||||
| 
 | ||||
|     USB_GPIO_CSR |= 0x1C00000; //sleep(3)
 | ||||
|     sleep(1); | ||||
|     USB_GPIO_CSR |= 0x200000; //sleep(10)
 | ||||
|     sleep(1); | ||||
| 
 | ||||
|     USB_DEV_CTRL |= 0x400; /* soft disconnect */ | ||||
| 
 | ||||
|     USB_GPIO_CSR &= ~0x1C00000; //sleep(3)
 | ||||
|     sleep(1); | ||||
|     USB_GPIO_CSR &= ~0x200000; //sleep(10)
 | ||||
|     sleep(1); | ||||
|     USB_DEV_CTRL &= ~0x400; /* soft disconnect */ | ||||
| 
 | ||||
|     /* note : this pin might be Clip specific */ | ||||
|     GPIOA_DIR |= (1<<6); | ||||
|     GPIOA_PIN(6) = (1<<6); | ||||
|     GPIOA_DIR &= ~(1<<6);   /* restore direction for usb_detect() */ | ||||
| 
 | ||||
| #if 0 /* linux */
 | ||||
|     USB_DEV_CFG |= (1<<17)  /* csr programming */ | ||||
|  | @ -260,6 +255,7 @@ int usb_drv_send_nonblocking(int ep, void *ptr, int len) | |||
| /* interrupt service routine */ | ||||
| void INT_USB(void) | ||||
| { | ||||
|     panicf("USB interrupt !"); | ||||
| } | ||||
| 
 | ||||
| /* (not essential? , not implemented in usb-tcc.c) */ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue