1 // SPDX-License-Identifier: GPL-2.0
3 * Cadence USBSS DRD Driver - host side
5 * Copyright (C) 2018-2019 Cadence Design Systems.
6 * Copyright (C) 2017-2018 NXP
8 * Authors: Peter Chen <peter.chen@nxp.com>
9 * Pawel Laszczak <pawell@cadence.com>
12 #include <linux/compat.h>
19 static int __cdns3_host_init(struct cdns3 *cdns)
21 struct xhci_hcor *hcor;
22 struct xhci_hccr *hccr;
24 cdns3_drd_switch_host(cdns, 1);
26 hccr = (struct xhci_hccr *)cdns->xhci_regs;
27 hcor = (struct xhci_hcor *)(cdns->xhci_regs +
28 HC_LENGTH(xhci_readl(&(hccr)->cr_capbase)));
30 return xhci_register(cdns->dev, hccr, hcor);
33 static void cdns3_host_exit(struct cdns3 *cdns)
35 xhci_deregister(cdns->dev);
36 cdns3_drd_switch_host(cdns, 0);
39 int cdns3_host_init(struct cdns3 *cdns)
41 struct cdns3_role_driver *rdrv;
43 rdrv = devm_kzalloc(cdns->dev, sizeof(*rdrv), GFP_KERNEL);
47 rdrv->start = __cdns3_host_init;
48 rdrv->stop = cdns3_host_exit;
49 rdrv->state = CDNS3_ROLE_STATE_INACTIVE;
52 cdns->roles[USB_ROLE_HOST] = rdrv;