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/platform_device.h>
15 #include "host-export.h"
17 static int __cdns3_host_init(struct cdns3
*cdns
)
19 struct platform_device
*xhci
;
22 cdns3_drd_switch_host(cdns
, 1);
24 xhci
= platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO
);
26 dev_err(cdns
->dev
, "couldn't allocate xHCI device\n");
30 xhci
->dev
.parent
= cdns
->dev
;
31 cdns
->host_dev
= xhci
;
33 ret
= platform_device_add_resources(xhci
, cdns
->xhci_res
,
34 CDNS3_XHCI_RESOURCES_NUM
);
36 dev_err(cdns
->dev
, "couldn't add resources to xHCI device\n");
40 ret
= platform_device_add(xhci
);
42 dev_err(cdns
->dev
, "failed to register xHCI device\n");
48 platform_device_put(xhci
);
52 static void cdns3_host_exit(struct cdns3
*cdns
)
54 platform_device_unregister(cdns
->host_dev
);
55 cdns
->host_dev
= NULL
;
56 cdns3_drd_switch_host(cdns
, 0);
59 int cdns3_host_init(struct cdns3
*cdns
)
61 struct cdns3_role_driver
*rdrv
;
63 rdrv
= devm_kzalloc(cdns
->dev
, sizeof(*rdrv
), GFP_KERNEL
);
67 rdrv
->start
= __cdns3_host_init
;
68 rdrv
->stop
= cdns3_host_exit
;
69 rdrv
->state
= CDNS3_ROLE_STATE_INACTIVE
;
72 cdns
->roles
[USB_ROLE_HOST
] = rdrv
;