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
This commit is contained in:
Alexander von Gluck IV 2012-05-04 21:59:50 -05:00
parent b4a80cfb69
commit 52119b503d
10 changed files with 72 additions and 21 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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

View File

@ -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);
}

View File

@ -1,10 +1,14 @@
/*
* Copyright 2004-2008, Axel D??rfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*
* Copyright 2009 Jonas Sundström, jonas@kirilla.com
* 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');
}

View File

@ -116,7 +116,6 @@ pi_start(void)
mmu_init();
serial_init();
console_init();
serial_enable();
args.heap_size = HEAP_SIZE;
args.arguments = NULL;

View File

@ -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