| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: exynos_usb.c,v 1.10 2014/09/21 15:22:40 reinoud Exp $ */ | | 1 | /* $NetBSD: exynos_usb.c,v 1.11 2014/09/24 20:51:43 reinoud Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2014 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Reinoud Zandijk. | | 8 | * by Reinoud Zandijk. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -25,27 +25,27 @@ | | | @@ -25,27 +25,27 @@ |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include "locators.h" | | 32 | #include "locators.h" |
33 | #include "ohci.h" | | 33 | #include "ohci.h" |
34 | #include "ehci.h" | | 34 | #include "ehci.h" |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | | | 37 | |
38 | __KERNEL_RCSID(1, "$NetBSD: exynos_usb.c,v 1.10 2014/09/21 15:22:40 reinoud Exp $"); | | 38 | __KERNEL_RCSID(1, "$NetBSD: exynos_usb.c,v 1.11 2014/09/24 20:51:43 reinoud Exp $"); |
39 | | | 39 | |
40 | #include <sys/param.h> | | 40 | #include <sys/param.h> |
41 | #include <sys/systm.h> | | 41 | #include <sys/systm.h> |
42 | #include <sys/kernel.h> | | 42 | #include <sys/kernel.h> |
43 | #include <sys/intr.h> | | 43 | #include <sys/intr.h> |
44 | #include <sys/bus.h> | | 44 | #include <sys/bus.h> |
45 | #include <sys/device.h> | | 45 | #include <sys/device.h> |
46 | #include <sys/proc.h> | | 46 | #include <sys/proc.h> |
47 | #include <sys/queue.h> | | 47 | #include <sys/queue.h> |
48 | #include <sys/kmem.h> | | 48 | #include <sys/kmem.h> |
49 | #include <sys/gpio.h> | | 49 | #include <sys/gpio.h> |
50 | | | 50 | |
51 | #include <dev/usb/usb.h> | | 51 | #include <dev/usb/usb.h> |
| @@ -98,26 +98,36 @@ static struct exynos_gpio_pinset e4_uhos | | | @@ -98,26 +98,36 @@ static struct exynos_gpio_pinset e4_uhos |
98 | .pinset_group = "ETC6", | | 98 | .pinset_group = "ETC6", |
99 | .pinset_func = 0, | | 99 | .pinset_func = 0, |
100 | .pinset_mask = __BIT(6) | __BIT(7), | | 100 | .pinset_mask = __BIT(6) | __BIT(7), |
101 | }; | | 101 | }; |
102 | #endif | | 102 | #endif |
103 | | | 103 | |
104 | | | 104 | |
105 | #ifdef EXYNOS5 | | 105 | #ifdef EXYNOS5 |
106 | static struct exynos_gpio_pinset e5_uhost_pwr_pinset = { | | 106 | static struct exynos_gpio_pinset e5_uhost_pwr_pinset = { |
107 | .pinset_group = "ETC6", | | 107 | .pinset_group = "ETC6", |
108 | .pinset_func = 0, | | 108 | .pinset_func = 0, |
109 | .pinset_mask = __BIT(5) | __BIT(6), | | 109 | .pinset_mask = __BIT(5) | __BIT(6), |
110 | }; | | 110 | }; |
| | | 111 | static struct exynos_gpio_pinset e5_usb3_bus0_pinset = { |
| | | 112 | .pinset_group = "GPK3", |
| | | 113 | .pinset_func = 2, |
| | | 114 | .pinset_mask = __BIT(0) | __BIT(1) | __BIT(3), |
| | | 115 | }; |
| | | 116 | static struct exynos_gpio_pinset e5_usb3_bus1_pinset = { |
| | | 117 | .pinset_group = "GPK2", |
| | | 118 | .pinset_func = 2, |
| | | 119 | .pinset_mask = __BIT(4) | __BIT(5) | __BIT(7), |
| | | 120 | }; |
111 | #endif | | 121 | #endif |
112 | | | 122 | |
113 | | | 123 | |
114 | static int exynos_usb_intr(void *arg); | | 124 | static int exynos_usb_intr(void *arg); |
115 | static void exynos_usb_phy_init(struct exynos_usb_softc *sc); | | 125 | static void exynos_usb_phy_init(struct exynos_usb_softc *sc); |
116 | | | 126 | |
117 | | | 127 | |
118 | static int exynos_usb_match(device_t, cfdata_t, void *); | | 128 | static int exynos_usb_match(device_t, cfdata_t, void *); |
119 | static void exynos_usb_attach(device_t, device_t, void *); | | 129 | static void exynos_usb_attach(device_t, device_t, void *); |
120 | | | 130 | |
121 | CFATTACH_DECL_NEW(exyo_usb, 0, | | 131 | CFATTACH_DECL_NEW(exyo_usb, 0, |
122 | exynos_usb_match, exynos_usb_attach, NULL, NULL); | | 132 | exynos_usb_match, exynos_usb_attach, NULL, NULL); |
123 | | | 133 | |
| @@ -193,40 +203,72 @@ exynos_usb_attach(device_t parent, devic | | | @@ -193,40 +203,72 @@ exynos_usb_attach(device_t parent, devic |
193 | bus_space_subregion(sc->sc_bst, exyoaa->exyo_core_bsh, | | 203 | bus_space_subregion(sc->sc_bst, exyoaa->exyo_core_bsh, |
194 | pmu_offset, EXYNOS_BLOCK_SIZE, | | 204 | pmu_offset, EXYNOS_BLOCK_SIZE, |
195 | &sc->sc_pmuregs_bsh); | | 205 | &sc->sc_pmuregs_bsh); |
196 | | | 206 | |
197 | aprint_naive("\n"); | | 207 | aprint_naive("\n"); |
198 | aprint_normal("\n"); | | 208 | aprint_normal("\n"); |
199 | | | 209 | |
200 | /* power up USB subsystem */ | | 210 | /* power up USB subsystem */ |
201 | #ifdef EXYNOS4 | | 211 | #ifdef EXYNOS4 |
202 | if (IS_EXYNOS4_P()) { | | 212 | if (IS_EXYNOS4_P()) { |
203 | exynos_gpio_pinset_acquire(&e4_uhost_pwr_pinset); | | 213 | exynos_gpio_pinset_acquire(&e4_uhost_pwr_pinset); |
204 | exynos_gpio_pinset_to_pindata(&e4_uhost_pwr_pinset, 6, &XuhostPWREN); | | 214 | exynos_gpio_pinset_to_pindata(&e4_uhost_pwr_pinset, 6, &XuhostPWREN); |
205 | exynos_gpio_pinset_to_pindata(&e4_uhost_pwr_pinset, 7, &XuhostOVERCUR); | | 215 | exynos_gpio_pinset_to_pindata(&e4_uhost_pwr_pinset, 7, &XuhostOVERCUR); |
| | | 216 | |
| | | 217 | /* enable power and set Xuhost OVERCUR to inactive by pulling it up */ |
| | | 218 | exynos_gpio_pindata_ctl(&XuhostPWREN, GPIO_PIN_PULLUP); |
| | | 219 | exynos_gpio_pindata_ctl(&XuhostOVERCUR, GPIO_PIN_PULLUP); |
| | | 220 | DELAY(80000); |
206 | } | | 221 | } |
207 | #endif | | 222 | #endif |
208 | #ifdef EXYNOS5 | | 223 | #ifdef EXYNOS5 |
209 | if (IS_EXYNOS5_P()) { | | 224 | if (IS_EXYNOS5410_P()) { |
| | | 225 | struct exynos_gpio_pindata Xovercur2, Xovercur3; |
| | | 226 | struct exynos_gpio_pindata Xvbus; |
| | | 227 | |
| | | 228 | /* BUS 0 */ |
| | | 229 | exynos_gpio_pinset_acquire(&e5_usb3_bus0_pinset); |
| | | 230 | exynos_gpio_pinset_to_pindata(&e5_usb3_bus0_pinset, 0, &Xovercur2); |
| | | 231 | exynos_gpio_pinset_to_pindata(&e5_usb3_bus0_pinset, 1, &Xovercur3); |
| | | 232 | exynos_gpio_pinset_to_pindata(&e5_usb3_bus0_pinset, 3, &Xvbus); |
| | | 233 | |
| | | 234 | /* enable power and set overcur inactive by pulling them up */ |
| | | 235 | exynos_gpio_pindata_ctl(&Xvbus, GPIO_PIN_PULLUP); |
| | | 236 | exynos_gpio_pindata_ctl(&Xovercur2, GPIO_PIN_PULLUP); |
| | | 237 | exynos_gpio_pindata_ctl(&Xovercur3, GPIO_PIN_PULLUP); |
| | | 238 | |
| | | 239 | /* BUS 1 */ |
| | | 240 | exynos_gpio_pinset_acquire(&e5_usb3_bus1_pinset); |
| | | 241 | exynos_gpio_pinset_to_pindata(&e5_usb3_bus1_pinset, 4, &Xovercur2); |
| | | 242 | exynos_gpio_pinset_to_pindata(&e5_usb3_bus1_pinset, 5, &Xovercur3); |
| | | 243 | exynos_gpio_pinset_to_pindata(&e5_usb3_bus1_pinset, 7, &Xvbus); |
| | | 244 | |
| | | 245 | /* enable power and set overcur inactive by pulling them up */ |
| | | 246 | exynos_gpio_pindata_ctl(&Xvbus, GPIO_PIN_PULLUP); |
| | | 247 | exynos_gpio_pindata_ctl(&Xovercur2, GPIO_PIN_PULLUP); |
| | | 248 | exynos_gpio_pindata_ctl(&Xovercur3, GPIO_PIN_PULLUP); |
| | | 249 | |
| | | 250 | /* enable power to the hub */ |
210 | exynos_gpio_pinset_acquire(&e5_uhost_pwr_pinset); | | 251 | exynos_gpio_pinset_acquire(&e5_uhost_pwr_pinset); |
211 | exynos_gpio_pinset_to_pindata(&e5_uhost_pwr_pinset, 5, &XuhostPWREN); | | 252 | exynos_gpio_pinset_to_pindata(&e5_uhost_pwr_pinset, 5, &XuhostPWREN); |
212 | exynos_gpio_pinset_to_pindata(&e5_uhost_pwr_pinset, 6, &XuhostOVERCUR); | | 253 | exynos_gpio_pinset_to_pindata(&e5_uhost_pwr_pinset, 6, &XuhostOVERCUR); |
| | | 254 | |
| | | 255 | /* enable power and set Xuhost OVERCUR to inactive by pulling it up */ |
| | | 256 | exynos_gpio_pindata_ctl(&XuhostPWREN, GPIO_PIN_PULLUP); |
| | | 257 | exynos_gpio_pindata_ctl(&XuhostOVERCUR, GPIO_PIN_PULLUP); |
| | | 258 | DELAY(80000); |
213 | } | | 259 | } |
214 | #endif | | 260 | #endif |
215 | | | 261 | |
216 | /* enable power and set Xuhost OVERCUR to inactive by pulling it up */ | | | |
217 | exynos_gpio_pindata_ctl(&XuhostPWREN, GPIO_PIN_PULLUP); | | | |
218 | exynos_gpio_pindata_ctl(&XuhostOVERCUR, GPIO_PIN_PULLUP); | | | |
219 | DELAY(80000); | | | |
220 | | | 262 | |
221 | /* init USB phys */ | | 263 | /* init USB phys */ |
222 | exynos_usb_phy_init(sc); | | 264 | exynos_usb_phy_init(sc); |
223 | | | 265 | |
224 | /* | | 266 | /* |
225 | * Disable interrupts | | 267 | * Disable interrupts |
226 | * | | 268 | * |
227 | * To prevent OHCI lockups on Exynos5 SoCs, we first have to read the | | 269 | * To prevent OHCI lockups on Exynos5 SoCs, we first have to read the |
228 | * address before we set it; this is most likely a bug in the SoC | | 270 | * address before we set it; this is most likely a bug in the SoC |
229 | */ | | 271 | */ |
230 | #if NOHCI > 0 | | 272 | #if NOHCI > 0 |
231 | int regval; | | 273 | int regval; |
232 | | | 274 | |