1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Cadence USBSS DRD Driver - host side 4 * 5 * Copyright (C) 2018-2019 Cadence Design Systems. 6 * Copyright (C) 2017-2018 NXP 7 * 8 * Authors: Peter Chen <peter.chen@nxp.com> 9 * Pawel Laszczak <pawell@cadence.com> 10 */ 11 #include <dm.h> 12 #include <linux/compat.h> 13 #include <usb.h> 14 #include <usb/xhci.h> 15 16 #include "core.h" 17 #include "drd.h" 18 __cdns3_host_init(struct cdns3 * cdns)19static int __cdns3_host_init(struct cdns3 *cdns) 20 { 21 struct xhci_hcor *hcor; 22 struct xhci_hccr *hccr; 23 24 cdns3_drd_switch_host(cdns, 1); 25 26 hccr = (struct xhci_hccr *)cdns->xhci_regs; 27 hcor = (struct xhci_hcor *)(cdns->xhci_regs + 28 HC_LENGTH(xhci_readl(&(hccr)->cr_capbase))); 29 30 return xhci_register(cdns->dev, hccr, hcor); 31 } 32 cdns3_host_exit(struct cdns3 * cdns)33static void cdns3_host_exit(struct cdns3 *cdns) 34 { 35 xhci_deregister(cdns->dev); 36 cdns3_drd_switch_host(cdns, 0); 37 } 38 cdns3_host_init(struct cdns3 * cdns)39int cdns3_host_init(struct cdns3 *cdns) 40 { 41 struct cdns3_role_driver *rdrv; 42 43 rdrv = devm_kzalloc(cdns->dev, sizeof(*rdrv), GFP_KERNEL); 44 if (!rdrv) 45 return -ENOMEM; 46 47 rdrv->start = __cdns3_host_init; 48 rdrv->stop = cdns3_host_exit; 49 rdrv->state = CDNS3_ROLE_STATE_INACTIVE; 50 rdrv->name = "host"; 51 52 cdns->roles[USB_ROLE_HOST] = rdrv; 53 54 return 0; 55 } 56