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 <dm/devres.h>
13 #include <linux/compat.h>
20 static int __cdns3_host_init(struct cdns3 *cdns)
22 struct xhci_hcor *hcor;
23 struct xhci_hccr *hccr;
25 cdns3_drd_switch_host(cdns, 1);
27 hccr = (struct xhci_hccr *)cdns->xhci_regs;
28 hcor = (struct xhci_hcor *)(cdns->xhci_regs +
29 HC_LENGTH(xhci_readl(&(hccr)->cr_capbase)));
31 return xhci_register(cdns->dev, hccr, hcor);
34 static void cdns3_host_exit(struct cdns3 *cdns)
36 xhci_deregister(cdns->dev);
37 cdns3_drd_switch_host(cdns, 0);
40 int cdns3_host_init(struct cdns3 *cdns)
42 struct cdns3_role_driver *rdrv;
44 rdrv = devm_kzalloc(cdns->dev, sizeof(*rdrv), GFP_KERNEL);
48 rdrv->start = __cdns3_host_init;
49 rdrv->stop = cdns3_host_exit;
50 rdrv->state = CDNS3_ROLE_STATE_INACTIVE;
53 cdns->roles[USB_ROLE_HOST] = rdrv;