iPXE
Functions | Variables
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. More...
 
static void dwusb_remove (struct dt_device *dt)
 Remove devicetree device. More...
 

Variables

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

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()

static 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 */
75  gctl &= ~DWUSB_GCTL_PRTDIR_MASK;
76  gctl |= DWUSB_GCTL_PRTDIR_HOST;
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:14
int xhci_register(struct xhci_device *xhci)
Register xHCI controller.
Definition: xhci.c:3318
An xHCI device.
Definition: xhci.h:1066
#define DWUSB_GCTL
Global core control register.
Definition: dwusb.h:15
#define DWUSB_GCTL_PRTDIR_MASK
Port direction mask.
Definition: dwusb.h:19
void * regs
Registers.
Definition: xhci.h:1068
uint32_t readl(volatile uint32_t *io_addr)
Read 32-bit dword from memory-mapped device.
struct device * dev
Underlying hardware device.
Definition: xhci.h:1070
#define DBGC(...)
Definition: compiler.h:505
struct device dev
Generic device.
Definition: devtree.h:21
#define ENOMEM
Not enough space.
Definition: errno.h:534
void xhci_init(struct xhci_device *xhci)
Initialise device.
Definition: xhci.c:263
void writel(uint32_t data, volatile uint32_t *io_addr)
Write 32-bit dword to memory-mapped device.
#define DWUSB_GCTL_RESET
Core soft reset.
Definition: dwusb.h:21
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static void dt_set_drvdata(struct dt_device *dt, void *priv)
Set devicetree driver-private data.
Definition: devtree.h:66
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:661
const char * name
Name.
Definition: xhci.h:1074
#define ENODEV
No such device.
Definition: errno.h:509
unsigned int uint32_t
Definition: stdint.h:12
#define DWUSB_GCTL_PRTDIR_HOST
Operate as a host.
Definition: dwusb.h:17
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
Definition: timer.c:78
void * dt_ioremap(struct dt_device *dt, unsigned int offset, unsigned int index, size_t len)
Map devicetree range.
Definition: devtree.c:52
void iounmap(volatile const void *io_addr)
Unmap I/O address.
struct dma_device * dma
DMA device.
Definition: xhci.h:1072
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
struct dma_device dma
DMA device.
Definition: devtree.h:23
void xhci_unregister(struct xhci_device *xhci)
Unregister xHCI controller.
Definition: xhci.c:3363

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()

static 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 }
An xHCI device.
Definition: xhci.h:1066
void * regs
Registers.
Definition: xhci.h:1068
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void iounmap(volatile const void *io_addr)
Unmap I/O address.
void xhci_unregister(struct xhci_device *xhci)
Unregister xHCI controller.
Definition: xhci.c:3363
static void * dt_get_drvdata(struct dt_device *dt)
Get devicetree driver-private data.
Definition: devtree.h:76

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

Variable Documentation

◆ dwusb_ids

const char* dwusb_ids[]
static
Initial value:
= {
"snps,dwc3",
}

DesignWare USB3 compatible model identifiers.

Definition at line 120 of file dwusb.c.

◆ __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 const char * dwusb_ids[]
DesignWare USB3 compatible model identifiers.
Definition: dwusb.c:120
static int dwusb_probe(struct dt_device *dt, unsigned int offset)
Probe devicetree device.
Definition: dwusb.c:47
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:39

DesignWare USB3 devicetree driver.

Definition at line 125 of file dwusb.c.