FreeBSD kernel usb device Code
musb_otg_allwinner.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/rman.h>
#include <sys/kernel.h>
#include <sys/condvar.h>
#include <sys/module.h>
#include <machine/bus.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_core.h>
#include <dev/usb/usb_busdma.h>
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_util.h>
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#include <dev/usb/controller/musb_otg.h>
#include <dev/extres/clk/clk.h>
#include <dev/extres/hwreset/hwreset.h>
#include <dev/extres/phy/phy.h>
#include <dev/extres/phy/phy_usb.h>
Include dependency graph for musb_otg_allwinner.c:

Go to the source code of this file.

Data Structures

struct  awusbdrd_softc
 

Macros

#define DRD_EP_MAX   5
 
#define DRD_EP_MAX_H3   4
 
#define MUSB2_REG_AWIN_VEND0   0x0043
 
#define VEND0_PIO_MODE   0
 
#define AWUSB_OKAY   0x01
 
#define AWUSB_NO_CONFDATA   0x02
 
#define REMAPFLAG   0x8000
 
#define REGDECL(a, b)   [(a)] = ((b) | REMAPFLAG)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static bus_size_t awusbdrd_reg (bus_size_t o)
 
static int awusbdrd_filt (bus_size_t o)
 
static uint8_t awusbdrd_bs_r_1 (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o)
 
static uint8_t awusbdrd_bs_r_1_noconf (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o)
 
static uint16_t awusbdrd_bs_r_2 (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o)
 
static void awusbdrd_bs_w_1 (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o, uint8_t v)
 
static void awusbdrd_bs_w_2 (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o, uint16_t v)
 
static void awusbdrd_bs_rm_1 (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o, uint8_t *d, bus_size_t c)
 
static void awusbdrd_bs_rm_4 (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o, uint32_t *d, bus_size_t c)
 
static void awusbdrd_bs_wm_1 (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o, const uint8_t *d, bus_size_t c)
 
static void awusbdrd_bs_wm_4 (awusb_bs_tag t, bus_space_handle_t h, bus_size_t o, const uint32_t *d, bus_size_t c)
 
static void awusbdrd_intr (void *arg)
 
static int awusbdrd_probe (device_t dev)
 
static int awusbdrd_attach (device_t dev)
 
static int awusbdrd_detach (device_t dev)
 
 DRIVER_MODULE (musbotg, simplebus, awusbdrd_driver, awusbdrd_devclass, 0, 0)
 
 MODULE_DEPEND (musbotg, usb, 1, 1, 1)
 

Variables

static struct ofw_compat_data compat_data []
 
static const struct musb_otg_ep_cfg musbotg_ep_allwinner []
 
static const struct musb_otg_ep_cfg musbotg_ep_allwinner_h3 []
 
static struct resource_spec awusbdrd_spec []
 
static const uint16_t awusbdrd_regmap []
 
static device_method_t awusbdrd_methods []
 
static driver_t awusbdrd_driver
 
static devclass_t awusbdrd_devclass
 

Macro Definition Documentation

◆ AWUSB_NO_CONFDATA

#define AWUSB_NO_CONFDATA   0x02

Definition at line 90 of file musb_otg_allwinner.c.

◆ AWUSB_OKAY

#define AWUSB_OKAY   0x01

Definition at line 89 of file musb_otg_allwinner.c.

◆ DRD_EP_MAX

#define DRD_EP_MAX   5

Definition at line 75 of file musb_otg_allwinner.c.

◆ DRD_EP_MAX_H3

#define DRD_EP_MAX_H3   4

Definition at line 76 of file musb_otg_allwinner.c.

◆ MUSB2_REG_AWIN_VEND0

#define MUSB2_REG_AWIN_VEND0   0x0043

Definition at line 78 of file musb_otg_allwinner.c.

◆ REGDECL

#define REGDECL (   a,
 
)    [(a)] = ((b) | REMAPFLAG)

Definition at line 138 of file musb_otg_allwinner.c.

