| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: octeon_xhci.c,v 1.1 2020/07/16 21:34:52 jmcneill Exp $ */ | | 1 | /* $NetBSD: octeon_xhci.c,v 1.2 2020/07/17 08:06:02 simonb Exp $ */ |
2 | /* $OpenBSD: octxhci.c,v 1.4 2019/09/29 04:32:23 visa Exp $ */ | | 2 | /* $OpenBSD: octxhci.c,v 1.4 2019/09/29 04:32:23 visa Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2017 Visa Hankala | | 5 | * Copyright (c) 2017 Visa Hankala |
6 | * Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca> | | 6 | * Copyright (c) 2020 Jared McNeill <jmcneill@invisible.ca> |
7 | * | | 7 | * |
8 | * Permission to use, copy, modify, and distribute this software for any | | 8 | * Permission to use, copy, modify, and distribute this software for any |
9 | * purpose with or without fee is hereby granted, provided that the above | | 9 | * purpose with or without fee is hereby granted, provided that the above |
10 | * copyright notice and this permission notice appear in all copies. | | 10 | * copyright notice and this permission notice appear in all copies. |
11 | * | | 11 | * |
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| @@ -141,27 +141,26 @@ octxhci_attach(device_t parent, device_t | | | @@ -141,27 +141,26 @@ octxhci_attach(device_t parent, device_t |
141 | } | | 141 | } |
142 | clock_type_ss = fdtbus_get_string(phandle, "refclk-type-ss"); | | 142 | clock_type_ss = fdtbus_get_string(phandle, "refclk-type-ss"); |
143 | if (clock_type_ss == NULL) { | | 143 | if (clock_type_ss == NULL) { |
144 | aprint_error(": couldn't get refclk-type-ss property\n"); | | 144 | aprint_error(": couldn't get refclk-type-ss property\n"); |
145 | return; | | 145 | return; |
146 | } | | 146 | } |
147 | | | 147 | |
148 | clock_sel = 0; | | 148 | clock_sel = 0; |
149 | if (strcmp(clock_type_ss, "dlmc_ref_clk1") == 0) | | 149 | if (strcmp(clock_type_ss, "dlmc_ref_clk1") == 0) |
150 | clock_sel |= 1; | | 150 | clock_sel |= 1; |
151 | if (strcmp(clock_type_hs, "pll_ref_clk") == 0) | | 151 | if (strcmp(clock_type_hs, "pll_ref_clk") == 0) |
152 | clock_sel |= 2; | | 152 | clock_sel |= 2; |
153 | | | 153 | |
154 | if (0) | | | |
155 | octxhci_uctl_init(osc, clock_freq, clock_sel); | | 154 | octxhci_uctl_init(osc, clock_freq, clock_sel); |
156 | | | 155 | |
157 | if (octxhci_dwc3_init(sc) != 0) { | | 156 | if (octxhci_dwc3_init(sc) != 0) { |
158 | /* Error message has been printed already. */ | | 157 | /* Error message has been printed already. */ |
159 | return; | | 158 | return; |
160 | } | | 159 | } |
161 | | | 160 | |
162 | if (!fdtbus_intr_str(child, 0, intrstr, sizeof(intrstr))) { | | 161 | if (!fdtbus_intr_str(child, 0, intrstr, sizeof(intrstr))) { |
163 | aprint_error_dev(self, "failed to decode interrupt\n"); | | 162 | aprint_error_dev(self, "failed to decode interrupt\n"); |
164 | return; | | 163 | return; |
165 | } | | 164 | } |
166 | | | 165 | |
167 | ih = fdtbus_intr_establish(child, 0, IPL_USB, FDT_INTR_MPSAFE, | | 166 | ih = fdtbus_intr_establish(child, 0, IPL_USB, FDT_INTR_MPSAFE, |
| @@ -320,28 +319,28 @@ octxhci_uctl_init(struct octxhci_softc * | | | @@ -320,28 +319,28 @@ octxhci_uctl_init(struct octxhci_softc * |
320 | val |= XCTL_CTL_CSCLK_EN; | | 319 | val |= XCTL_CTL_CSCLK_EN; |
321 | XCTL_WR_8(sc, XCTL_CTL, val); | | 320 | XCTL_WR_8(sc, XCTL_CTL, val); |
322 | | | 321 | |
323 | /* Take the PHY out of reset. */ | | 322 | /* Take the PHY out of reset. */ |
324 | val = XCTL_RD_8(sc, XCTL_CTL); | | 323 | val = XCTL_RD_8(sc, XCTL_CTL); |
325 | val &= ~XCTL_CTL_UPHY_RST; | | 324 | val &= ~XCTL_CTL_UPHY_RST; |
326 | XCTL_WR_8(sc, XCTL_CTL, val); | | 325 | XCTL_WR_8(sc, XCTL_CTL, val); |
327 | (void)XCTL_RD_8(sc, XCTL_CTL); | | 326 | (void)XCTL_RD_8(sc, XCTL_CTL); |
328 | | | 327 | |
329 | /* Fix endianess. */ | | 328 | /* Fix endianess. */ |
330 | val = XCTL_RD_8(sc, XCTL_SHIM_CFG); | | 329 | val = XCTL_RD_8(sc, XCTL_SHIM_CFG); |
331 | val &= ~XCTL_SHIM_CFG_CSR_BYTE_SWAP; | | 330 | val &= ~XCTL_SHIM_CFG_CSR_BYTE_SWAP; |
332 | val &= ~XCTL_SHIM_CFG_DMA_BYTE_SWAP; | | 331 | val &= ~XCTL_SHIM_CFG_DMA_BYTE_SWAP; |
333 | val |= 3ull << XCTL_SHIM_CFG_CSR_BYTE_SWAP_SHIFT; | | 332 | val |= __SHIFTIN(XCTL_SHIM_ENDIAN_BIG, XCTL_SHIM_CFG_DMA_BYTE_SWAP); |
334 | val |= 1ull << XCTL_SHIM_CFG_DMA_BYTE_SWAP_SHIFT; | | 333 | val |= __SHIFTIN(XCTL_SHIM_ENDIAN_BIG, XCTL_SHIM_CFG_CSR_BYTE_SWAP); |
335 | XCTL_WR_8(sc, XCTL_SHIM_CFG, val); | | 334 | XCTL_WR_8(sc, XCTL_SHIM_CFG, val); |
336 | (void)XCTL_RD_8(sc, XCTL_SHIM_CFG); | | 335 | (void)XCTL_RD_8(sc, XCTL_SHIM_CFG); |
337 | } | | 336 | } |
338 | | | 337 | |
339 | int | | 338 | int |
340 | octxhci_dwc3_init(struct xhci_softc *sc) | | 339 | octxhci_dwc3_init(struct xhci_softc *sc) |
341 | { | | 340 | { |
342 | bus_space_handle_t ioh = sc->sc_ioh; | | 341 | bus_space_handle_t ioh = sc->sc_ioh; |
343 | uint32_t rev; | | 342 | uint32_t rev; |
344 | uint32_t val; | | 343 | uint32_t val; |
345 | | | 344 | |
346 | val = bus_space_read_4(sc->sc_iot, ioh, DWC3_GSNPSID); | | 345 | val = bus_space_read_4(sc->sc_iot, ioh, DWC3_GSNPSID); |
347 | if ((val & 0xffff0000u) != 0x55330000u) { | | 346 | if ((val & 0xffff0000u) != 0x55330000u) { |