diff options
Diffstat (limited to 'firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c')
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c index 217a7d3cef..79f43f07a6 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/usb-meg-fx.c | |||
@@ -26,8 +26,8 @@ | |||
26 | #define USB_RST_ASSERT GPBDAT &= ~(1 << 4) | 26 | #define USB_RST_ASSERT GPBDAT &= ~(1 << 4) |
27 | #define USB_RST_DEASSERT GPBDAT |= (1 << 4) | 27 | #define USB_RST_DEASSERT GPBDAT |= (1 << 4) |
28 | 28 | ||
29 | #define USB_VPLUS_PWR_ASSERT GPBDAT |= (1 << 6) | 29 | #define USB_VBUS_PWR_ASSERT GPBDAT |= (1 << 6) |
30 | #define USB_VPLUS_PWR_DEASSERT GPBDAT &= ~(1 << 6) | 30 | #define USB_VBUS_PWR_DEASSERT GPBDAT &= ~(1 << 6) |
31 | 31 | ||
32 | #define USB_UNIT_IS_PRESENT !(GPFDAT & 0x01) | 32 | #define USB_UNIT_IS_PRESENT !(GPFDAT & 0x01) |
33 | #define USB_CRADLE_IS_PRESENT ((GPFDAT &0x02)&&((GPGDAT&(3<<13))==(1<<13))) | 33 | #define USB_CRADLE_IS_PRESENT ((GPFDAT &0x02)&&((GPGDAT&(3<<13))==(1<<13))) |
@@ -46,16 +46,21 @@ int usb_detect(void) | |||
46 | 46 | ||
47 | void usb_init_device(void) | 47 | void usb_init_device(void) |
48 | { | 48 | { |
49 | /* Input is the default configuration, only pullups need to be disabled */ | 49 | /* Setup USB Cradle Power control (output, disabled, no pullup) */ |
50 | /* GPFUP|=0x02; */ | 50 | GPHCON=( GPHCON&~(1<<17) ) | (1<<16); |
51 | GPHUP|=1<<8; | ||
52 | USB_CRADLE_BUS_DISABLE; | ||
51 | 53 | ||
54 | /* Setup VBUS PWR (output, asserted, no pullup) */ | ||
52 | GPBCON=( GPBCON&~(1<<13) ) | (1 << 12); | 55 | GPBCON=( GPBCON&~(1<<13) ) | (1 << 12); |
53 | USB_VPLUS_PWR_ASSERT; | 56 | GPBUP|=1<<6; |
57 | USB_VBUS_PWR_ASSERT; | ||
54 | 58 | ||
55 | sleep(HZ/20); | 59 | sleep(HZ/20); |
56 | 60 | ||
57 | /* Reset the usb port */ | 61 | /* Setup USB reset (output, asserted, no pullup) */ |
58 | GPBCON = (GPBCON & ~0x200) | 0x100; /* Make sure reset line is an output */ | 62 | GPBCON = (GPBCON & ~0x200) | 0x100; /* Make sure reset line is an output */ |
63 | GPBUP|=1<<4; | ||
59 | USB_RST_ASSERT; | 64 | USB_RST_ASSERT; |
60 | 65 | ||
61 | sleep(HZ/25); | 66 | sleep(HZ/25); |
@@ -71,25 +76,22 @@ void usb_init_device(void) | |||
71 | sleep(HZ/25); | 76 | sleep(HZ/25); |
72 | 77 | ||
73 | /* leave chip in low power mode */ | 78 | /* leave chip in low power mode */ |
74 | USB_VPLUS_PWR_DEASSERT; | 79 | USB_VBUS_PWR_DEASSERT; |
75 | 80 | ||
76 | sleep(HZ/25); | 81 | sleep(HZ/25); |
77 | } | 82 | } |
78 | 83 | ||
79 | void usb_enable(bool on) | 84 | void usb_enable(bool on) |
80 | { | 85 | { |
81 | GPHCON=( GPHCON&~(1<<17) ) | (1<<16); /* Make the pin an output */ | ||
82 | GPHUP|=1<<8; /* Disable pullup in SOC as we are now driving */ | ||
83 | |||
84 | if (on) | 86 | if (on) |
85 | { | 87 | { |
86 | USB_VPLUS_PWR_ASSERT; | 88 | USB_VBUS_PWR_ASSERT; |
87 | if(USB_CRADLE_IS_PRESENT) USB_CRADLE_BUS_ENABLE; | 89 | if(USB_CRADLE_IS_PRESENT) USB_CRADLE_BUS_ENABLE; |
88 | } | 90 | } |
89 | else | 91 | else |
90 | { | 92 | { |
91 | if(USB_CRADLE_IS_PRESENT) USB_CRADLE_BUS_DISABLE; | 93 | if(USB_CRADLE_IS_PRESENT) USB_CRADLE_BUS_DISABLE; |
92 | USB_VPLUS_PWR_DEASSERT; | 94 | USB_VBUS_PWR_DEASSERT; |
93 | } | 95 | } |
94 | 96 | ||
95 | sleep(HZ/20); // > 50ms for detecting the enable state change | 97 | sleep(HZ/20); // > 50ms for detecting the enable state change |