◆ REMAPFLAG

#define REMAPFLAG   0x8000

Definition at line 137 of file musb_otg_allwinner.c.

◆ VEND0_PIO_MODE

#define VEND0_PIO_MODE   0

Definition at line 79 of file musb_otg_allwinner.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ awusbdrd_attach()

◆ awusbdrd_bs_r_1()

static uint8_t awusbdrd_bs_r_1 ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o 
)
static

Definition at line 246 of file musb_otg_allwinner.c.

References awusbdrd_reg(), and MUSB2_REG_HWVERS.

Referenced by awusbdrd_attach(), and awusbdrd_bs_r_1_noconf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_bs_r_1_noconf()

static uint8_t awusbdrd_bs_r_1_noconf ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o 
)
static

Definition at line 259 of file musb_otg_allwinner.c.

References awusbdrd_bs_r_1(), and MUSB2_REG_CONFDATA.

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_bs_r_2()

static uint16_t awusbdrd_bs_r_2 ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o 
)
static

Definition at line 274 of file musb_otg_allwinner.c.

References awusbdrd_filt(), and awusbdrd_reg().

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_bs_rm_1()

static void awusbdrd_bs_rm_1 ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o,
uint8_t *  d,
bus_size_t  c 
)
static

Definition at line 308 of file musb_otg_allwinner.c.

References awusbdrd_reg().

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_bs_rm_4()

static void awusbdrd_bs_rm_4 ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o,
uint32_t *  d,
bus_size_t  c 
)
static

Definition at line 317 of file musb_otg_allwinner.c.

References awusbdrd_reg().

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_bs_w_1()

static void awusbdrd_bs_w_1 ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o,
uint8_t  v 
)
static

Definition at line 284 of file musb_otg_allwinner.c.

References awusbdrd_filt(), and awusbdrd_reg().

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_bs_w_2()

static void awusbdrd_bs_w_2 ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o,
uint16_t  v 
)
static

Definition at line 296 of file musb_otg_allwinner.c.

References awusbdrd_filt(), and awusbdrd_reg().

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_bs_wm_1()

static void awusbdrd_bs_wm_1 ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o,
const uint8_t *  d,
bus_size_t  c 
)
static

Definition at line 326 of file musb_otg_allwinner.c.

References awusbdrd_filt(), and awusbdrd_reg().

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_bs_wm_4()

static void awusbdrd_bs_wm_4 ( awusb_bs_tag  t,
bus_space_handle_t  h,
bus_size_t  o,
const uint32_t *  d,
bus_size_t  c 
)
static

Definition at line 338 of file musb_otg_allwinner.c.

References awusbdrd_filt(), and awusbdrd_reg().

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_detach()

static int awusbdrd_detach ( device_t  dev)
static

◆ awusbdrd_filt()

static int awusbdrd_filt ( bus_size_t  o)
static

Definition at line 233 of file musb_otg_allwinner.c.

References MUSB2_REG_MISC, MUSB2_REG_RXDBDIS, and MUSB2_REG_TXDBDIS.

Referenced by awusbdrd_bs_r_2(), awusbdrd_bs_w_1(), awusbdrd_bs_w_2(), awusbdrd_bs_wm_1(), and awusbdrd_bs_wm_4().

Here is the caller graph for this function:

◆ awusbdrd_intr()

static void awusbdrd_intr ( void *  arg)
static

Definition at line 350 of file musb_otg_allwinner.c.

References MUSB2_READ_1, MUSB2_READ_2, MUSB2_REG_INTRX, MUSB2_REG_INTTX, MUSB2_REG_INTUSB, MUSB2_WRITE_1, MUSB2_WRITE_2, musbotg_interrupt(), and awusbdrd_softc::sc.

Referenced by awusbdrd_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ awusbdrd_probe()

static int awusbdrd_probe ( device_t  dev)
static

Definition at line 373 of file musb_otg_allwinner.c.

References compat_data, and dev.

◆ awusbdrd_reg()

static bus_size_t awusbdrd_reg ( bus_size_t  o)
static

