[haiku-commits] haiku: hrev44107 - build/jam/board/raspberry_pi src/system/boot/platform/raspberrypi_arm

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 5 May 2012 05:01:48 +0200 (CEST)

hrev44107 adds 2 changesets to branch 'master'
old head: 116dab1616d5a9e7a5061afea80b724086ab9e69
new head: 52119b503daf22b8a998560c287414fe522477dc

----------------------------------------------------------------------------

b4a80cf: 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.

52119b5: Pi uart: Begin first attempts at UART communication on Pi.
  
  * Make Kernel ARM UART slightly more generic
    through (BOARD_UART_CLOCK) configured per board
  * Add initial Raspberry Pi serial code
  * Still rough and non-working

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

14 files changed, 146 insertions(+), 25 deletions(-)
build/jam/board/raspberry_pi/BoardSetup            |    3 -
build/jam/board/raspberry_pi/first32k.bin          |  Bin 0 -> 32768 bytes
.../kernel/arch/arm/board/beagle/board_config.h    |    6 ++
.../arch/arm/board/neo_freerunner/board_config.h   |    6 ++
.../kernel/arch/arm/board/overo/board_config.h     |    6 ++
.../arch/arm/board/raspberry_pi/board_config.h     |    7 ++-
.../kernel/arch/arm/board/verdex/board_config.h    |    6 ++
src/system/boot/platform/raspberrypi_arm/Jamfile   |    7 +--
src/system/boot/platform/raspberrypi_arm/gpio.cpp  |   25 +++++++++
src/system/boot/platform/raspberrypi_arm/gpio.h    |   38 +++++++++++++
.../boot/platform/raspberrypi_arm/serial.cpp       |   46 +++++++++++++---
src/system/boot/platform/raspberrypi_arm/serial.h  |    2 +-
src/system/boot/platform/raspberrypi_arm/start.c   |   14 ++++-
src/system/kernel/arch/arm/uart.cpp                |    5 +-

############################################################################

Commit:      b4a80cfb697dfa0d73b19d8a31b398fd918d70e1
URL:         http://cgit.haiku-os.org/haiku/commit/?id=b4a80cf
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Sat May  5 00:06:37 2012 UTC

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.

----------------------------------------------------------------------------

diff --git a/build/jam/board/raspberry_pi/BoardSetup 
b/build/jam/board/raspberry_pi/BoardSetup
index 795172f..5ecce07 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 0000000..ebf74be
Binary files /dev/null and b/build/jam/board/raspberry_pi/first32k.bin differ
diff --git a/src/system/boot/platform/raspberrypi_arm/Jamfile 
b/src/system/boot/platform/raspberrypi_arm/Jamfile
index b854c2b..13094f7 100644
--- a/src/system/boot/platform/raspberrypi_arm/Jamfile
+++ b/src/system/boot/platform/raspberrypi_arm/Jamfile
@@ -30,6 +30,7 @@ KernelMergeObject boot_platform_raspberrypi_arm.o :
        cpu.cpp
        debug.cpp
        devices.cpp
+       gpio.cpp
        keyboard.cpp
        menu.cpp
        mmu.cpp
diff --git a/src/system/boot/platform/raspberrypi_arm/gpio.cpp 
b/src/system/boot/platform/raspberrypi_arm/gpio.cpp
new file mode 100644
index 0000000..daba364
--- /dev/null
+++ b/src/system/boot/platform/raspberrypi_arm/gpio.cpp
@@ -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@xxxxxxxxxxx
+ */
+
+
+#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);
+       }
+}
diff --git a/src/system/boot/platform/raspberrypi_arm/gpio.h 
b/src/system/boot/platform/raspberrypi_arm/gpio.h
new file mode 100644
index 0000000..da0f952
--- /dev/null
+++ b/src/system/boot/platform/raspberrypi_arm/gpio.h
@@ -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@xxxxxxxxxxx
+ */
+#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 */
diff --git a/src/system/boot/platform/raspberrypi_arm/serial.h 
b/src/system/boot/platform/raspberrypi_arm/serial.h
index e6d2c04..6004f5a 100644
--- a/src/system/boot/platform/raspberrypi_arm/serial.h
+++ b/src/system/boot/platform/raspberrypi_arm/serial.h
@@ -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 */
diff --git a/src/system/boot/platform/raspberrypi_arm/start.c 
b/src/system/boot/platform/raspberrypi_arm/start.c
index 8e95321..9ba3598 100644
--- a/src/system/boot/platform/raspberrypi_arm/start.c
+++ b/src/system/boot/platform/raspberrypi_arm/start.c
@@ -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();

