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.
This commit is contained in:
Alexander von Gluck IV 2012-05-04 19:06:37 -05:00
parent 116dab1616
commit b4a80cfb69
7 changed files with 76 additions and 6 deletions

View File

@ -56,9 +56,6 @@ fi" ;
HAIKU_BOARD_SDIMAGE_FILES =
haiku_loader
haiku_loader.ub
haiku_loader_nbsd.ub
$(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME)
;

Binary file not shown.

View File

@ -30,6 +30,7 @@ KernelMergeObject boot_platform_raspberrypi_arm.o :
cpu.cpp
debug.cpp
devices.cpp
gpio.cpp
keyboard.cpp
menu.cpp
mmu.cpp

View File

@ -0,0 +1,25 @@
/*
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck, kallisti5@unixzen.com
*/
#include "gpio.h"
void
gpio_init()
{
// Set up pointer to Raspberry Pi GPIO base
gGPIOBase = (volatile unsigned *)GPIO_BASE;
// Take control of general use pins, status led, uart
int pin = 0;
for (pin = 14; pin <= 25; pin++) {
GPIO_IN(pin);
GPIO_OUT(pin);
}
}

View File

@ -0,0 +1,38 @@
/*
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Alexander von Gluck, kallisti5@unixzen.com
*/
#ifndef _SYSTEM_BOOT_PLATFORM_PI_GPIO_H
#define _SYSTEM_BOOT_PLATFORM_PI_GPIO_H
#include <arch/arm/bcm2708.h>
// 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<<g)
#define GPIO_CLR(g) *(gGPIOBase + 10) = (1<<g)
volatile unsigned *gGPIOBase;
#ifdef __cplusplus
extern "C" {
#endif
void gpio_init();
#ifdef __cplusplus
}
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_PI_GPIO_H */

View File

@ -24,4 +24,4 @@ extern void serial_enable(void);
#endif
#endif /* _SYSTEM_BOOT_PLATFORM_ROUTERBOARD_MIPSEL_SERIAL_H */
#endif /* _SYSTEM_BOOT_PLATFORM_PI_SERIAL_H */

View File

@ -5,11 +5,12 @@
*/
#include "serial.h"
#include "console.h"
#include "cpu.h"
#include "mmu.h"
#include "gpio.h"
#include "keyboard.h"
#include "mmu.h"
#include "serial.h"
#include <KernelExport.h>
#include <boot/platform.h>
@ -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();