Definition at line 215 of file musb_otg_allwinner.c.

References awusbdrd_regmap, and REMAPFLAG.

Referenced by awusbdrd_bs_r_1(), awusbdrd_bs_r_2(), awusbdrd_bs_rm_1(), awusbdrd_bs_rm_4(), awusbdrd_bs_w_1(), awusbdrd_bs_w_2(), awusbdrd_bs_wm_1(), and awusbdrd_bs_wm_4().

Here is the caller graph for this function:

◆ DRIVER_MODULE()

DRIVER_MODULE ( musbotg  ,
simplebus  ,
awusbdrd_driver  ,
awusbdrd_devclass  ,
,
 
)

◆ MODULE_DEPEND()

MODULE_DEPEND ( musbotg  ,
usb  ,
,
,
 
)

Variable Documentation

◆ awusbdrd_devclass

devclass_t awusbdrd_devclass
static

Definition at line 624 of file musb_otg_allwinner.c.

◆ awusbdrd_driver

driver_t awusbdrd_driver
static
Initial value:
= {
.name = "musbotg",
.methods = awusbdrd_methods,
.size = sizeof(struct awusbdrd_softc),
}
static device_method_t awusbdrd_methods[]

Definition at line 618 of file musb_otg_allwinner.c.

◆ awusbdrd_methods

device_method_t awusbdrd_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, awusbdrd_probe),
DEVMETHOD(device_attach, awusbdrd_attach),
DEVMETHOD(device_detach, awusbdrd_detach),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD_END
}
static int awusbdrd_probe(device_t dev)
static int awusbdrd_detach(device_t dev)
static int awusbdrd_attach(device_t dev)

Definition at line 606 of file musb_otg_allwinner.c.

◆ awusbdrd_regmap

const uint16_t awusbdrd_regmap[]
static

Definition at line 141 of file musb_otg_allwinner.c.

Referenced by awusbdrd_reg().

◆ awusbdrd_spec

struct resource_spec awusbdrd_spec[]
static
Initial value:
= {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
{ SYS_RES_IRQ, 0, RF_ACTIVE },
{ -1, 0 }
}

Definition at line 131 of file musb_otg_allwinner.c.

Referenced by awusbdrd_attach(), and awusbdrd_detach().

◆ compat_data

struct ofw_compat_data compat_data[]
static
Initial value:
= {
{ "allwinner,sun4i-a10-musb", AWUSB_OKAY },
{ "allwinner,sun6i-a31-musb", AWUSB_OKAY },
{ "allwinner,sun8i-a33-musb", AWUSB_OKAY | AWUSB_NO_CONFDATA },
{ "allwinner,sun8i-h3-musb", AWUSB_OKAY | AWUSB_NO_CONFDATA },
{ NULL, 0 }
}
#define AWUSB_OKAY
#define AWUSB_NO_CONFDATA

Definition at line 91 of file musb_otg_allwinner.c.

Referenced by awusbdrd_attach(), and awusbdrd_probe().

◆ musbotg_ep_allwinner

const struct musb_otg_ep_cfg musbotg_ep_allwinner[]
static
Initial value:
= {
{
.ep_end = DRD_EP_MAX,
.ep_fifosz_shift = 9,
.ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512,
},
{
.ep_end = -1,
},
}
#define MUSB2_VAL_FIFOSZ_512
Definition: musb_otg.h:236
#define DRD_EP_MAX

Definition at line 99 of file musb_otg_allwinner.c.

Referenced by awusbdrd_attach().

◆ musbotg_ep_allwinner_h3

const struct musb_otg_ep_cfg musbotg_ep_allwinner_h3[]
static
Initial value:
= {
{
.ep_end = DRD_EP_MAX_H3,
.ep_fifosz_shift = 9,
.ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512,
},
{
.ep_end = -1,
},
}
#define DRD_EP_MAX_H3

Definition at line 110 of file musb_otg_allwinner.c.

Referenced by awusbdrd_attach().