############################################################################

Revision:    hrev44107
Commit:      52119b503daf22b8a998560c287414fe522477dc
URL:         http://cgit.haiku-os.org/haiku/commit/?id=52119b5
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Sat May  5 02:59:50 2012 UTC

Pi uart: Begin first attempts at UART communication on Pi.

* Make Kernel ARM UART slightly more generic
  through (BOARD_UART_CLOCK) configured per board
* Add initial Raspberry Pi serial code
* Still rough and non-working

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/arch/arm/board/beagle/board_config.h 
b/headers/private/kernel/arch/arm/board/beagle/board_config.h
index 00b01fa..3c6c97a 100644
--- a/headers/private/kernel/arch/arm/board/beagle/board_config.h
+++ b/headers/private/kernel/arch/arm/board/beagle/board_config.h
@@ -5,6 +5,7 @@
 #ifndef _BOARD_OVERO_BOARD_CONFIG_H
 #define _BOARD_OVERO_BOARD_CONFIG_H
 
+
 #define BOARD_NAME_PRETTY "Beagle Board"
 
 #define BOARD_CPU_TYPE_OMAP 1
@@ -12,10 +13,15 @@
 
 #include <arch/arm/omap3.h>
 
+// UART Settings
 #define BOARD_UART1_BASE OMAP_UART1_BASE
 #define BOARD_UART2_BASE OMAP_UART2_BASE
 #define BOARD_UART3_BASE OMAP_UART3_BASE
 
 #define BOARD_DEBUG_UART 2
 
+#define BOARD_UART_CLOCK 48000000
+       // 48MHz (APLL96/2)
+
+
 #endif /* _BOARD_OVERO_BOARD_CONFIG_H */
diff --git 
a/headers/private/kernel/arch/arm/board/neo_freerunner/board_config.h 
b/headers/private/kernel/arch/arm/board/neo_freerunner/board_config.h
index 706401b..eda0ab4 100644
--- a/headers/private/kernel/arch/arm/board/neo_freerunner/board_config.h
+++ b/headers/private/kernel/arch/arm/board/neo_freerunner/board_config.h
@@ -5,6 +5,7 @@
 #ifndef _BOARD_FREERUNNER_BOARD_CONFIG_H
 #define _BOARD_FREERUNNER_BOARD_CONFIG_H
 
+
 #define BOARD_NAME_PRETTY "Openmoko Neo FreeRunner"
 
 #define BOARD_CPU_TYPE_ARM9 1
@@ -12,10 +13,15 @@
 
 #include <arch/arm/arm920t.h>
 
+// UART Settings
 #define BOARD_UART1_BASE UART0_BASE
 #define BOARD_UART2_BASE UART1_BASE
 #define BOARD_UART3_BASE UART2_BASE
 
 #define BOARD_DEBUG_UART 2
 
+#define BOARD_UART_CLOCK 48000000
+       // 48MHz (APLL96/2)
+
+
 #endif /* _BOARD_FREERUNNER_BOARD_CONFIG_H */
diff --git a/headers/private/kernel/arch/arm/board/overo/board_config.h 
b/headers/private/kernel/arch/arm/board/overo/board_config.h
index 8781e4d..2816fe6 100644
--- a/headers/private/kernel/arch/arm/board/overo/board_config.h
+++ b/headers/private/kernel/arch/arm/board/overo/board_config.h
@@ -5,6 +5,7 @@
 #ifndef _BOARD_OVERO_BOARD_CONFIG_H
 #define _BOARD_OVERO_BOARD_CONFIG_H
 
+
 #define BOARD_NAME_PRETTY "Gumstix Overo"
 
 #define BOARD_CPU_TYPE_OMAP 1
@@ -12,10 +13,15 @@
 
 #include <arch/arm/omap3.h>
 
+// UART Settings
 #define BOARD_UART1_BASE OMAP_UART1_BASE
 #define BOARD_UART2_BASE OMAP_UART2_BASE
 #define BOARD_UART3_BASE OMAP_UART3_BASE
 
 #define BOARD_DEBUG_UART 2
 
