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
12 #include <linux/platform_device.h>
15 #include "host-export.h"
16 #include <linux/usb/hcd.h>
18 static int __cdns3_host_init(struct cdns3 *cdns)
20 struct platform_device *xhci;
24 cdns3_drd_host_on(cdns);
26 xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
28 dev_err(cdns->dev, "couldn't allocate xHCI device\n");
32 xhci->dev.parent = cdns->dev;
33 cdns->host_dev = xhci;
35 ret = platform_device_add_resources(xhci, cdns->xhci_res,
36 CDNS3_XHCI_RESOURCES_NUM);
38 dev_err(cdns->dev, "couldn't add resources to xHCI device\n");
42 ret = platform_device_add(xhci);
44 dev_err(cdns->dev, "failed to register xHCI device\n");
48 /* Glue needs to access xHCI region register for Power management */
49 hcd = platform_get_drvdata(xhci);
51 cdns->xhci_regs = hcd->regs;
55 platform_device_put(xhci);
59 static void cdns3_host_exit(struct cdns3 *cdns)
61 platform_device_unregister(cdns->host_dev);
62 cdns->host_dev = NULL;
63 cdns3_drd_host_off(cdns);
66 int cdns3_host_init(struct cdns3 *cdns)
68 struct cdns3_role_driver *rdrv;
70 rdrv = devm_kzalloc(cdns->dev, sizeof(*rdrv), GFP_KERNEL);
74 rdrv->start = __cdns3_host_init;
75 rdrv->stop = cdns3_host_exit;
76 rdrv->state = CDNS3_ROLE_STATE_INACTIVE;
79 cdns->roles[USB_ROLE_HOST] = rdrv;