arm uart: Complete redesign of ARM uart code

* Add nested function wrappers to allow usage of other
  uart drivers depending on board. We may want to use this
  on other platforms at some point (haha, maybe)
This commit is contained in:
Alexander von Gluck IV
2012-05-06 17:03:33 -05:00
parent 95aae4ae1e
commit 917e9be1a6
14 changed files with 372 additions and 220 deletions
@@ -14,11 +14,13 @@
#include <arch/arm/omap3.h>
// UART Settings
#define BOARD_UART_8250 1
#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_DEBUG BOARD_UART3_BASE
#define BOARD_UART_CLOCK 48000000
// 48MHz (APLL96/2)
@@ -14,11 +14,13 @@
#include <arch/arm/arm920t.h>
// UART Settings
#define BOARD_UART_8250 1
#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_DEBUG BOARD_UART3_BASE
#define BOARD_UART_CLOCK 48000000
// 48MHz (APLL96/2)
@@ -14,11 +14,13 @@
#include <arch/arm/omap3.h>
// UART Settings
#define BOARD_UART_8250 1
#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_DEBUG BOARD_UART3_BASE
#define BOARD_UART_CLOCK 48000000
// 48MHz (APLL96/2)
@@ -16,11 +16,13 @@
#include <arch/arm/bcm2708.h>
// UART Settings
#define BOARD_UART_8250 1
#define BOARD_UART1_BASE UART0_BASE
#define BOARD_UART2_BASE UART1_BASE
#define BOARD_UART3_BASE 0
#define BOARD_DEBUG_UART 0
#define BOARD_UART_DEBUG BOARD_UART2_BASE
#define BOARD_UART_CLOCK 125000000
/* 125Mhz, strange */
@@ -14,11 +14,13 @@
#include <arch/arm/pxa270.h>
// UART Settings
#define BOARD_UART_8250 1
#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_DEBUG BOARD_UART1_BASE
#define BOARD_UART_CLOCK 48000000
// 48MHz (APLL96/2)
+28 -30
View File
@@ -1,47 +1,45 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
* Copyright 2011-2012 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* 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.
* Authors:
* Alexander von Gluck, [email protected]
*/
#ifndef __DEV_UART_H
#define __DEV_UART_H
//#include <sys/types.h>
#include <sys/types.h>
#include "uart_8250.h"
#ifdef __cplusplus
extern "C" {
#endif
void uart_init(void);
void uart_init_early(void);
int uart_debug_port(void);
struct uart_info {
addr_t base;
// Pointers to functions based on port type
void (*init)(addr_t base);
void (*init_early)(void);
void (*init_port)(addr_t base, uint baud);
int (*putc)(addr_t base, char c);
int (*getc)(addr_t base, bool wait);
void (*flush_tx)(addr_t base);
void (*flush_rx)(addr_t base);
};
uart_info* uart_create(void);
void uart_destroy();
addr_t uart_base_port(int port);
addr_t uart_debug_port(void);
int uart_putc(int port, char c);
int uart_getc(int port, bool wait);
void uart_flush_tx(int port);
void uart_flush_rx(int port);
void uart_init_port(int port, uint baud);
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* 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.
*/
#ifndef __DEV_UART_8250_H
#define __DEV_UART_8250_H
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
void uart_8250_init_port(addr_t base, uint baud);
void uart_8250_init_early(void);
void uart_8250_init(addr_t base);
int uart_8250_putc(addr_t base, char c);
int uart_8250_getc(addr_t base, bool wait);
void uart_8250_flush_tx(addr_t base);
void uart_8250_flush_rx(addr_t base);
#ifdef __cplusplus
}
#endif
#endif