+#define BOARD_UART_CLOCK 48000000
+       // 48MHz (APLL96/2)
+
+
 #endif /* _BOARD_OVERO_BOARD_CONFIG_H */
diff --git a/headers/private/kernel/arch/arm/board/raspberry_pi/board_config.h 
b/headers/private/kernel/arch/arm/board/raspberry_pi/board_config.h
index afbbd76..33b72ed 100644
--- a/headers/private/kernel/arch/arm/board/raspberry_pi/board_config.h
+++ b/headers/private/kernel/arch/arm/board/raspberry_pi/board_config.h
@@ -15,12 +15,15 @@
 
 #include <arch/arm/bcm2708.h>
 
+// UART Settings
 #define BOARD_UART1_BASE UART0_BASE
 #define BOARD_UART2_BASE UART1_BASE
-#define BOARD_UART3_BASE UART1_BASE
-#warning NO UART3!!!
+#define BOARD_UART3_BASE 0
 
 #define BOARD_DEBUG_UART 0
 
+#define BOARD_UART_CLOCK 125000000
+       /* 125Mhz, strange */
+
 
 #endif /* _BOARD_RASPBERRY_PI_BOARD_CONFIG_H */
diff --git a/headers/private/kernel/arch/arm/board/verdex/board_config.h 
b/headers/private/kernel/arch/arm/board/verdex/board_config.h
index 4f490d4..dfc83d5 100644
--- a/headers/private/kernel/arch/arm/board/verdex/board_config.h
+++ b/headers/private/kernel/arch/arm/board/verdex/board_config.h
@@ -5,6 +5,7 @@
 #ifndef _BOARD_VERDEX_BOARD_CONFIG_H
 #define _BOARD_VERDEX_BOARD_CONFIG_H
 
+
 #define BOARD_NAME_PRETTY "Gumstix Verdex"
 
 #define BOARD_CPU_TYPE_PXA 1
@@ -12,10 +13,15 @@
 
 #include <arch/arm/pxa270.h>
 
+// UART Settings
 #define BOARD_UART1_BASE FFUART_BASE
 #define BOARD_UART2_BASE BTUART_BASE
 #define BOARD_UART3_BASE STUART_BASE
 
 #define BOARD_DEBUG_UART 0
 
+#define BOARD_UART_CLOCK 48000000
+       // 48MHz (APLL96/2)
+
+
 #endif /* _BOARD_VERDEX_BOARD_CONFIG_H */
diff --git a/src/system/boot/platform/raspberrypi_arm/Jamfile 
b/src/system/boot/platform/raspberrypi_arm/Jamfile
index 13094f7..036c5df 100644
--- a/src/system/boot/platform/raspberrypi_arm/Jamfile
+++ b/src/system/boot/platform/raspberrypi_arm/Jamfile
@@ -17,12 +17,6 @@ UsePrivateHeaders [ FDirName storage ] ;
 
 SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons accelerants common ] ;
 
-local genericPlatformSources =
-       text_menu.cpp
-#      video_blit.cpp
-#      video_splash.cpp
-;
-
 KernelMergeObject boot_platform_raspberrypi_arm.o :
        entry.S
        start.c
diff --git a/src/system/boot/platform/raspberrypi_arm/gpio.cpp 
b/src/system/boot/platform/raspberrypi_arm/gpio.cpp
index daba364..ed6fa1f 100644
--- a/src/system/boot/platform/raspberrypi_arm/gpio.cpp
+++ b/src/system/boot/platform/raspberrypi_arm/gpio.cpp
@@ -16,9 +16,9 @@ gpio_init()
        // Set up pointer to Raspberry Pi GPIO base
        gGPIOBase = (volatile unsigned *)GPIO_BASE;
 
-       // Take control of general use pins, status led, uart
+       // Take control of ok led and general use pins
        int pin = 0;
