| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
27 | * POSSIBILITY OF SUCH DAMAGE. | | 27 | * POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | #define USBH_PRIVATE | | 29 | #define USBH_PRIVATE |
30 | | | 30 | |
31 | #include "locators.h" | | 31 | #include "locators.h" |
32 | #include "ohci.h" | | 32 | #include "ohci.h" |
33 | #include "ehci.h" | | 33 | #include "ehci.h" |
34 | | | 34 | |
35 | #include <sys/cdefs.h> | | 35 | #include <sys/cdefs.h> |
36 | | | 36 | |
37 | __KERNEL_RCSID(1, "$NetBSD: awin_usb.c,v 1.12 2014/06/24 05:07:31 skrll Exp $"); | | 37 | __KERNEL_RCSID(1, "$NetBSD: awin_usb.c,v 1.13 2014/09/13 17:48:00 jmcneill Exp $"); |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/bus.h> | | 40 | #include <sys/bus.h> |
41 | #include <sys/device.h> | | 41 | #include <sys/device.h> |
42 | #include <sys/intr.h> | | 42 | #include <sys/intr.h> |
43 | #include <sys/systm.h> | | 43 | #include <sys/systm.h> |
44 | | | 44 | |
45 | #include <arm/allwinner/awin_reg.h> | | 45 | #include <arm/allwinner/awin_reg.h> |
46 | #include <arm/allwinner/awin_var.h> | | 46 | #include <arm/allwinner/awin_var.h> |
47 | | | 47 | |
48 | #include <dev/usb/usb.h> | | 48 | #include <dev/usb/usb.h> |
49 | #include <dev/usb/usbdi.h> | | 49 | #include <dev/usb/usbdi.h> |
50 | #include <dev/usb/usbdivar.h> | | 50 | #include <dev/usb/usbdivar.h> |
| @@ -226,53 +226,53 @@ ehci_awinusb_attach(device_t parent, dev | | | @@ -226,53 +226,53 @@ ehci_awinusb_attach(device_t parent, dev |
226 | irq); | | 226 | irq); |
227 | return; | | 227 | return; |
228 | } | | 228 | } |
229 | aprint_normal_dev(self, "interrupting on irq %d\n", irq); | | 229 | aprint_normal_dev(self, "interrupting on irq %d\n", irq); |
230 | } | | 230 | } |
231 | #endif /* NEHCI > 0 */ | | 231 | #endif /* NEHCI > 0 */ |
232 | | | 232 | |
233 | static void | | 233 | static void |
234 | awin_usb_phy_write(struct awinusb_softc *usbsc, u_int bit_addr, u_int bits, | | 234 | awin_usb_phy_write(struct awinusb_softc *usbsc, u_int bit_addr, u_int bits, |
235 | u_int len) | | 235 | u_int len) |
236 | { | | 236 | { |
237 | bus_space_tag_t bst = usbsc->usbsc_bst; | | 237 | bus_space_tag_t bst = usbsc->usbsc_bst; |
238 | bus_space_handle_t bsh = usbsc->usbsc_usb0_phy_csr_bsh; | | 238 | bus_space_handle_t bsh = usbsc->usbsc_usb0_phy_csr_bsh; |
239 | uint32_t clk = AWIN_USB0_PHY_CSR_CLK0 << usbsc->usbsc_number; | | 239 | uint32_t clk = AWIN_USB0_PHY_CTL_CLK0 << usbsc->usbsc_number; |
240 | | | 240 | |
241 | uint32_t v = bus_space_read_4(bst, bsh, 0); | | 241 | uint32_t v = bus_space_read_4(bst, bsh, 0); |
242 | | | 242 | |
243 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK0) == 0); | | 243 | KASSERT((v & AWIN_USB0_PHY_CTL_CLK0) == 0); |
244 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK1) == 0); | | 244 | KASSERT((v & AWIN_USB0_PHY_CTL_CLK1) == 0); |
245 | KASSERT((v & AWIN_USB0_PHY_CSR_CLK2) == 0); | | 245 | KASSERT((v & AWIN_USB0_PHY_CTL_CLK2) == 0); |
246 | | | 246 | |
247 | v &= ~AWIN_USB0_PHY_CSR_ADDR; | | 247 | v &= ~AWIN_USB0_PHY_CTL_ADDR; |
248 | v &= ~AWIN_USB0_PHY_CSR_DAT; | | 248 | v &= ~AWIN_USB0_PHY_CTL_DAT; |
249 | | | 249 | |
250 | v |= __SHIFTIN(bit_addr, AWIN_USB0_PHY_CSR_ADDR); | | 250 | v |= __SHIFTIN(bit_addr, AWIN_USB0_PHY_CTL_ADDR); |
251 | | | 251 | |
252 | /* | | 252 | /* |
253 | * Bitbang the data to the phy, bit by bit, incrementing bit address | | 253 | * Bitbang the data to the phy, bit by bit, incrementing bit address |
254 | * as we go. | | 254 | * as we go. |
255 | */ | | 255 | */ |
256 | for (; len > 0; bit_addr++, bits >>= 1, len--) { | | 256 | for (; len > 0; bit_addr++, bits >>= 1, len--) { |
257 | v |= __SHIFTIN(bits & 1, AWIN_USB0_PHY_CSR_DAT); | | 257 | v |= __SHIFTIN(bits & 1, AWIN_USB0_PHY_CTL_DAT); |
258 | bus_space_write_4(bst, bsh, 0, v); | | 258 | bus_space_write_4(bst, bsh, 0, v); |
259 | delay(1); | | 259 | delay(1); |
260 | bus_space_write_4(bst, bsh, 0, v | clk); | | 260 | bus_space_write_4(bst, bsh, 0, v | clk); |
261 | delay(1); | | 261 | delay(1); |
262 | bus_space_write_4(bst, bsh, 0, v); | | 262 | bus_space_write_4(bst, bsh, 0, v); |
263 | delay(1); | | 263 | delay(1); |
264 | v += __LOWEST_SET_BIT(AWIN_USB0_PHY_CSR_ADDR); | | 264 | v += __LOWEST_SET_BIT(AWIN_USB0_PHY_CTL_ADDR); |
265 | v &= ~AWIN_USB0_PHY_CSR_DAT; | | 265 | v &= ~AWIN_USB0_PHY_CTL_DAT; |
266 | } | | 266 | } |
267 | } | | 267 | } |
268 | | | 268 | |
269 | static int awinusb_match(device_t, cfdata_t, void *); | | 269 | static int awinusb_match(device_t, cfdata_t, void *); |
270 | static void awinusb_attach(device_t, device_t, void *); | | 270 | static void awinusb_attach(device_t, device_t, void *); |
271 | | | 271 | |
272 | CFATTACH_DECL_NEW(awin_usb, sizeof(struct awinusb_softc), | | 272 | CFATTACH_DECL_NEW(awin_usb, sizeof(struct awinusb_softc), |
273 | awinusb_match, awinusb_attach, NULL, NULL); | | 273 | awinusb_match, awinusb_attach, NULL, NULL); |
274 | | | 274 | |
275 | static int awinusb_ports; | | 275 | static int awinusb_ports; |
276 | | | 276 | |
277 | static const char awinusb_drvpin_names[2][8] = { "usb1drv", "usb2drv" }; | | 277 | static const char awinusb_drvpin_names[2][8] = { "usb1drv", "usb2drv" }; |
278 | static const bus_size_t awinusb_dram_hpcr_regs[2] = { | | 278 | static const bus_size_t awinusb_dram_hpcr_regs[2] = { |
| @@ -325,27 +325,27 @@ awinusb_attach(device_t parent, device_t | | | @@ -325,27 +325,27 @@ awinusb_attach(device_t parent, device_t |
325 | awinusb_ports |= __BIT(loc->loc_port); | | 325 | awinusb_ports |= __BIT(loc->loc_port); |
326 | | | 326 | |
327 | usbsc->usbsc_bst = aio->aio_core_bst; | | 327 | usbsc->usbsc_bst = aio->aio_core_bst; |
328 | usbsc->usbsc_dmat = aio->aio_dmat; | | 328 | usbsc->usbsc_dmat = aio->aio_dmat; |
329 | usbsc->usbsc_number = loc->loc_port + 1; | | 329 | usbsc->usbsc_number = loc->loc_port + 1; |
330 | | | 330 | |
331 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | | 331 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, |
332 | loc->loc_offset + AWIN_EHCI_OFFSET, AWIN_EHCI_SIZE, | | 332 | loc->loc_offset + AWIN_EHCI_OFFSET, AWIN_EHCI_SIZE, |
333 | &usbsc->usbsc_ehci_bsh); | | 333 | &usbsc->usbsc_ehci_bsh); |
334 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | | 334 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, |
335 | loc->loc_offset + AWIN_OHCI_OFFSET, AWIN_OHCI_SIZE, | | 335 | loc->loc_offset + AWIN_OHCI_OFFSET, AWIN_OHCI_SIZE, |
336 | &usbsc->usbsc_ohci_bsh); | | 336 | &usbsc->usbsc_ohci_bsh); |
337 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, | | 337 | bus_space_subregion(usbsc->usbsc_bst, aio->aio_core_bsh, |
338 | AWIN_USB0_OFFSET + AWIN_USB0_PHY_CSR_REG, 4, | | 338 | AWIN_USB0_OFFSET + AWIN_USB0_PHY_CTL_REG, 4, |
339 | &usbsc->usbsc_usb0_phy_csr_bsh); | | 339 | &usbsc->usbsc_usb0_phy_csr_bsh); |
340 | | | 340 | |
341 | aprint_naive("\n"); | | 341 | aprint_naive("\n"); |
342 | aprint_normal("\n"); | | 342 | aprint_normal("\n"); |
343 | | | 343 | |
344 | /* | | 344 | /* |
345 | * Access to the USB phy is off USB0 so make sure it's on. | | 345 | * Access to the USB phy is off USB0 so make sure it's on. |
346 | */ | | 346 | */ |
347 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_ccm_bsh, | | 347 | awin_reg_set_clear(usbsc->usbsc_bst, aio->aio_ccm_bsh, |
348 | AWIN_AHB_GATING0_REG, | | 348 | AWIN_AHB_GATING0_REG, |
349 | AWIN_AHB_GATING0_USB0 | awinusb_ahb_gating[loc->loc_port], 0); | | 349 | AWIN_AHB_GATING0_USB0 | awinusb_ahb_gating[loc->loc_port], 0); |
350 | | | 350 | |
351 | | | 351 | |