summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/sansa-connect/usb-sansaconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tms320dm320/sansa-connect/usb-sansaconnect.c')
-rw-r--r--firmware/target/arm/tms320dm320/sansa-connect/usb-sansaconnect.c67
1 files changed, 13 insertions, 54 deletions
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/usb-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/usb-sansaconnect.c
index abe6622f0b..986efe374c 100644
--- a/firmware/target/arm/tms320dm320/sansa-connect/usb-sansaconnect.c
+++ b/firmware/target/arm/tms320dm320/sansa-connect/usb-sansaconnect.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id: $ 8 * $Id: $
9 * 9 *
10 * Copyright (C) 2011 by Tomasz Moń 10 * Copyright (C) 2011-2021 by Tomasz Moń
11 * 11 *
12 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 13 * modify it under the terms of the GNU General Public License
@@ -22,52 +22,12 @@
22#include "config.h" 22#include "config.h"
23#include "system.h" 23#include "system.h"
24#include "kernel.h" 24#include "kernel.h"
25#include "usb.h"
26#ifdef HAVE_USBSTACK
27#include "usb_drv.h"
28#include "usb_core.h" 25#include "usb_core.h"
29#endif
30
31static bool usb_is_connected = false;
32 26
33static int usb_detect_callback(struct timeout *tmo) 27static int usb_detect_callback(struct timeout *tmo)
34{ 28{
35 (void)tmo; 29 (void)tmo;
36 30 usb_status_event(usb_detect());
37 if (IO_GIO_BITSET0 & (1 << 9))
38 {
39 /* Set GIO33 as normal output, drive it low */
40 IO_GIO_FSEL3 &= ~(0x0003);
41 IO_GIO_BITCLR2 = (1 << 1);
42
43 /* Disable M48XI crystal resonator */
44 IO_CLK_LPCTL1 |= 0x01;
45
46 /* Drive reset low */
47 IO_GIO_BITCLR0 = (1 << 7);
48
49 /* Disable VLYNQ clock */
50 IO_CLK_MOD2 &= ~(1 << 13);
51
52 usb_is_connected = false;
53 }
54 else
55 {
56 /* Enable M48XI crystal resonator */
57 IO_CLK_LPCTL1 &= ~(0x01);
58
59 /* Set GIO33 as CLKOUT1B */
60 IO_GIO_FSEL3 |= 0x0003;
61
62 /* Drive reset high */
63 IO_GIO_BITSET0 = (1 << 7);
64
65 /* Enable VLYNQ clock */
66 IO_CLK_MOD2 |= (1 << 13);
67
68 usb_is_connected = true;
69 }
70
71 return 0; 31 return 0;
72} 32}
73 33
@@ -82,20 +42,15 @@ void GIO9(void)
82 timeout_register(&usb_oneshot, usb_detect_callback, HZ, 0); 42 timeout_register(&usb_oneshot, usb_detect_callback, HZ, 0);
83} 43}
84 44
85bool usb_drv_connected(void)
86{
87 return false;
88}
89
90int usb_detect(void) 45int usb_detect(void)
91{ 46{
92 if (usb_is_connected == true) 47 if (IO_GIO_BITSET0 & (1 << 9))
93 { 48 {
94 return USB_INSERTED; 49 return USB_EXTRACTED;
95 } 50 }
96 else 51 else
97 { 52 {
98 return USB_EXTRACTED; 53 return USB_INSERTED;
99 } 54 }
100} 55}
101 56
@@ -127,14 +82,18 @@ void usb_init_device(void)
127 82
128 /* Enable USB insert detection interrupt */ 83 /* Enable USB insert detection interrupt */
129 IO_INTC_EINT1 |= (1 << 14); 84 IO_INTC_EINT1 |= (1 << 14);
130
131 /* Check if USB is connected */
132 usb_detect_callback(NULL);
133} 85}
134 86
135void usb_enable(bool on) 87void usb_enable(bool on)
136{ 88{
137 (void)on; 89 if (on)
90 {
91 usb_core_init();
92 }
93 else
94 {
95 usb_core_exit();
96 }
138} 97}
139 98
140void usb_attach(void) 99void usb_attach(void)