From b4a80cfb697dfa0d73b19d8a31b398fd918d70e1 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Fri, 4 May 2012 19:06:37 -0500 Subject: [PATCH] Pi: Add GPIO controls to Raspberry Pi Haiku Loader * When first32k.bin is added in front of haiku_loader, the OK led comes on verifying haiku_loader is actually running on the Pi. --- build/jam/board/raspberry_pi/BoardSetup | 3 -- build/jam/board/raspberry_pi/first32k.bin | Bin 0 -> 32768 bytes .../boot/platform/raspberrypi_arm/Jamfile | 1 + .../boot/platform/raspberrypi_arm/gpio.cpp | 25 ++++++++++++ .../boot/platform/raspberrypi_arm/gpio.h | 38 ++++++++++++++++++ .../boot/platform/raspberrypi_arm/serial.h | 2 +- .../boot/platform/raspberrypi_arm/start.c | 13 +++++- 7 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 build/jam/board/raspberry_pi/first32k.bin create mode 100644 src/system/boot/platform/raspberrypi_arm/gpio.cpp create mode 100644 src/system/boot/platform/raspberrypi_arm/gpio.h diff --git a/build/jam/board/raspberry_pi/BoardSetup b/build/jam/board/raspberry_pi/BoardSetup index 795172fb58..5ecce07b70 100644 --- a/build/jam/board/raspberry_pi/BoardSetup +++ b/build/jam/board/raspberry_pi/BoardSetup @@ -56,9 +56,6 @@ fi" ; HAIKU_BOARD_SDIMAGE_FILES = haiku_loader - haiku_loader.ub - haiku_loader_nbsd.ub - $(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME) ; diff --git a/build/jam/board/raspberry_pi/first32k.bin b/build/jam/board/raspberry_pi/first32k.bin new file mode 100644 index 0000000000000000000000000000000000000000..ebf74be8a1434d3e296b664136f9d51bc851647f GIT binary patch literal 32768 zcmeIuu?@md3 + + +// Macros for easy GPIO pin access in loader +#define GPIO_IN(g) *(gGPIOBase + ((g)/10)) &= ~(7<<(((g)%10)*3)) +#define GPIO_OUT(g) *(gGPIOBase + ((g)/10)) |= (1<<(((g)%10)*3)) +#define GPIO_SET(g) *(gGPIOBase + 7) = (1< #include @@ -33,6 +34,9 @@ extern int main(stage2_args *args); void _start(void); +volatile unsigned *gGPIOBase; + + static void clear_bss(void) { @@ -104,6 +108,11 @@ pi_start(void) call_ctors(); cpu_init(); + gpio_init(); + + // Flick on "OK" led + GPIO_CLR(16); + mmu_init(); serial_init(); console_init();