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 <dm/devres.h> 13 #include <linux/compat.h> 14 #include <usb.h> 15 #include <usb/xhci.h> 16 17 #include "core.h" 18 #include "drd.h" 19 __cdns3_host_init(struct cdns3 * cdns)20static int __cdns3_host_init(struct cdns3 *cdns) 21 { 22 struct xhci_hcor *hcor; 23 struct xhci_hccr *hccr; 24 25 cdns3_drd_switch_host(cdns, 1); 26 27 hccr = (struct xhci_hccr *)cdns->xhci_regs; 28 hcor = (struct xhci_hcor *)(cdns->xhci_regs + 29 HC_LENGTH(xhci_readl(&(hccr)->cr_capbase))); 30 31 return xhci_register(cdns->dev, hccr, hcor); 32 } 33 cdns3_host_exit(struct cdns3 * cdns)34static void cdns3_host_exit(struct cdns3 *cdns) 35 { 36 xhci_deregister(cdns->dev); 37 cdns3_drd_switch_host(cdns, 0); 38 } 39 cdns3_host_init(struct cdns3 * cdns)40int cdns3_host_init(struct cdns3 *cdns) 41 { 42 struct cdns3_role_driver *rdrv; 43 44 rdrv = devm_kzalloc(cdns->dev, sizeof(*rdrv), GFP_KERNEL); 45 if (!rdrv) 46 return -ENOMEM; 47 48 rdrv->start = __cdns3_host_init; 49 rdrv->stop = cdns3_host_exit; 50 rdrv->state = CDNS3_ROLE_STATE_INACTIVE; 51 rdrv->name = "host"; 52 53 cdns->roles[USB_ROLE_HOST] = rdrv; 54 55 return 0; 56 } 57