diff --git a/dev/usb/rules.mk b/dev/usb/rules.mk new file mode 100644 index 000000000..649f0c417 --- /dev/null +++ b/dev/usb/rules.mk @@ -0,0 +1,5 @@ +LOCAL_DIR := $(GET_LOCAL_DIR) + +OBJS += \ + $(LOCAL_DIR)/usb.o + diff --git a/dev/usb/usb.c b/dev/usb/usb.c new file mode 100644 index 000000000..6042391fc --- /dev/null +++ b/dev/usb/usb.c @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008 Travis Geiselbrecht + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include + +void usb_init(void) +{ +} + diff --git a/include/dev/usb.h b/include/dev/usb.h new file mode 100644 index 000000000..556a4edca --- /dev/null +++ b/include/dev/usb.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2008 Travis Geiselbrecht + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef __DEV_USB_H +#define __DEV_USB_H + +/* device side usb stack api */ + +void usb_init(void); + +#endif + diff --git a/include/dev/usbc.h b/include/dev/usbc.h new file mode 100644 index 000000000..26c19455f --- /dev/null +++ b/include/dev/usbc.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2008 Travis Geiselbrecht + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef __DEV_USBC_H +#define __DEV_USBC_H + +/* device side usb controller api (used by the usb stack) */ +void usbc_init(void); + +#endif + diff --git a/include/hw/usb.h b/include/hw/usb.h new file mode 100644 index 000000000..a533b7bd4 --- /dev/null +++ b/include/hw/usb.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2008 Travis Geiselbrecht + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef __HW_USB_H +#define __HW_USB_H + +#include +#include + +/* GLOBAL STATUS VALUES */ +#define STD_COMMAND 0x00 +#define SETUP_COMMAND_PHASE 0x40 +#define FUNCTION_ERROR 0x7F /* Used when we are stalling the function EP0 */ +#define HUB_ERROR 0xFF /* Used when we are stalling the HUB EP0 */ + +/* Request Types */ +#define DIR_OUT (0 << 7) +#define DIR_IN (1 << 7) +#define DIR_MASK (1 << 7) +#define TYPE_STANDARD (0 << 5) +#define TYPE_CLASS (1 << 5) +#define TYPE_VENDOR (2 << 5) +#define TYPE_MASK (3 << 5) +#define RECIP_DEVICE (0 << 0) +#define RECIP_INTERFACE (1 << 0) +#define RECIP_ENDPOINT (2 << 0) +#define RECIP_OTHER (3 << 0) +#define RECIP_MASK (0x1f << 0) + +/* 1.0 Request Values */ +#define GET_STATUS 0x00 +#define CLEAR_FEATURE 0x01 +#define SET_FEATURE 0x03 +#define SET_ADDRESS 0x05 +#define GET_DESCRIPTOR 0x06 +#define SET_DESCRIPTOR 0x07 +#define GET_CONFIGURATION 0x08 +#define SET_CONFIGURATION 0x09 +#define GET_INTERFACE 0x0A +#define SET_INTERFACE 0x0B +#define SYNCH_FRAME 0x0C + +/* Mass storage requests */ +#define MASS_STORAGE_GET_MAX_LUN 0xfe +#define MASS_STORAGE_RESET 0xff + +/* DFU requests */ +#define DFU_DETACH 0x00 +#define DFU_DNLOAD 0x01 +#define DFU_UPLOAD 0x02 +#define DFU_GETSTATUS 0x03 +#define DFU_CLRSTATUS 0x04 +#define DFU_GETSTATE 0x05 +#define DFU_ABORT 0x06 + +/* HID Request Values */ +#define GET_REPORT 0x01 +#define GET_IDLE 0x02 +#define GET_PROTOCOL 0x03 +#define SET_REPORT 0x09 +#define SET_IDLE 0x0A +#define SET_PROTOCOL 0x0B + +/* Descriptor Types */ +#define DEVICE 0x01 +#define CONFIGURATION 0x02 +#define STRING 0x03 +#define INTERFACE 0x04 +#define ENDPOINT 0x05 +#define DEVICE_QUALIFIER 0x06 +#define OTHER_SPEED_CONFIGURATION 0x07 +#define INTERFACE_POWER 0x08 +#define HID 0x21 +#define HIDREPORT 0x22 +#define HIDPHYSICAL 0x23 + +/* general USB defines */ +struct usb_setup { + uint8_t request_type; + uint8_t request; + uint16_t value; + uint16_t index; + uint16_t length; +} __PACKED; + +#endif + diff --git a/include/reg.h b/include/reg.h index e10a3e865..d04d4ea4a 100644 --- a/include/reg.h +++ b/include/reg.h @@ -31,6 +31,11 @@ #define REG16(addr) ((volatile uint16_t *)(addr)) #define REG8(addr) ((volatile uint8_t *)(addr)) +#define RMWREG64(addr, startbit, width, val) *REG64(addr) = (*REG64(addr) & ~(((1<<(width)) - 1) << (startbit))) | ((val) << (startbit)) +#define RMWREG32(addr, startbit, width, val) *REG32(addr) = (*REG32(addr) & ~(((1<<(width)) - 1) << (startbit))) | ((val) << (startbit)) +#define RMWREG16(addr, startbit, width, val) *REG16(addr) = (*REG16(addr) & ~(((1<<(width)) - 1) << (startbit))) | ((val) << (startbit)) +#define RMWREG8(addr, startbit, width, val) *REG8(addr) = (*REG8(addr) & ~(((1<<(width)) - 1) << (startbit))) | ((val) << (startbit)) + #define writel(v, a) (*REG32(a) = (v)) #define readl(a) (*REG32(a)) diff --git a/platform/omap3/i2c.c b/platform/omap3/i2c.c index 1c3efee51..ad07d29cb 100644 --- a/platform/omap3/i2c.c +++ b/platform/omap3/i2c.c @@ -230,6 +230,10 @@ void i2c_init_early(void) { LTRACE_ENTRY; + /* enable clocks on i2c 0-2 */ + RMWREG32(CM_FCLKEN1_CORE, 15, 3, 0x7), + RMWREG32(CM_ICLKEN1_CORE, 15, 3, 0x7), + i2c_reset_bus(0); i2c_reset_bus(1); i2c_reset_bus(2); diff --git a/platform/omap3/include/platform/omap3.h b/platform/omap3/include/platform/omap3.h index 1ad3ae0eb..4a2534e6e 100644 --- a/platform/omap3/include/platform/omap3.h +++ b/platform/omap3/include/platform/omap3.h @@ -39,6 +39,47 @@ /* clocks */ #define CM_CLKSEL_PER (L4_BASE + 0x5040) +/* PRCM */ +#define CM_FCLKEN_IVA2 (L4_BASE + 0x4000) +#define CM_CLKEN_PLL_IVA2 (L4_BASE + 0x4004) +#define CM_IDLEST_PLL_IVA2 (L4_BASE + 0x4024) +#define CM_CLKSEL1_PLL_IVA2 (L4_BASE + 0x4040) +#define CM_CLKSEL2_PLL_IVA2 (L4_BASE + 0x4044) +#define CM_CLKEN_PLL_MPU (L4_BASE + 0x4904) +#define CM_IDLEST_PLL_MPU (L4_BASE + 0x4924) +#define CM_CLKSEL1_PLL_MPU (L4_BASE + 0x4940) +#define CM_CLKSEL2_PLL_MPU (L4_BASE + 0x4944) +#define CM_FCLKEN1_CORE (L4_BASE + 0x4a00) +#define CM_ICLKEN1_CORE (L4_BASE + 0x4a10) +#define CM_ICLKEN2_CORE (L4_BASE + 0x4a14) +#define CM_CLKSEL_CORE (L4_BASE + 0x4a40) +#define CM_FCLKEN_GFX (L4_BASE + 0x4b00) +#define CM_ICLKEN_GFX (L4_BASE + 0x4b10) +#define CM_CLKSEL_GFX (L4_BASE + 0x4b40) +#define CM_FCLKEN_WKUP (L4_BASE + 0x4c00) +#define CM_ICLKEN_WKUP (L4_BASE + 0x4c10) +#define CM_CLKSEL_WKUP (L4_BASE + 0x4c40) +#define CM_IDLEST_WKUP (L4_BASE + 0x4c20) +#define CM_CLKEN_PLL (L4_BASE + 0x4d00) +#define CM_IDLEST_CKGEN (L4_BASE + 0x4d20) +#define CM_CLKSEL1_PLL (L4_BASE + 0x4d40) +#define CM_CLKSEL2_PLL (L4_BASE + 0x4d44) +#define CM_CLKSEL3_PLL (L4_BASE + 0x4d48) +#define CM_FCLKEN_DSS (L4_BASE + 0x4e00) +#define CM_ICLKEN_DSS (L4_BASE + 0x4e10) +#define CM_CLKSEL_DSS (L4_BASE + 0x4e40) +#define CM_FCLKEN_CAM (L4_BASE + 0x4f00) +#define CM_ICLKEN_CAM (L4_BASE + 0x4f10) +#define CM_CLKSEL_CAM (L4_BASE + 0x4F40) +#define CM_FCLKEN_PER (L4_BASE + 0x5000) +#define CM_ICLKEN_PER (L4_BASE + 0x5010) +#define CM_CLKSEL_PER (L4_BASE + 0x5040) +#define CM_CLKSEL1_EMU (L4_BASE + 0x5140) + +#define PRM_CLKSEL (L4_BASE + 0x306d40) +#define PRM_RSTCTRL (L4_BASE + 0x307250) +#define PRM_CLKSRC_CTRL (L4_BASE + 0x307270) + /* General Purpose Timers */ #define OMAP34XX_GPT1 (L4_BASE + 0x318000) #define OMAP34XX_GPT2 (L4_BASE + 0x1032000) @@ -171,6 +212,19 @@ #define INT_VECTORS 96 #define GPT2_IRQ 38 +/* HS USB */ +#define USB_HS_BASE (L4_BASE + 0xab000) + +/* USB OTG */ +#define OTG_BASE (L4_BASE + 0xab400) + +#define OTG_REVISION (OTG_BASE + 0x00) +#define OTG_SYSCONFIG (OTG_BASE + 0x04) +#define OTG_SYSSTATUS (OTG_BASE + 0x08) +#define OTG_INTERFSEL (OTG_BASE + 0x0C) +#define OTG_SIMENABLE (OTG_BASE + 0x10) +#define OTG_FORCESTDBY (OTG_BASE + 0x14) + /* I2C */ #define I2C1_BASE (L4_BASE + 0x70000) #define I2C2_BASE (L4_BASE + 0x72000) diff --git a/platform/omap3/platform.c b/platform/omap3/platform.c index fbe1b46f1..cba7a2644 100644 --- a/platform/omap3/platform.c +++ b/platform/omap3/platform.c @@ -28,6 +28,7 @@ #include #include #include +#include void platform_init_mmu_mappings(void) { @@ -56,5 +57,9 @@ void platform_early_init(void) void platform_init(void) { i2c_init(); + + uart_init(); + + usbc_init(); } diff --git a/platform/omap3/rules.mk b/platform/omap3/rules.mk index ea47c37a2..c92ba0bfb 100644 --- a/platform/omap3/rules.mk +++ b/platform/omap3/rules.mk @@ -4,6 +4,13 @@ ARCH := arm ARM_CPU := cortex-a8 CPU := generic +DEVS += usb + +# provides a few devices +DEFINES += \ + WITH_DEV_USBC=1 \ + WITH_DEV_UART=1 + INCLUDES += \ -I$(LOCAL_DIR)/include @@ -14,7 +21,8 @@ OBJS += \ $(LOCAL_DIR)/interrupts.o \ $(LOCAL_DIR)/platform.o \ $(LOCAL_DIR)/timer.o \ - $(LOCAL_DIR)/uart.o + $(LOCAL_DIR)/uart.o \ + $(LOCAL_DIR)/usbc.o MEMBASE := 0x80000000 diff --git a/platform/omap3/timer.c b/platform/omap3/timer.c index c6df2088f..f101f503e 100644 --- a/platform/omap3/timer.c +++ b/platform/omap3/timer.c @@ -104,6 +104,11 @@ static enum handler_return os_timer_tick(void *arg) void platform_init_timer(void) { + /* GPT2 */ + RMWREG32(CM_CLKSEL_PER, 0, 1, 1); + RMWREG32(CM_ICLKEN_PER, 3, 1, 1); + RMWREG32(CM_FCLKEN_PER, 3, 1, 1); + // reset the GP timer TIMER_REG(TIOCP_CFG) = 0x2; while ((TIMER_REG(TISTAT) & 1) == 0) diff --git a/platform/omap3/uart.c b/platform/omap3/uart.c index e4c51022d..27eee9f01 100644 --- a/platform/omap3/uart.c +++ b/platform/omap3/uart.c @@ -21,6 +21,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include +#include #include #include #include @@ -105,6 +106,18 @@ void uart_init_port(int port, uint baud) void uart_init_early(void) { + /* UART1 */ + RMWREG32(CM_FCLKEN1_CORE, 13, 1, 1), + RMWREG32(CM_ICLKEN1_CORE, 13, 1, 1), + + /* UART2 */ + RMWREG32(CM_FCLKEN1_CORE, 14, 1, 1), + RMWREG32(CM_ICLKEN1_CORE, 14, 1, 1), + + /* UART3 */ + RMWREG32(CM_FCLKEN_PER, 11, 1, 1), + RMWREG32(CM_ICLKEN_PER, 11, 1, 1), + uart_init_port(DEBUG_UART, 115200); } diff --git a/platform/omap3/usbc.c b/platform/omap3/usbc.c new file mode 100644 index 000000000..99f950401 --- /dev/null +++ b/platform/omap3/usbc.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2008 Travis Geiselbrecht + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#define LOCAL_TRACE 1 + +#define hsusb_reg8(reg) *REG8(USB_HS_BASE + (reg)) +#define hsusb_reg16(reg) *REG16(USB_HS_BASE + (reg)) +#define hsusb_reg32(reg) *REG32(USB_HS_BASE + (reg)) + +/* registers */ +#define FADDR 0x0 +#define POWER 0x1 +#define INTRTX 0x2 +#define INTRRX 0x4 +#define INTRTXE 0x6 +#define INTRRXE 0x8 +#define INTRUSB 0xa +#define INTRUSBE 0xb +#define FRAME 0xc +#define INDEX 0xe +#define TESTMODE 0xf + +// indexed endpoint regs +#define IDX_TXMAXP 0x10 +#define IDX_TXCSR 0x12 +#define IDX_TXCSRL 0x12 +#define IDX_TXCSRH 0x13 +#define IDX_RXMAXP 0x14 +#define IDX_RXCSR 0x16 +#define IDX_RXCSRL 0x16 +#define IDX_RXCSRH 0x17 +#define IDX_RXCOUNT 0x18 +#define IDX_FIFOSIZE 0x1f + +// if endpoint 0 is selected +#define IDX_CSR0 0x12 +#define IDX_CONFIGDATA 0x1f + +// endpoint FIFOs +#define FIFOBASE 0x20 + +#define DEVCTL 0x60 +#define TXFIFOSZ 0x62 +#define RXFIFOSZ 0x63 +#define TXFIFOADD 0x64 +#define RXFIFOADD 0x66 +#define HWVERS 0x6c +#define EPINFO 0x78 +#define RAMINFO 0x79 +#define LINKINFO 0x7a + +static enum handler_return hsusb_interrupt(void *arg) +{ + uint16_t intrtx = hsusb_reg16(INTRTX); + uint16_t intrrx = hsusb_reg16(INTRRX); + uint8_t intrusb = hsusb_reg8(INTRUSB); + enum handler_return ret = INT_NO_RESCHEDULE; + + LTRACEF("intrtx 0x%hx (0x%x), intrrx 0x%hx (0x%x), intrusb 0x%hhx, intrusbe 0x%hhx\n", + intrtx, hsusb_reg16(INTRTXE), intrrx, hsusb_reg16(INTRRXE), intrusb, hsusb_reg8(INTRUSBE)); + + return ret; +} + +int usbc_set_active(bool active) +{ + if (active) { +// DEBUG_ASSERT(!usbc->active); + + hsusb_reg8(POWER) |= (1<<6); // soft conn + twl4030_set_usb_pullup(true); +// usbc->active = true; + } else { + hsusb_reg8(POWER) &= ~(1<<6); // soft conn + twl4030_set_usb_pullup(false); +// usbc->active = false; + } + + return 0; +} + +static void otg_reset(void) +{ + /* reset the chip */ + *REG32(OTG_SYSCONFIG) |= (1<<1); + while ((*REG32(OTG_SYSSTATUS) & 1) == 0) + ; + + /* power up the controller */ + *REG32(OTG_FORCESTDBY) = 0; // disable forced standby + *REG32(OTG_SYSCONFIG) &= ~(1<<1); // autoidle off + *REG32(OTG_SYSCONFIG) = (2<<12) | (2<<3) | (0<<0); // master in smart-standby, periph in smart-idle, autoidle off + + *REG32(OTG_SYSCONFIG) |= 1; // autoidle on + + *REG32(OTG_INTERFSEL) = 1; // 8 bit ULPI +} + +static void hsusb_init(void) +{ + LTRACE_ENTRY; + + // select endpoint 0 + dprintf("hwvers 0x%hx\n", hsusb_reg16(HWVERS)); + dprintf("epinfo 0x%hhx\n", hsusb_reg8(EPINFO)); + dprintf("raminfo 0x%hhx\n", hsusb_reg8(RAMINFO)); + hsusb_reg8(INDEX) = 0; + dprintf("config 0x%hhx\n", hsusb_reg8(IDX_CONFIGDATA)); + + // assert that we have dynamic fifo sizing + DEBUG_ASSERT(hsusb_reg8(IDX_CONFIGDATA) & (1<<2)); + + // mask all the interrupts for the endpoints (except 0) + hsusb_reg16(INTRTXE) = (1<<0); + hsusb_reg16(INTRRXE) = 0; + + twl4030_usb_reset(); + twl4030_init_hs(); + + hsusb_reg8(DEVCTL) = 0; // peripheral mode +// hsusb_reg8(POWER) &= (1<<5); // disable high speed + hsusb_reg8(POWER) |= (1<<5); // enable high speed + + hsusb_reg8(INTRUSBE) = (1<<5)|(1<<2)|(1<<1)|(1<<0); // disconnect, reset, resume, suspend + + LTRACE_EXIT; +} + +void usbc_init(void) +{ + // enable the clock + RMWREG32(CM_ICLKEN1_CORE, 4, 1, 1); + + // register the interrupt handlers + register_int_handler(92, hsusb_interrupt, NULL); +// register_int_handler(93, hsusb_dma_interrupt, NULL); + + otg_reset(); + hsusb_init(); + + unmask_interrupt(92, NULL); +// unmask_interrupt(93, NULL); + + usbc_set_active(true); +} +