1 /* 2 * Copyright (C) 2014 Roman Byshko 3 * 4 * Roman Byshko <rbyshko@gmail.com> 5 * 6 * Based on code from 7 * Allwinner Technology Co., Ltd. <www.allwinnertech.com> 8 * 9 * SPDX-License-Identifier: GPL-2.0+ 10 */ 11 12 #include <asm/arch/usbc.h> 13 #include <common.h> 14 #include "ehci.h" 15 16 int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr, 17 struct ehci_hcor **hcor) 18 { 19 int err; 20 21 err = sunxi_usbc_request_resources(index + 1); 22 if (err) 23 return err; 24 25 sunxi_usbc_enable(index + 1); 26 sunxi_usbc_vbus_enable(index + 1); 27 28 *hccr = sunxi_usbc_get_io_base(index + 1); 29 30 *hcor = (struct ehci_hcor *)((uint32_t) *hccr 31 + HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); 32 33 debug("sunxi-ehci: init hccr %x and hcor %x hc_length %d\n", 34 (uint32_t)*hccr, (uint32_t)*hcor, 35 (uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase))); 36 37 return 0; 38 } 39 40 int ehci_hcd_stop(int index) 41 { 42 sunxi_usbc_vbus_disable(index + 1); 43 sunxi_usbc_disable(index + 1); 44 45 return sunxi_usbc_free_resources(index + 1); 46 } 47