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