]> git.sur5r.net Git - u-boot/blob - drivers/usb/host/ehci-uniphier.c
ARM: UniPhier: remove EHCI platform devices
[u-boot] / drivers / usb / host / ehci-uniphier.c
1 /*
2  * Copyright (C) 2014 Panasonic Corporation
3  *   Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <linux/err.h>
10 #include <usb.h>
11 #include <mach/ehci-uniphier.h>
12 #include <fdtdec.h>
13 #include "ehci.h"
14
15 DECLARE_GLOBAL_DATA_PTR;
16
17 #define FDT             gd->fdt_blob
18 #define COMPAT          "panasonic,uniphier-ehci"
19
20 static int get_uniphier_ehci_base(int index, struct ehci_hccr **base)
21 {
22         int offset;
23
24         for (offset = fdt_node_offset_by_compatible(FDT, 0, COMPAT);
25              offset >= 0;
26              offset = fdt_node_offset_by_compatible(FDT, offset, COMPAT)) {
27                 if (index == 0) {
28                         *base = (struct ehci_hccr *)
29                                         fdtdec_get_addr(FDT, offset, "reg");
30                         return 0;
31                 }
32                 index--;
33         }
34
35         return -ENODEV; /* not found */
36 }
37
38 int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
39                   struct ehci_hcor **hcor)
40 {
41         int ret;
42         struct ehci_hccr *cr;
43         struct ehci_hcor *or;
44
45         uniphier_ehci_reset(index, 0);
46
47         ret = get_uniphier_ehci_base(index, &cr);
48         if (ret < 0)
49                 return ret;
50         or = (void *)cr + HC_LENGTH(ehci_readl(&cr->cr_capbase));
51
52         *hccr = cr;
53         *hcor = or;
54
55         return 0;
56 }
57
58 int ehci_hcd_stop(int index)
59 {
60         uniphier_ehci_reset(index, 1);
61
62         return 0;
63 }