summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorScott Shawcroft <[email protected]>2022-01-05 13:47:01 -0800
committerScott Shawcroft <[email protected]>2022-01-05 13:47:01 -0800
commita79ffeb7643bb9c7e7af69f29fe2cfe7ded837d8 (patch)
treeb525d3646ac59cb7fbd3a1eb13e1bfe585cd1d45 /hw
parent868948f67c90fa7c2553cdcd604b52862cf55720 (diff)
Add Raspberry Pi Zero W and Zero 2 W
These are different Broadcom chips. The peripherals are essentially the same. The main differences are: * The CPU(s) * The interrupt controller * The peripheral base address (but not the peripherals that we use)
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/bcm2835/boards/raspberrypi_cm4/board.h (renamed from hw/bsp/raspberrypi4/boards/raspberrypi_cm4/board.h)0
-rw-r--r--hw/bsp/bcm2835/boards/raspberrypi_cm4/board.mk9
-rw-r--r--hw/bsp/bcm2835/boards/raspberrypi_zero2w/board.h38
-rw-r--r--hw/bsp/bcm2835/boards/raspberrypi_zero2w/board.mk9
-rw-r--r--hw/bsp/bcm2835/boards/raspberrypi_zero_w/board.h38
-rw-r--r--hw/bsp/bcm2835/boards/raspberrypi_zero_w/board.mk7
-rw-r--r--hw/bsp/bcm2835/family.c (renamed from hw/bsp/raspberrypi4/family.c)32
-rw-r--r--hw/bsp/bcm2835/family.mk (renamed from hw/bsp/raspberrypi4/family.mk)24
-rw-r--r--hw/bsp/raspberrypi4/boards/raspberrypi_cm4/board.mk1
m---------hw/mcu/broadcom0
10 files changed, 131 insertions, 27 deletions
diff --git a/hw/bsp/raspberrypi4/boards/raspberrypi_cm4/board.h b/hw/bsp/bcm2835/boards/raspberrypi_cm4/board.h
index 1d3565d5c..1d3565d5c 100644
--- a/hw/bsp/raspberrypi4/boards/raspberrypi_cm4/board.h
+++ b/hw/bsp/bcm2835/boards/raspberrypi_cm4/board.h
diff --git a/hw/bsp/bcm2835/boards/raspberrypi_cm4/board.mk b/hw/bsp/bcm2835/boards/raspberrypi_cm4/board.mk
new file mode 100644
index 000000000..b4fa3dff6
--- /dev/null
+++ b/hw/bsp/bcm2835/boards/raspberrypi_cm4/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += -mcpu=cortex-a72 \
+ -DBCM_VERSION=2711 \
+ -DCFG_TUSB_MCU=OPT_MCU_BCM2711
+
+CROSS_COMPILE = aarch64-none-elf-
+
+SUFFIX = 8
+
+INC += $(TOP)/lib/CMSIS_5/CMSIS/Core_A/Include
diff --git a/hw/bsp/bcm2835/boards/raspberrypi_zero2w/board.h b/hw/bsp/bcm2835/boards/raspberrypi_zero2w/board.h
new file mode 100644
index 000000000..1d3565d5c
--- /dev/null
+++ b/hw/bsp/bcm2835/boards/raspberrypi_zero2w/board.h
@@ -0,0 +1,38 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/bcm2835/boards/raspberrypi_zero2w/board.mk b/hw/bsp/bcm2835/boards/raspberrypi_zero2w/board.mk
new file mode 100644
index 000000000..f43e12e35
--- /dev/null
+++ b/hw/bsp/bcm2835/boards/raspberrypi_zero2w/board.mk
@@ -0,0 +1,9 @@
+CFLAGS += -mcpu=cortex-a53 \
+ -DBCM_VERSION=2837 \
+ -DCFG_TUSB_MCU=OPT_MCU_BCM2837
+
+CROSS_COMPILE = aarch64-none-elf-
+
+SUFFIX = 8
+
+INC += $(TOP)/lib/CMSIS_5/CMSIS/Core_A/Include
diff --git a/hw/bsp/bcm2835/boards/raspberrypi_zero_w/board.h b/hw/bsp/bcm2835/boards/raspberrypi_zero_w/board.h
new file mode 100644
index 000000000..1d3565d5c
--- /dev/null
+++ b/hw/bsp/bcm2835/boards/raspberrypi_zero_w/board.h
@@ -0,0 +1,38 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020, Ha Thach (tinyusb.org)
+ *
+ * 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.
+ *
+ * This file is part of the TinyUSB stack.
+ */
+
+#ifndef BOARD_H_
+#define BOARD_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* BOARD_H_ */
diff --git a/hw/bsp/bcm2835/boards/raspberrypi_zero_w/board.mk b/hw/bsp/bcm2835/boards/raspberrypi_zero_w/board.mk
new file mode 100644
index 000000000..79d7096ce
--- /dev/null
+++ b/hw/bsp/bcm2835/boards/raspberrypi_zero_w/board.mk
@@ -0,0 +1,7 @@
+CFLAGS += -mcpu=arm1176jzf-s \
+ -DBCM_VERSION=2835 \
+ -DCFG_TUSB_MCU=OPT_MCU_BCM2835
+
+CROSS_COMPILE = arm-none-eabi-
+
+SUFFIX =
diff --git a/hw/bsp/raspberrypi4/family.c b/hw/bsp/bcm2835/family.c
index ba0b2700a..f7a11fb49 100644
--- a/hw/bsp/raspberrypi4/family.c
+++ b/hw/bsp/bcm2835/family.c
@@ -27,8 +27,9 @@
#include "bsp/board.h"
#include "board.h"
+#include "broadcom/cpu.h"
+#include "broadcom/gpio.h"
#include "broadcom/interrupts.h"
-#include "broadcom/io.h"
#include "broadcom/mmu.h"
#include "broadcom/caches.h"
#include "broadcom/vcmailbox.h"
@@ -37,9 +38,8 @@
#define LED_PIN 18
#define LED_STATE_ON 1
-// Button
-#define BUTTON_PIN 16
-#define BUTTON_STATE_ACTIVE 0
+// UART TX
+#define UART_TX_PIN 14
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
@@ -62,14 +62,26 @@ void board_init(void)
init_caches();
// LED
- gpio_initOutputPinWithPullNone(LED_PIN);
+ gpio_set_function(LED_PIN, GPIO_FUNCTION_OUTPUT);
+ gpio_set_pull(LED_PIN, BP_PULL_NONE);
board_led_write(true);
- // Button
- // TODO
-
// Uart
- uart_init();
+ COMPLETE_MEMORY_READS;
+ AUX->ENABLES_b.UART_1 = true;
+
+ UART1->IER = 0;
+ UART1->CNTL = 0;
+ UART1->LCR_b.DATA_SIZE = UART1_LCR_DATA_SIZE_MODE_8BIT;
+ UART1->MCR = 0;
+ UART1->IER = 0;
+
+ uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE);
+ UART1->BAUD = ((source_clock / (115200 * 8)) - 1);
+ UART1->CNTL |= UART1_CNTL_TX_ENABLE_Msk;
+ COMPLETE_MEMORY_READS;
+
+ gpio_set_function(UART_TX_PIN, GPIO_FUNCTION_ALT5);
// Turn on USB peripheral.
vcmailbox_set_power_state(VCMAILBOX_DEVICE_USB_HCD, true);
@@ -87,7 +99,7 @@ void board_init(void)
void board_led_write(bool state)
{
- gpio_setPinOutputBool(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
+ gpio_set_value(LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
}
uint32_t board_button_read(void)
diff --git a/hw/bsp/raspberrypi4/family.mk b/hw/bsp/bcm2835/family.mk
index c65070a71..6de97f584 100644
--- a/hw/bsp/raspberrypi4/family.mk
+++ b/hw/bsp/bcm2835/family.mk
@@ -3,18 +3,14 @@ DEPS_SUBMODULES += $(MCU_DIR)
include $(TOP)/$(BOARD_PATH)/board.mk
-CC = clang
-
CFLAGS += \
- -mcpu=cortex-a72 \
-Wall \
-O0 \
-ffreestanding \
-nostdlib \
-nostartfiles \
- -std=c17 \
-mgeneral-regs-only \
- -DCFG_TUSB_MCU=OPT_MCU_BCM2711
+ -std=c17
# mcu driver cause following warnings
CFLAGS += -Wno-error=cast-qual
@@ -22,30 +18,26 @@ CFLAGS += -Wno-error=cast-qual
SRC_C += \
src/portable/synopsys/dwc2/dcd_dwc2.c \
$(MCU_DIR)/broadcom/gen/interrupt_handlers.c \
+ $(MCU_DIR)/broadcom/gpio.c \
$(MCU_DIR)/broadcom/interrupts.c \
- $(MCU_DIR)/broadcom/io.c \
$(MCU_DIR)/broadcom/mmu.c \
$(MCU_DIR)/broadcom/caches.c \
$(MCU_DIR)/broadcom/vcmailbox.c
-
-CROSS_COMPILE = aarch64-none-elf-
-
SKIP_NANOLIB = 1
-LD_FILE = $(MCU_DIR)/broadcom/link.ld
+LD_FILE = $(MCU_DIR)/broadcom/link$(SUFFIX).ld
INC += \
$(TOP)/$(BOARD_PATH) \
- $(TOP)/$(MCU_DIR) \
- $(TOP)/lib/CMSIS_5/CMSIS/Core_A/Include
+ $(TOP)/$(MCU_DIR)
-SRC_S += $(MCU_DIR)/broadcom/boot.S
+SRC_S += $(MCU_DIR)/broadcom/boot$(SUFFIX).S
-$(BUILD)/kernel8.img: $(BUILD)/$(PROJECT).elf
+$(BUILD)/kernel$(SUFFIX).img: $(BUILD)/$(PROJECT).elf
$(OBJCOPY) -O binary $^ $@
# Copy to kernel to netboot drive or SD card
# Change destinaation to fit your need
-flash: $(BUILD)/kernel8.img
- $(CP) $< /home/$(USER)/Documents/code/pi4_tinyusb/boot_cpy
+flash: $(BUILD)/kernel$(SUFFIX).img
+ @$(CP) $< /home/$(USER)/Documents/code/pi_tinyusb/boot_cpy
diff --git a/hw/bsp/raspberrypi4/boards/raspberrypi_cm4/board.mk b/hw/bsp/raspberrypi4/boards/raspberrypi_cm4/board.mk
deleted file mode 100644
index 897342479..000000000
--- a/hw/bsp/raspberrypi4/boards/raspberrypi_cm4/board.mk
+++ /dev/null
@@ -1 +0,0 @@
-CFLAGS += -DBCM_VERSION=2711
diff --git a/hw/mcu/broadcom b/hw/mcu/broadcom
-Subproject 5bff1d5e02c37c38ee1e5cf3f7fe82fdc7e1517
+Subproject 08370086080759ed54ac1136d62d2ad24c6fa26