diff --git a/sys/dev/usb/controller/dwc3.h b/sys/dev/usb/controller/dwc3.h --- a/sys/dev/usb/controller/dwc3.h +++ b/sys/dev/usb/controller/dwc3.h @@ -31,6 +31,15 @@ #ifndef _DWC3_H_ #define _DWC3_H_ +#define DWC3_IP_ID 0x5533 +#define DWC3_1_IP_ID 0x3331 +#define DWC3_2_IP_ID 0x3332 + +#define DWC3_VERSION_MASK 0xFFFF0000 +#define DWC3_REVISION_MASK 0xFFFF +#define DWC3_VERSION(x) (((x) & DWC3_VERSION_MASK) >> 16) +#define DWC3_REVISION(x) ((x) & DWC3_REVISION_MASK) + #define DWC3_GSBUSCFG0 0xc100 #define DWC3_GSBUSCFG1 0xc104 #define DWC3_GTXTHRCFG 0xc108 @@ -80,6 +89,9 @@ #define DWC3_GPRTBIMAP_HSLO 0xc180 #define DWC3_GPRTBIMAP_FSLO 0xc188 +#define DWC3_1_VER_NUMBER 0xc1a0 +#define DWC3_1_VER_TYPE 0xc1a4 + #define DWC3_GUSB2PHYCFG0 0xc200 #define DWC3_GUSB2PHYCFG0_PHYSOFTRST (1 << 31) #define DWC3_GUSB2PHYCFG0_U2_FREECLK_EXISTS (1 << 30) diff --git a/sys/dev/usb/controller/dwc3.c b/sys/dev/usb/controller/dwc3.c --- a/sys/dev/usb/controller/dwc3.c +++ b/sys/dev/usb/controller/dwc3.c @@ -86,6 +86,9 @@ bus_space_tag_t bst; bus_space_handle_t bsh; uint32_t snpsid; + uint32_t snpsversion; + uint32_t snpsrevision; + uint32_t snpsversion_type; #ifdef FDT clk_t clk_ref; clk_t clk_suspend; @@ -389,8 +392,31 @@ sc->bsh = rman_get_bushandle(sc->mem_res); sc->snpsid = DWC3_READ(sc, DWC3_GSNPSID); - if (bootverbose) - device_printf(sc->dev, "snps id: %#012x\n", sc->snpsid); + sc->snpsversion = DWC3_VERSION(sc->snpsid); + sc->snpsrevision = DWC3_REVISION(sc->snpsid); + if (sc->snpsversion == DWC3_1_IP_ID || + sc->snpsversion == DWC3_2_IP_ID) { + sc->snpsrevision = DWC3_READ(sc, DWC3_1_VER_NUMBER); + sc->snpsversion_type = DWC3_READ(sc, DWC3_1_VER_TYPE); + } + if (bootverbose) { + switch (sc->snpsversion) { + case DWC3_IP_ID: + device_printf(sc->dev, "SNPS Version: DWC3 (%x %x)\n", + sc->snpsversion, sc->snpsrevision); + break; + case DWC3_1_IP_ID: + device_printf(sc->dev, "SNPS Version: DWC3.1 (%x %x %x)\n", + sc->snpsversion, sc->snpsrevision, + sc->snpsversion_type); + break; + case DWC3_2_IP_ID: + device_printf(sc->dev, "SNPS Version: DWC3.2 (%x %x %x)\n", + sc->snpsversion, sc->snpsrevision, + sc->snpsversion_type); + break; + } + } #ifdef DWC3_DEBUG snps_dwc3_dump_ctrlparams(sc); #endif