blob: 68959efb20eb24f51a9d2dd92953ff3d478477b1 [file] [log] [blame]
Masahiro Yamada048899b2014-11-07 18:48:33 +09001/*
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>
Masahiro Yamada149c7512014-11-26 18:34:01 +09009#include <linux/err.h>
Masahiro Yamada048899b2014-11-07 18:48:33 +090010#include <usb.h>
Masahiro Yamadaa86ac952015-02-27 02:26:44 +090011#include <mach/ehci-uniphier.h>
Masahiro Yamada44f597a2015-02-27 02:26:54 +090012#include <fdtdec.h>
Masahiro Yamada048899b2014-11-07 18:48:33 +090013#include "ehci.h"
14
Masahiro Yamada149c7512014-11-26 18:34:01 +090015DECLARE_GLOBAL_DATA_PTR;
16
17#define FDT gd->fdt_blob
18#define COMPAT "panasonic,uniphier-ehci"
19
20static 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}
Masahiro Yamada149c7512014-11-26 18:34:01 +090037
Masahiro Yamada048899b2014-11-07 18:48:33 +090038int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
39 struct ehci_hcor **hcor)
40{
Masahiro Yamada149c7512014-11-26 18:34:01 +090041 int ret;
Masahiro Yamada048899b2014-11-07 18:48:33 +090042 struct ehci_hccr *cr;
43 struct ehci_hcor *or;
44
45 uniphier_ehci_reset(index, 0);
46
Masahiro Yamada149c7512014-11-26 18:34:01 +090047 ret = get_uniphier_ehci_base(index, &cr);
48 if (ret < 0)
49 return ret;
Masahiro Yamada048899b2014-11-07 18:48:33 +090050 or = (void *)cr + HC_LENGTH(ehci_readl(&cr->cr_capbase));
51
52 *hccr = cr;
53 *hcor = or;
54
55 return 0;
56}
57
58int ehci_hcd_stop(int index)
59{
60 uniphier_ehci_reset(index, 1);
61
62 return 0;
63}