2014-07-27 17:32:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Roman Byshko
|
|
|
|
*
|
|
|
|
* Roman Byshko <rbyshko@gmail.com>
|
|
|
|
*
|
|
|
|
* Based on code from
|
|
|
|
* Allwinner Technology Co., Ltd. <www.allwinnertech.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
|
|
*/
|
|
|
|
|
2015-01-07 14:08:43 +00:00
|
|
|
#include <asm/arch/usbc.h>
|
2014-07-27 17:32:44 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include "ehci.h"
|
|
|
|
|
|
|
|
int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
|
|
|
|
struct ehci_hcor **hcor)
|
|
|
|
{
|
2014-10-31 16:04:52 +00:00
|
|
|
int err;
|
2014-07-27 17:32:44 +00:00
|
|
|
|
2015-01-07 14:08:43 +00:00
|
|
|
err = sunxi_usbc_request_resources(index + 1);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2014-11-07 15:09:00 +00:00
|
|
|
|
2015-01-07 14:08:43 +00:00
|
|
|
sunxi_usbc_enable(index + 1);
|
|
|
|
sunxi_usbc_vbus_enable(index + 1);
|
2014-07-27 17:32:44 +00:00
|
|
|
|
2015-01-07 14:08:43 +00:00
|
|
|
*hccr = sunxi_usbc_get_io_base(index + 1);
|
2014-07-27 17:32:44 +00:00
|
|
|
|
|
|
|
*hcor = (struct ehci_hcor *)((uint32_t) *hccr
|
|
|
|
+ HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
|
|
|
|
|
|
|
|
debug("sunxi-ehci: init hccr %x and hcor %x hc_length %d\n",
|
|
|
|
(uint32_t)*hccr, (uint32_t)*hcor,
|
|
|
|
(uint32_t)HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ehci_hcd_stop(int index)
|
|
|
|
{
|
2015-01-07 14:08:43 +00:00
|
|
|
sunxi_usbc_vbus_disable(index + 1);
|
|
|
|
sunxi_usbc_disable(index + 1);
|
2014-10-31 16:04:52 +00:00
|
|
|
|
2015-01-07 14:08:43 +00:00
|
|
|
return sunxi_usbc_free_resources(index + 1);
|
2014-07-27 17:32:44 +00:00
|
|
|
}
|