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>
16 static int __cdns3_host_init(struct cdns3 *cdns)
18 struct platform_device *xhci;
21 cdns3_drd_switch_host(cdns, 1);
23 xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
25 dev_err(cdns->dev, "couldn't allocate xHCI device\n");
29 xhci->dev.parent = cdns->dev;
30 cdns->host_dev = xhci;
32 ret = platform_device_add_resources(xhci, cdns->xhci_res,
33 CDNS3_XHCI_RESOURCES_NUM);
35 dev_err(cdns->dev, "couldn't add resources to xHCI device\n");
39 ret = platform_device_add(xhci);
41 dev_err(cdns->dev, "failed to register xHCI device\n");
47 platform_device_put(xhci);
51 static void cdns3_host_exit(struct cdns3 *cdns)
53 platform_device_unregister(cdns->host_dev);
54 cdns->host_dev = NULL;
55 cdns3_drd_switch_host(cdns, 0);
58 int cdns3_host_init(struct cdns3 *cdns)
60 struct cdns3_role_driver *rdrv;
62 rdrv = devm_kzalloc(cdns->dev, sizeof(*rdrv), GFP_KERNEL);
66 rdrv->start = __cdns3_host_init;
67 rdrv->stop = cdns3_host_exit;
68 rdrv->state = CDNS3_ROLE_STATE_INACTIVE;
71 cdns->roles[USB_ROLE_HOST] = rdrv;