mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2025-04-21 12:27:27 +03:00
clean-serial-c-into-drivers.patch
Move serial.c into drivers/serial-s3c24xx.c and qi-serial.h into include/serial-s3c24xx.h making things a bit cleaner for being s3c24xx-specific. This needed a lot of meddling additionally, ending up with a new puts() callback that belongs in the board structure and removal of the debug uart member, since the puts() action was the only user. Also change serial init API name and function to only fix to 115kbps and adapt to PCLK. Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <qi.h>
|
||||
#include <i2c-bitbang.h>
|
||||
#include <ports-s3c24xx.h>
|
||||
|
||||
static char i2c_read_sda_s3c24xx(void)
|
||||
{
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
*/
|
||||
|
||||
#include <qi.h>
|
||||
#include "blink_led.h"
|
||||
#include <serial-s3c24xx.h>
|
||||
|
||||
void serial_init (const int uart, const int ubrdiv_val)
|
||||
void serial_init_115200_s3c24xx(const int uart, const int pclk_MHz)
|
||||
{
|
||||
int div = (((54 * pclk_MHz) + (pclk_MHz / 2)) / 100) -1;
|
||||
switch(uart)
|
||||
{
|
||||
case UART0:
|
||||
@@ -32,20 +33,20 @@ void serial_init (const int uart, const int ubrdiv_val)
|
||||
rUCON0 = 0x245;
|
||||
rUFCON0 = 0x0;
|
||||
rUMCON0 = 0x0;
|
||||
rUBRDIV0 = ubrdiv_val;
|
||||
rUBRDIV0 = div;
|
||||
break;
|
||||
case UART1:
|
||||
rULCON1 = 0x3;
|
||||
rUCON1 = 0x245;
|
||||
rUFCON1 = 0x0;
|
||||
rUMCON1 = 0x0;
|
||||
rUBRDIV1 = ubrdiv_val;
|
||||
rUBRDIV1 = div;
|
||||
break;
|
||||
case UART2:
|
||||
rULCON2 = 0x3;
|
||||
rUCON2 = 0x245;
|
||||
rUFCON2 = 0x1;
|
||||
rUBRDIV2 = ubrdiv_val;
|
||||
rUBRDIV2 = div;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -54,7 +55,7 @@ void serial_init (const int uart, const int ubrdiv_val)
|
||||
/*
|
||||
* Output a single byte to the serial port.
|
||||
*/
|
||||
void serial_putc (const int uart, const char c)
|
||||
void serial_putc_s3c24xx(const int uart, const char c)
|
||||
{
|
||||
switch(uart)
|
||||
{
|
||||
@@ -25,8 +25,12 @@
|
||||
|
||||
#include <qi.h>
|
||||
#include <neo_gta02.h>
|
||||
#include <serial-s3c24xx.h>
|
||||
#include <ports-s3c24xx.h>
|
||||
#include <i2c-bitbang-s3c24xx.h>
|
||||
|
||||
#define GTA02_DEBUG_UART 2
|
||||
|
||||
#define PCF50633_I2C_ADS 0x73
|
||||
|
||||
static const struct board_variant board_variants[] = {
|
||||
@@ -180,11 +184,11 @@ void port_init_gta02(void)
|
||||
"nop\n"\
|
||||
"nop\n"\
|
||||
"nop\n"\
|
||||
);
|
||||
);
|
||||
/* configure MPLL */
|
||||
*MPLLCON = ((42 << 12) + (1 << 4) + 0);
|
||||
|
||||
serial_init(UART2, (((54 * 50) + 50) / 100) -1);
|
||||
serial_init_115200_s3c24xx(GTA02_DEBUG_UART, 50 /* 50MHz PCLK */);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,13 +258,17 @@ const struct board_variant const * get_board_variant_gta02(void)
|
||||
return &board_variants[gta02_get_pcb_revision()];
|
||||
}
|
||||
|
||||
static void putc_gta02(char c)
|
||||
{
|
||||
serial_putc_s3c24xx(GTA02_DEBUG_UART, c);
|
||||
}
|
||||
|
||||
/*
|
||||
* our API for bootloader on this machine
|
||||
*/
|
||||
|
||||
const struct board_api board_api_gta02 = {
|
||||
.name = "Freerunner / GTA02",
|
||||
.debug_serial_port = 2,
|
||||
.linux_machine_id = 1304,
|
||||
.linux_mem_start = 0x30000000,
|
||||
.linux_mem_size = (128 * 1024 * 1024),
|
||||
@@ -268,6 +276,7 @@ const struct board_api board_api_gta02 = {
|
||||
.get_board_variant = get_board_variant_gta02,
|
||||
.is_this_board = is_this_board_gta02,
|
||||
.port_init = port_init_gta02,
|
||||
.putc = putc_gta02,
|
||||
/* these are the ways we could boot GTA02 in order to try */
|
||||
.kernel_source = {
|
||||
[0] = {
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#include <qi.h>
|
||||
#include <neo_gta03.h>
|
||||
#include <serial-s3c24xx.h>
|
||||
#include <ports-s3c24xx.h>
|
||||
#include <i2c-bitbang-s3c24xx.h>
|
||||
|
||||
#define GTA03_DEBUG_UART 2
|
||||
|
||||
#define PCF50633_I2C_ADS 0x73
|
||||
|
||||
|
||||
static const struct board_variant board_variants[] = {
|
||||
[0] = {
|
||||
@@ -108,7 +116,7 @@ void port_init_gta03(void)
|
||||
rGPJCON = 0x02AAAAAA;
|
||||
rGPJUP = 0x1FFFF;
|
||||
|
||||
serial_init(UART2, 0x11);
|
||||
serial_init_115200_s3c24xx(GTA03_DEBUG_UART, 33 /*MHz PCLK */);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,12 +169,18 @@ int is_this_board_gta03(void)
|
||||
/* FIXME: find something gta03 specific */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void putc_gta03(char c)
|
||||
{
|
||||
serial_putc_s3c24xx(GTA03_DEBUG_UART, c);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* our API for bootloader on this machine
|
||||
*/
|
||||
const struct board_api board_api_gta03 = {
|
||||
.name = "GTA03",
|
||||
.debug_serial_port = 2,
|
||||
.linux_machine_id = 1808,
|
||||
.linux_mem_start = 0x30000000,
|
||||
.linux_mem_size = (128 * 1024 * 1024),
|
||||
@@ -174,6 +188,7 @@ const struct board_api board_api_gta03 = {
|
||||
.get_board_variant = get_board_variant_gta03,
|
||||
.is_this_board = is_this_board_gta03,
|
||||
.port_init = port_init_gta03,
|
||||
.putc = putc_gta03,
|
||||
/* these are the ways we could boot GTA03 in order to try */
|
||||
.kernel_source = {
|
||||
[0] = {
|
||||
|
||||
@@ -71,13 +71,6 @@ static int is_bad_block(unsigned long i)
|
||||
NFCMD = NAND_CMD_READSTART;
|
||||
nand_wait();
|
||||
data = (NFDATA & 0xff);
|
||||
#ifdef DEBUG
|
||||
serial_putc(2, '$');
|
||||
serial_putc(2, '0');
|
||||
serial_putc(2, 'x');
|
||||
print32((unsigned int)data);
|
||||
serial_putc(2, ' ');
|
||||
#endif
|
||||
|
||||
if (data != 0xff)
|
||||
return 1;
|
||||
@@ -138,20 +131,11 @@ int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)
|
||||
if ((i & (NAND_BLOCK_SIZE - 1)) == 0) {
|
||||
if (is_bad_block(i) ||
|
||||
is_bad_block(i + NAND_PAGE_SIZE)) {
|
||||
serial_putc(2, '!');
|
||||
serial_putc(2, '0');
|
||||
serial_putc(2, 'x');
|
||||
print32((unsigned int)i);
|
||||
serial_putc(2, ' ');
|
||||
|
||||
i += NAND_BLOCK_SIZE;
|
||||
size += NAND_BLOCK_SIZE;
|
||||
if (bad_count++ == 4) {
|
||||
serial_putc(2, '+');
|
||||
serial_putc(2, '\n');
|
||||
if (bad_count++ == 4)
|
||||
return -1;
|
||||
}
|
||||
serial_putc(2, '\n');
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
.text :
|
||||
{
|
||||
src/start.o (.text .rodata* .data)
|
||||
src/lowlevel_init.o (.text .rodata* .data)
|
||||
src/start_qi.o (.text .rodata* .data)
|
||||
src/blink_led.o (.text .rodata* .data)
|
||||
src/nand_read.o (.text .rodata* .data)
|
||||
src/serial.o (.text .rodata* .data)
|
||||
src/start.o (.text .rodata* .data)
|
||||
src/lowlevel_init.o (.text .rodata* .data)
|
||||
src/start_qi.o (.text .rodata* .data)
|
||||
src/blink_led.o (.text .rodata* .data)
|
||||
src/nand_read.o (.text .rodata* .data)
|
||||
src/drivers/serial-s3c24xx.o (.text .rodata* .data)
|
||||
}
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -57,7 +57,7 @@ unsigned int _ntohl(unsigned int n) {
|
||||
int puts(const char *string)
|
||||
{
|
||||
while (*string)
|
||||
serial_putc(this_board->debug_serial_port, *string++);
|
||||
this_board->putc(*string++);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -66,9 +66,9 @@ int puts(const char *string)
|
||||
void printnybble(unsigned char n)
|
||||
{
|
||||
if (n < 10)
|
||||
serial_putc(this_board->debug_serial_port, '0' + n);
|
||||
this_board->putc('0' + n);
|
||||
else
|
||||
serial_putc(this_board->debug_serial_port, 'a' + n - 10);
|
||||
this_board->putc('a' + n - 10);
|
||||
}
|
||||
|
||||
void printhex(unsigned char n)
|
||||
@@ -91,13 +91,13 @@ void hexdump(unsigned char *start, int len)
|
||||
|
||||
while (len > 0) {
|
||||
print32((int)start);
|
||||
serial_putc(this_board->debug_serial_port, ':');
|
||||
serial_putc(this_board->debug_serial_port, ' ');
|
||||
this_board->putc(':');
|
||||
this_board->putc(' ');
|
||||
for (n = 0; n < 16; n++) {
|
||||
printhex(*start++);
|
||||
serial_putc(this_board->debug_serial_port, ' ');
|
||||
this_board->putc(' ');
|
||||
}
|
||||
serial_putc(this_board->debug_serial_port, '\n');
|
||||
this_board->putc('\n');
|
||||
len -= 16;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user