-       for (pin = 14; pin <= 25; pin++) {
+       for (pin = 16; pin <= 25; pin++) {
                GPIO_IN(pin);
                GPIO_OUT(pin);
        }
diff --git a/src/system/boot/platform/raspberrypi_arm/serial.cpp 
b/src/system/boot/platform/raspberrypi_arm/serial.cpp
index 4c8d121..85efbc0 100644
--- a/src/system/boot/platform/raspberrypi_arm/serial.cpp
+++ b/src/system/boot/platform/raspberrypi_arm/serial.cpp
@@ -1,10 +1,14 @@
 /*
+ * Copyright 2004-2008, Axel D??rfler, axeld@xxxxxxxxxxxxxxxxx
+ * Distributed under the terms of the MIT License.
+ *
  * Copyright 2009 Jonas Sundström, jonas@xxxxxxxxxxx
  * All rights reserved. Distributed under the terms of the MIT License.
  */
 
 
 #include "serial.h"
+#include "uart.h"
 
 #include <boot/platform.h>
 #include <arch/cpu.h>
@@ -13,31 +17,57 @@
 #include <string.h>
 
 
+static int32 sSerialEnabled = 0;
+
+static char sBuffer[16384];
+static uint32 sBufferPosition;
+
+
 static void
 serial_putc(char c)
 {
-#warning IMPLEMENT serial_putc
+       uart_putc(uart_debug_port(), c);
 }
 
 
 extern "C" void
 serial_puts(const char* string, size_t size)
 {
-#warning IMPLEMENT serial_puts
+       if (sSerialEnabled <= 0)
+               return;
+
+       if (sBufferPosition + size < sizeof(sBuffer)) {
+               memcpy(sBuffer + sBufferPosition, string, size);
+               sBufferPosition += size;
+       }
+
+       while (size-- != 0) {
+               char c = string[0];
+
+               if (c == '\n') {
+                       serial_putc('\r');
+                       serial_putc('\n');
+               } else if (c != '\r')
+                       serial_putc(c);
+
+               string++;
+       }
 }
 
 
-extern "C" void 
+extern "C" void
 serial_disable(void)
 {
-#warning IMPLEMENT serial_disable
+       sSerialEnabled--;
 }
 
 
-extern "C" void 
+extern "C" void
 serial_enable(void)
 {
-#warning IMPLEMENT serial_enable
+       uart_init_early();
+       uart_init();
+       sSerialEnabled++;
 }
 
 
@@ -51,6 +81,8 @@ serial_cleanup(void)
 extern "C" void
 serial_init(void)
 {
-#warning IMPLEMENT serial_init
+       serial_enable();
+
+       serial_putc('S');
 }
 
diff --git a/src/system/boot/platform/raspberrypi_arm/start.c 
b/src/system/boot/platform/raspberrypi_arm/start.c
index 9ba3598..f90c1ca 100644
--- a/src/system/boot/platform/raspberrypi_arm/start.c
+++ b/src/system/boot/platform/raspberrypi_arm/start.c
@@ -116,7 +116,6 @@ pi_start(void)
        mmu_init();
        serial_init();
        console_init();
-       serial_enable();
 
        args.heap_size = HEAP_SIZE;
        args.arguments = NULL;
diff --git a/src/system/kernel/arch/arm/uart.cpp 
b/src/system/kernel/arch/arm/uart.cpp
index d05263c..cc383f3 100644
--- a/src/system/kernel/arch/arm/uart.cpp
+++ b/src/system/kernel/arch/arm/uart.cpp
@@ -95,18 +95,17 @@ static inline unsigned char read_uart_reg(int port, uint 
reg)
 #define MCRVAL (MCR_DTR | MCR_RTS)     /* RTS/DTR */
 #define FCRVAL (FCR_FIFO_EN | FCR_RXSR | FCR_TXSR) /* Clear & enable FIFOs */
 
-#define V_NS16550_CLK            (48000000) /* 48MHz (APLL96/2) */
-
 
 int uart_debug_port(void)
 {
        return DEBUG_UART;
 }
 
+
 void uart_init_port(int port, uint baud)
 {
        /* clear the tx & rx fifo and disable */
-       uint16 baud_divisor = (V_NS16550_CLK / 16 / baud);
+       uint16 baud_divisor = (BOARD_UART_CLOCK / 16 / baud);
 
        write_uart_reg(port, UART_IER, 0);
        write_uart_reg(port, UART_LCR, LCR_BKSE | LCRVAL); // config mode A


Other related posts:

  • » [haiku-commits] haiku: hrev44107 - build/jam/board/raspberry_pi src/system/boot/platform/raspberrypi_arm - kallisti5