From 98ab8117d68f05bb36b9aeb857273e896199bc6a Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 5 Oct 2021 18:20:44 -0700 Subject: [PATCH] USB seems to init ok --- .gitmodules | 4 ++++ hw/bsp/raspberrypi4/family.c | 18 ++++++++++++------ hw/bsp/raspberrypi4/family.mk | 16 +++++++++------- hw/mcu/broadcom | 1 + 4 files changed, 26 insertions(+), 13 deletions(-) create mode 160000 hw/mcu/broadcom diff --git a/.gitmodules b/.gitmodules index 4c86fd55c..95f35d270 100644 --- a/.gitmodules +++ b/.gitmodules @@ -127,3 +127,7 @@ [submodule "hw/mcu/gd/nuclei-sdk"] path = hw/mcu/gd/nuclei-sdk url = https://github.com/Nuclei-Software/nuclei-sdk.git +[submodule "hw/mcu/broadcom"] + path = hw/mcu/broadcom + url = git@github.com:adafruit/broadcom-peripherals.git + branch = main-build diff --git a/hw/bsp/raspberrypi4/family.c b/hw/bsp/raspberrypi4/family.c index 6266d5a35..fe7e429d6 100644 --- a/hw/bsp/raspberrypi4/family.c +++ b/hw/bsp/raspberrypi4/family.c @@ -27,8 +27,9 @@ #include "bsp/board.h" #include "board.h" -#include "io.h" -#include "mmu.h" +#include "broadcom/io.h" +#include "broadcom/mmu.h" +#include "broadcom/vcmailbox.h" //--------------------------------------------------------------------+ // Forward USB interrupt events to TinyUSB IRQ Handler @@ -46,9 +47,8 @@ void OTG_FS_IRQHandler(void) // Board porting API //--------------------------------------------------------------------+ -void print(void) { - const char* greeting2 = "hello from cm100\r\n"; - board_uart_write(greeting2, strlen(greeting2)); +void print(const char* str) { + board_uart_write(str, strlen(str)); } void board_init(void) @@ -83,7 +83,7 @@ void board_init(void) board_uart_write(greeting, strlen(greeting)); // gpio_setPinOutputBool(24, false); // gpio_setPinOutputBool(25, true); - print(); + // print(); // gpio_setPinOutputBool(25, false); // while (true) { // // for (size_t i = 0; i < 5; i++) { @@ -97,6 +97,12 @@ void board_init(void) // gpio_setPinOutputBool(42, false); // } // while (1) uart_update(); + + // Turn on USB peripheral. + print("Turning on USB power\r\n"); + + vcmailbox_set_power_state(VCMAILBOX_DEVICE_USB_HCD, true); + print("USB power on\r\n"); } void board_led_write(bool state) diff --git a/hw/bsp/raspberrypi4/family.mk b/hw/bsp/raspberrypi4/family.mk index 1547beee1..b36a83b48 100644 --- a/hw/bsp/raspberrypi4/family.mk +++ b/hw/bsp/raspberrypi4/family.mk @@ -2,7 +2,7 @@ UF2_FAMILY_ID = 0x57755a57 include $(TOP)/$(BOARD_PATH)/board.mk -MCU_DIR = hw/mcu/broadcom/bcm2711 +MCU_DIR = hw/mcu/broadcom CC = clang @@ -18,21 +18,23 @@ CFLAGS += \ SRC_C += \ src/portable/broadcom/synopsys/dcd_synopsys.c \ - $(MCU_DIR)/interrupts.c \ - $(MCU_DIR)/io.c \ - $(MCU_DIR)/mmu.c + $(MCU_DIR)/broadcom/interrupts.c \ + $(MCU_DIR)/broadcom/io.c \ + $(MCU_DIR)/broadcom/mmu.c \ + $(MCU_DIR)/broadcom/vcmailbox.c CROSS_COMPILE = aarch64-none-elf- SKIP_NANOLIB = 1 -LD_FILE = $(MCU_DIR)/link.ld +LD_FILE = $(MCU_DIR)/broadcom/link.ld INC += \ $(TOP)/$(BOARD_PATH) \ - $(TOP)/$(MCU_DIR) + $(TOP)/$(MCU_DIR) \ + $(TOP)/lib/CMSIS_5/CMSIS/Core_A/Include -SRC_S += $(MCU_DIR)/boot.S +SRC_S += $(MCU_DIR)/broadcom/boot.S $(BUILD)/kernel8.img: $(BUILD)/$(PROJECT).elf $(OBJCOPY) -O binary $^ $@ diff --git a/hw/mcu/broadcom b/hw/mcu/broadcom new file mode 160000 index 000000000..c24e8f689 --- /dev/null +++ b/hw/mcu/broadcom @@ -0,0 +1 @@ +Subproject commit c24e8f6898d7cf8e2884eb70dbabd97480526450