drivers/usb/cdns3/host.c
Source file repositories/reference/linux-study-clean/drivers/usb/cdns3/host.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/cdns3/host.c- Extension
.c- Size
- 3989 bytes
- Lines
- 169
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/platform_device.hlinux/slab.hcore.hdrd.hhost-export.hlinux/usb/hcd.h../host/xhci.h../host/xhci-plat.h
Detected Declarations
function Copyrightfunction xhci_cdns3_resume_quirkfunction __cdns_host_initfunction cdns_host_exitfunction cdns_host_resumefunction cdns_host_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Cadence USBSS and USBSSP DRD Driver - host side
*
* Copyright (C) 2018-2019 Cadence Design Systems.
* Copyright (C) 2017-2018 NXP
*
* Authors: Peter Chen <peter.chen@nxp.com>
* Pawel Laszczak <pawell@cadence.com>
*/
#include <linux/platform_device.h>
#include <linux/slab.h>
#include "core.h"
#include "drd.h"
#include "host-export.h"
#include <linux/usb/hcd.h>
#include "../host/xhci.h"
#include "../host/xhci-plat.h"
/*
* The XECP_PORT_CAP_REG and XECP_AUX_CTRL_REG1 exist only
* in Cadence USB3 dual-role controller, so it can't be used
* with Cadence CDNSP dual-role controller.
*/
#define XECP_PORT_CAP_REG 0x8000
#define XECP_AUX_CTRL_REG1 0x8120
#define CFG_RXDET_P3_EN BIT(15)
#define LPM_2_STB_SWITCH_EN BIT(25)
static void xhci_cdns3_plat_start(struct usb_hcd *hcd)
{
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
u32 value;
/* set usbcmd.EU3S */
value = readl(&xhci->op_regs->command);
value |= CMD_PM_INDEX;
writel(value, &xhci->op_regs->command);
if (hcd->regs) {
value = readl(hcd->regs + XECP_AUX_CTRL_REG1);
value |= CFG_RXDET_P3_EN;
writel(value, hcd->regs + XECP_AUX_CTRL_REG1);
value = readl(hcd->regs + XECP_PORT_CAP_REG);
value |= LPM_2_STB_SWITCH_EN;
writel(value, hcd->regs + XECP_PORT_CAP_REG);
}
}
static int xhci_cdns3_resume_quirk(struct usb_hcd *hcd)
{
xhci_cdns3_plat_start(hcd);
return 0;
}
static const struct xhci_plat_priv xhci_plat_cdns3_xhci = {
.quirks = XHCI_SKIP_PHY_INIT | XHCI_AVOID_BEI,
.plat_start = xhci_cdns3_plat_start,
.resume_quirk = xhci_cdns3_resume_quirk,
};
static const struct xhci_plat_priv xhci_plat_cdnsp_xhci = {
.quirks = XHCI_CDNS_SCTX_QUIRK,
};
static int __cdns_host_init(struct cdns *cdns)
{
struct platform_device *xhci;
int ret;
struct usb_hcd *hcd;
cdns_drd_host_on(cdns);
xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
if (!xhci) {
dev_err(cdns->dev, "couldn't allocate xHCI device\n");
return -ENOMEM;
}
xhci->dev.parent = cdns->dev;
cdns->host_dev = xhci;
ret = platform_device_add_resources(xhci, cdns->xhci_res,
CDNS_XHCI_RESOURCES_NUM);
if (ret) {
dev_err(cdns->dev, "couldn't add resources to xHCI device\n");
goto err1;
Annotation
- Immediate include surface: `linux/platform_device.h`, `linux/slab.h`, `core.h`, `drd.h`, `host-export.h`, `linux/usb/hcd.h`, `../host/xhci.h`, `../host/xhci-plat.h`.
- Detected declarations: `function Copyright`, `function xhci_cdns3_resume_quirk`, `function __cdns_host_init`, `function cdns_host_exit`, `function cdns_host_resume`, `function cdns_host_init`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.