diff options
author | Cástor Muñoz <cmvidal@gmail.com> | 2016-07-31 03:48:11 +0200 |
---|---|---|
committer | Cástor Muñoz <cmvidal@gmail.com> | 2016-08-02 04:57:50 +0200 |
commit | ef572fec523c3064cbec8df3ef7610a2a9b5df54 (patch) | |
tree | 1b6f979c1cd8fad4f2ed6c6114763d6d7bda8156 /firmware/target | |
parent | 3c5aa754de9c9e572232b469398a981dccfff127 (diff) | |
download | rockbox-ef572fec523c3064cbec8df3ef7610a2a9b5df54.tar.gz rockbox-ef572fec523c3064cbec8df3ef7610a2a9b5df54.zip |
iPod Nano 2G: use the new USB DesignWare driver
Change-Id: I8d1561bf4e239b55617a8d5075457a668e0c312c
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/s5l8700/usb-nano2g-6g.c | 117 | ||||
-rw-r--r-- | firmware/target/arm/s5l8700/usb-s5l8701.c | 138 |
2 files changed, 138 insertions, 117 deletions
diff --git a/firmware/target/arm/s5l8700/usb-nano2g-6g.c b/firmware/target/arm/s5l8700/usb-nano2g-6g.c deleted file mode 100644 index 6ae9f9b96b..0000000000 --- a/firmware/target/arm/s5l8700/usb-nano2g-6g.c +++ /dev/null | |||
@@ -1,117 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Michael Sparmann | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "usb.h" | ||
24 | #include "usb-s3c6400x.h" | ||
25 | #include "cpu.h" | ||
26 | |||
27 | #ifdef HAVE_USBSTACK | ||
28 | #include "usb_core.h" | ||
29 | #include "usb_drv.h" | ||
30 | |||
31 | void usb_enable(bool on) | ||
32 | { | ||
33 | if (on) usb_core_init(); | ||
34 | else usb_core_exit(); | ||
35 | } | ||
36 | |||
37 | #if CONFIG_CPU==S5L8701 | ||
38 | #include "power.h" | ||
39 | |||
40 | int usb_detect(void) | ||
41 | { | ||
42 | if (power_input_status() & POWER_INPUT_USB) | ||
43 | return USB_INSERTED; | ||
44 | return USB_EXTRACTED; | ||
45 | } | ||
46 | |||
47 | #elif CONFIG_CPU==S5L8702 | ||
48 | static int usb_status = USB_EXTRACTED; | ||
49 | |||
50 | int usb_detect(void) | ||
51 | { | ||
52 | return usb_status; | ||
53 | } | ||
54 | |||
55 | void usb_insert_int(void) | ||
56 | { | ||
57 | usb_status = USB_INSERTED; | ||
58 | #ifdef USB_STATUS_BY_EVENT | ||
59 | usb_status_event(USB_INSERTED); | ||
60 | #endif | ||
61 | } | ||
62 | |||
63 | void usb_remove_int(void) | ||
64 | { | ||
65 | usb_status = USB_EXTRACTED; | ||
66 | #ifdef USB_STATUS_BY_EVENT | ||
67 | usb_status_event(USB_EXTRACTED); | ||
68 | #endif | ||
69 | } | ||
70 | #endif /* S5L8702 */ | ||
71 | |||
72 | void usb_init_device(void) | ||
73 | { | ||
74 | /* Power up the core clocks to allow writing | ||
75 | to some registers needed to power it down */ | ||
76 | PCGCCTL = 0; | ||
77 | #if CONFIG_CPU==S5L8701 | ||
78 | PWRCON &= ~0x4000; | ||
79 | PWRCONEXT &= ~0x800; | ||
80 | INTMSK |= INTMSK_USB_OTG; | ||
81 | #elif CONFIG_CPU==S5L8702 | ||
82 | PWRCON(0) &= ~0x4; | ||
83 | PWRCON(1) &= ~0x8; | ||
84 | VIC0INTENABLE |= 1 << 19; | ||
85 | #endif | ||
86 | |||
87 | usb_drv_exit(); | ||
88 | } | ||
89 | |||
90 | #else /* !HAVE_USBSTACK */ | ||
91 | void usb_enable(bool on) | ||
92 | { | ||
93 | (void)on; | ||
94 | } | ||
95 | |||
96 | int usb_detect(void) | ||
97 | { | ||
98 | return USB_EXTRACTED; | ||
99 | } | ||
100 | |||
101 | void usb_init_device(void) | ||
102 | { | ||
103 | DCTL = DCTL_pwronprgdone | DCTL_sftdiscon; | ||
104 | |||
105 | ORSTCON = 1; /* Put the PHY into reset (needed to get current down) */ | ||
106 | PCGCCTL = 1; /* Shut down PHY clock */ | ||
107 | OPHYPWR = 0xF; /* PHY: Power down */ | ||
108 | |||
109 | #if CONFIG_CPU==S5L8701 | ||
110 | PWRCON |= 0x4000; | ||
111 | PWRCONEXT |= 0x800; | ||
112 | #elif CONFIG_CPU==S5L8702 | ||
113 | PWRCON(0) |= 0x4; | ||
114 | PWRCON(1) |= 0x8; | ||
115 | #endif | ||
116 | } | ||
117 | #endif | ||
diff --git a/firmware/target/arm/s5l8700/usb-s5l8701.c b/firmware/target/arm/s5l8700/usb-s5l8701.c new file mode 100644 index 0000000000..860f54b2d8 --- /dev/null +++ b/firmware/target/arm/s5l8700/usb-s5l8701.c | |||
@@ -0,0 +1,138 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2014 Michael Sparmann | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include <inttypes.h> | ||
22 | |||
23 | #include "config.h" | ||
24 | #include "usb.h" | ||
25 | #include "usb_drv.h" | ||
26 | #ifdef HAVE_USBSTACK | ||
27 | #include "usb_core.h" | ||
28 | #include "power.h" | ||
29 | #endif | ||
30 | |||
31 | #include "s5l8700.h" | ||
32 | #include "usb-designware.h" | ||
33 | |||
34 | |||
35 | const struct usb_dw_config usb_dw_config = | ||
36 | { | ||
37 | /* PHY must run at 60MHz, otherwise there are spurious -EPROTO | ||
38 | errors, probably related with GHWCFG4_MIN_AHB_FREQ. */ | ||
39 | .phytype = DWC_PHYTYPE_UTMI_8, | ||
40 | |||
41 | /* | ||
42 | * Total available FIFO memory: 0x500 words. | ||
43 | */ | ||
44 | .rx_fifosz = 0x220, | ||
45 | /* nptx_fifosz seems limited to 0x200 due to some internal counter | ||
46 | misbehaviour (TBC). */ | ||
47 | .nptx_fifosz = 0x200, | ||
48 | /* ptx_fifosz is not writeable (fixed to 0x300), anyway it seems | ||
49 | internally limited to a small number, aroung 0x10..0x20 (TBC), | ||
50 | we use_ptxfifo_as_plain_buffer to deal with this issue. */ | ||
51 | .ptx_fifosz = 0x80, | ||
52 | .use_ptxfifo_as_plain_buffer = true, | ||
53 | |||
54 | #ifdef USB_DW_ARCH_SLAVE | ||
55 | .disable_double_buffering = false, | ||
56 | #else | ||
57 | .ahb_burst_len = HBSTLEN_INCR4, | ||
58 | #endif | ||
59 | }; | ||
60 | |||
61 | void usb_dw_target_enable_clocks() | ||
62 | { | ||
63 | PWRCON &= ~0x4000; | ||
64 | PWRCONEXT &= ~0x800; | ||
65 | |||
66 | OPHYPWR = 0; /* PHY: Power up */ | ||
67 | udelay(10); | ||
68 | OPHYUNK1 = 1; | ||
69 | OPHYUNK2 = 0xe3f; | ||
70 | ORSTCON = 1; /* PHY: Assert Software Reset */ | ||
71 | udelay(10); | ||
72 | ORSTCON = 0; /* PHY: Deassert Software Reset */ | ||
73 | udelay(10); | ||
74 | OPHYUNK3 = 0x600; | ||
75 | OPHYCLK = USB_DW_CLOCK; | ||
76 | udelay(400); | ||
77 | } | ||
78 | |||
79 | void usb_dw_target_disable_clocks() | ||
80 | { | ||
81 | OPHYPWR = 0xf; /* PHY: Power down */ | ||
82 | udelay(10); | ||
83 | ORSTCON = 7; /* PHY: Assert Software Reset */ | ||
84 | udelay(10); | ||
85 | |||
86 | PWRCON |= 0x4000; | ||
87 | PWRCONEXT |= 0x800; | ||
88 | } | ||
89 | |||
90 | void usb_dw_target_enable_irq() | ||
91 | { | ||
92 | INTMSK |= INTMSK_USB_OTG; | ||
93 | } | ||
94 | |||
95 | void usb_dw_target_disable_irq() | ||
96 | { | ||
97 | INTMSK &= ~INTMSK_USB_OTG; | ||
98 | } | ||
99 | |||
100 | void usb_dw_target_clear_irq() | ||
101 | { | ||
102 | SRCPND |= INTMSK_USB_OTG; | ||
103 | } | ||
104 | |||
105 | /* RB API fuctions */ | ||
106 | void usb_enable(bool on) | ||
107 | { | ||
108 | #ifdef HAVE_USBSTACK | ||
109 | if (on){ | ||
110 | cpu_boost(1); | ||
111 | usb_core_init(); | ||
112 | } else { | ||
113 | usb_core_exit(); | ||
114 | cpu_boost(0); | ||
115 | } | ||
116 | #else | ||
117 | (void)on; | ||
118 | #endif | ||
119 | } | ||
120 | |||
121 | int usb_detect(void) | ||
122 | { | ||
123 | #ifdef HAVE_USBSTACK | ||
124 | if (power_input_status() & POWER_INPUT_USB) | ||
125 | return USB_INSERTED; | ||
126 | #endif | ||
127 | return USB_EXTRACTED; | ||
128 | } | ||
129 | |||
130 | void usb_init_device(void) | ||
131 | { | ||
132 | /* Power up the core clocks to allow writing | ||
133 | to some registers needed to power it down */ | ||
134 | usb_dw_target_disable_irq(); | ||
135 | usb_dw_target_enable_clocks(); | ||
136 | |||
137 | usb_drv_exit(); | ||
138 | } | ||