blob: 425d9d053ddbfdd1bf168fcef0eebee5d7bdf870 [file] [log] [blame]
Vignesh Raghavendra7e91f6c2019-10-01 17:26:33 +05301// SPDX-License-Identifier: GPL-2.0
2/*
3 * Cadence USBSS DRD Driver - host side
4 *
5 * Copyright (C) 2018-2019 Cadence Design Systems.
6 * Copyright (C) 2017-2018 NXP
7 *
8 * Authors: Peter Chen <peter.chen@nxp.com>
9 * Pawel Laszczak <pawell@cadence.com>
10 */
11#include <dm.h>
12#include <linux/compat.h>
13#include <usb.h>
Vignesh Raghavendrae5521b12019-11-18 19:16:33 +053014#include <usb/xhci.h>
Vignesh Raghavendra7e91f6c2019-10-01 17:26:33 +053015
16#include "core.h"
17#include "drd.h"
18
19static int __cdns3_host_init(struct cdns3 *cdns)
20{
21 struct xhci_hcor *hcor;
22 struct xhci_hccr *hccr;
23
24 cdns3_drd_switch_host(cdns, 1);
25
26 hccr = (struct xhci_hccr *)cdns->xhci_regs;
27 hcor = (struct xhci_hcor *)(cdns->xhci_regs +
28 HC_LENGTH(xhci_readl(&(hccr)->cr_capbase)));
29
30 return xhci_register(cdns->dev, hccr, hcor);
31}
32
33static void cdns3_host_exit(struct cdns3 *cdns)
34{
35 xhci_deregister(cdns->dev);
36 cdns3_drd_switch_host(cdns, 0);
37}
38
39int cdns3_host_init(struct cdns3 *cdns)
40{
41 struct cdns3_role_driver *rdrv;
42
43 rdrv = devm_kzalloc(cdns->dev, sizeof(*rdrv), GFP_KERNEL);
44 if (!rdrv)
45 return -ENOMEM;
46
47 rdrv->start = __cdns3_host_init;
48 rdrv->stop = cdns3_host_exit;
49 rdrv->state = CDNS3_ROLE_STATE_INACTIVE;
50 rdrv->name = "host";
51
52 cdns->roles[USB_ROLE_HOST] = rdrv;
53
54 return 0;
55}