]> git.ipfire.org Git - people/ms/u-boot.git/blame - drivers/usb/host/ehci-sunxi.c
sunxi: Move usb-controller init code out of ehci-sunxi.c for reuse for otg
[people/ms/u-boot.git] / drivers / usb / host / ehci-sunxi.c
CommitLineData
8d154002
RB
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
0eccec4e 12#include <asm/arch/usbc.h>
8d154002
RB
13#include <common.h>
14#include "ehci.h"
15
8d154002
RB
16int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
17 struct ehci_hcor **hcor)
18{
44fd5914 19 int err;
8d154002 20
0eccec4e
HG
21 err = sunxi_usbc_request_resources(index + 1);
22 if (err)
23 return err;
115200ce 24
0eccec4e
HG
25 sunxi_usbc_enable(index + 1);
26 sunxi_usbc_vbus_enable(index + 1);
8d154002 27
0eccec4e 28 *hccr = sunxi_usbc_get_io_base(index + 1);
8d154002
RB
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
8d154002
RB
37 return 0;
38}
39
40int ehci_hcd_stop(int index)
41{
0eccec4e
HG
42 sunxi_usbc_vbus_disable(index + 1);
43 sunxi_usbc_disable(index + 1);
44fd5914 44
0eccec4e 45 return sunxi_usbc_free_resources(index + 1);
8d154002 46}