iPXE
dwusb.c File Reference

Synopsys DesignWare USB3 host controller driver. More...

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ipxe/timer.h>
#include <ipxe/devtree.h>
#include <ipxe/fdt.h>
#include "dwusb.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int dwusb_probe (struct dt_device *dt, unsigned int offset)
 Probe devicetree device.
static void dwusb_remove (struct dt_device *dt)
 Remove devicetree device.

Variables

static const char * dwusb_ids []
 DesignWare USB3 compatible model identifiers.
struct dt_driver dwusb_driver __dt_driver
 DesignWare USB3 devicetree driver.

Detailed Description

Synopsys DesignWare USB3 host controller driver.

Definition in file dwusb.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ dwusb_probe()

int dwusb_probe ( struct dt_device * dt,
unsigned int offset )
static

Probe devicetree device.

Parameters
dtDevicetree device
offsetStarting node offset
Return values
rcReturn status code

Definition at line 47 of file dwusb.c.

47 {
48 struct xhci_device *xhci;
49 uint32_t gctl;
50 int rc;
51
52 /* Allocate and initialise structure */
53 xhci = zalloc ( sizeof ( *xhci ) );
54 if ( ! xhci ) {
55 rc = -ENOMEM;
56 goto err_alloc;
57 }
58 xhci->dev = &dt->dev;
59 xhci->dma = &dt->dma;
60
61 /* Map registers */
62 xhci->regs = dt_ioremap ( dt, offset, 0, 0 );
63 if ( ! xhci->regs ) {
64 rc = -ENODEV;
65 goto err_ioremap;
66 }
67
68 /* Reset via global core control register */
69 gctl = readl ( xhci->regs + DWUSB_GCTL );
70 writel ( ( gctl | DWUSB_GCTL_RESET ), ( xhci->regs + DWUSB_GCTL ) );
71 mdelay ( 100 );
72 writel ( gctl, ( xhci->regs + DWUSB_GCTL ) );
73
74 /* Configure as a host controller */
77 writel ( gctl, ( xhci->regs + DWUSB_GCTL ) );
78
79 /* Initialise xHCI device */
80 xhci_init ( xhci );
81
82 /* Register xHCI device */
83 if ( ( rc = xhci_register ( xhci ) ) != 0 ) {
84 DBGC ( xhci, "XHCI %s could not register: %s\n",
85 xhci->name, strerror ( rc ) );
86 goto err_register;
87 }
88
89 dt_set_drvdata ( dt, xhci );
90 return 0;
91
92 xhci_unregister ( xhci );
93 err_register:
94 iounmap ( xhci->regs );
95 err_ioremap:
96 free ( xhci );
97 err_alloc:
98 return rc;
99}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
unsigned int uint32_t
Definition stdint.h:12
uint16_t offset
Offset to command line.
Definition bzimage.h:3
void * dt_ioremap(struct dt_device *dt, unsigned int offset, unsigned int index, size_t len)
Map devicetree range.
Definition devtree.c:52
static void dt_set_drvdata(struct dt_device *dt, void *priv)
Set devicetree driver-private data.
Definition devtree.h:72
#define DWUSB_GCTL
Global core control register.
Definition dwusb.h:15
#define DWUSB_GCTL_PRTDIR_HOST
Operate as a host.
Definition dwusb.h:17
#define DWUSB_GCTL_RESET
Core soft reset.
Definition dwusb.h:21
#define DWUSB_GCTL_PRTDIR_MASK
Port direction mask.
Definition dwusb.h:19
#define DBGC(...)
Definition compiler.h:505
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ENODEV
No such device.
Definition errno.h:510
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
struct dma_device dma
DMA device.
Definition devtree.h:23
struct device dev
Generic device.
Definition devtree.h:21
An xHCI device.
Definition xhci.h:1067
struct device * dev
Underlying hardware device.
Definition xhci.h:1071
const char * name
Name.
Definition xhci.h:1075
void * regs
Registers.
Definition xhci.h:1069
struct dma_device * dma
DMA device.
Definition xhci.h:1073
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition timer.c:79
#define readl
Definition w89c840.c:157
#define writel
Definition w89c840.c:160
void xhci_unregister(struct xhci_device *xhci)
Unregister xHCI controller.
Definition xhci.c:3364
int xhci_register(struct xhci_device *xhci)
Register xHCI controller.
Definition xhci.c:3319
void xhci_init(struct xhci_device *xhci)
Initialise device.
Definition xhci.c:264

References DBGC, dt_device::dev, xhci_device::dev, dt_device::dma, xhci_device::dma, dt_ioremap(), dt_set_drvdata(), DWUSB_GCTL, DWUSB_GCTL_PRTDIR_HOST, DWUSB_GCTL_PRTDIR_MASK, DWUSB_GCTL_RESET, ENODEV, ENOMEM, free, iounmap(), mdelay(), xhci_device::name, offset, rc, readl, xhci_device::regs, strerror(), writel, xhci_init(), xhci_register(), xhci_unregister(), and zalloc().

◆ dwusb_remove()

void dwusb_remove ( struct dt_device * dt)
static

Remove devicetree device.

Parameters
dtDevicetree device

Definition at line 106 of file dwusb.c.

106 {
107 struct xhci_device *xhci = dt_get_drvdata ( dt );
108
109 /* Unregister xHCI device */
110 xhci_unregister ( xhci );
111
112 /* Unmap registers */
113 iounmap ( xhci->regs );
114
115 /* Free device */
116 free ( xhci );
117}
static void * dt_get_drvdata(struct dt_device *dt)
Get devicetree driver-private data.
Definition devtree.h:82

References dt_get_drvdata(), free, iounmap(), xhci_device::regs, and xhci_unregister().

Variable Documentation

◆ dwusb_ids

const char* dwusb_ids[]
static
Initial value:
= {
DT_ID ( "snps,dwc3", "DesignWare USB3" ),
}
#define DT_ID(_name, _desc)
Definition devtree.h:31

DesignWare USB3 compatible model identifiers.

Definition at line 120 of file dwusb.c.

120 {
121 DT_ID ( "snps,dwc3", "DesignWare USB3" ),
122};

◆ __dt_driver

struct dt_driver dwusb_driver __dt_driver
Initial value:
= {
.name = "dwusb",
.ids = dwusb_ids,
.id_count = ( sizeof ( dwusb_ids ) / sizeof ( dwusb_ids[0] ) ),
.probe = dwusb_probe,
}
static int dwusb_probe(struct dt_device *dt, unsigned int offset)
Probe devicetree device.
Definition dwusb.c:47
static const char * dwusb_ids[]
DesignWare USB3 compatible model identifiers.
Definition dwusb.c:120
static void dwusb_remove(struct dt_device *dt)
Remove devicetree device.
Definition dwusb.c:106
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40

DesignWare USB3 devicetree driver.

Definition at line 125 of file dwusb.c.

125 {
126 .name = "dwusb",
127 .ids = dwusb_ids,
128 .id_count = ( sizeof ( dwusb_ids ) / sizeof ( dwusb_ids[0] ) ),
129 .probe = dwusb_probe,
131};