mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-23 00:25:55 +02: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:
parent
666089cd0a
commit
9eba09a86f
41
qiboot/include/ports-s3c24xx.h
Normal file
41
qiboot/include/ports-s3c24xx.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef __PORTS_S3C24XX_H__
|
||||||
|
#define __PORTS_S3C24XX_H__
|
||||||
|
|
||||||
|
|
||||||
|
// I/O PORT
|
||||||
|
#define rGPACON (*(volatile unsigned *)0x56000000)
|
||||||
|
#define rGPADAT (*(volatile unsigned *)0x56000004)
|
||||||
|
|
||||||
|
#define rGPBCON (*(volatile unsigned *)0x56000010)
|
||||||
|
#define rGPBDAT (*(volatile unsigned *)0x56000014)
|
||||||
|
#define rGPBUP (*(volatile unsigned *)0x56000018)
|
||||||
|
|
||||||
|
#define rGPCCON (*(volatile unsigned *)0x56000020)
|
||||||
|
#define rGPCDAT (*(volatile unsigned *)0x56000024)
|
||||||
|
#define rGPCUP (*(volatile unsigned *)0x56000028)
|
||||||
|
|
||||||
|
#define rGPDCON (*(volatile unsigned *)0x56000030)
|
||||||
|
#define rGPDDAT (*(volatile unsigned *)0x56000034)
|
||||||
|
#define rGPDUP (*(volatile unsigned *)0x56000038)
|
||||||
|
|
||||||
|
#define rGPECON (*(volatile unsigned *)0x56000040)
|
||||||
|
#define rGPEDAT (*(volatile unsigned *)0x56000044)
|
||||||
|
#define rGPEUP (*(volatile unsigned *)0x56000048)
|
||||||
|
|
||||||
|
#define rGPFCON (*(volatile unsigned *)0x56000050)
|
||||||
|
#define rGPFDAT (*(volatile unsigned *)0x56000054)
|
||||||
|
#define rGPFUP (*(volatile unsigned *)0x56000058)
|
||||||
|
|
||||||
|
#define rGPGCON (*(volatile unsigned *)0x56000060)
|
||||||
|
#define rGPGDAT (*(volatile unsigned *)0x56000064)
|
||||||
|
#define rGPGUP (*(volatile unsigned *)0x56000068)
|
||||||
|
|
||||||
|
#define rGPHCON (*(volatile unsigned *)0x56000070)
|
||||||
|
#define rGPHDAT (*(volatile unsigned *)0x56000074)
|
||||||
|
#define rGPHUP (*(volatile unsigned *)0x56000078)
|
||||||
|
|
||||||
|
#define rGPJCON (*(volatile unsigned *)0x560000d0) //Port J control
|
||||||
|
#define rGPJDAT (*(volatile unsigned *)0x560000d4) //Port J data
|
||||||
|
#define rGPJUP (*(volatile unsigned *)0x560000d8) //Port J data
|
||||||
|
|
||||||
|
#endif
|
@ -22,7 +22,6 @@
|
|||||||
#define __QI_H__
|
#define __QI_H__
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <qi-serial.h>
|
|
||||||
#include <qi-ctype.h>
|
#include <qi-ctype.h>
|
||||||
|
|
||||||
#define u32 unsigned int
|
#define u32 unsigned int
|
||||||
@ -62,7 +61,6 @@ struct board_variant {
|
|||||||
|
|
||||||
struct board_api {
|
struct board_api {
|
||||||
const char * name;
|
const char * name;
|
||||||
int debug_serial_port;
|
|
||||||
int linux_machine_id;
|
int linux_machine_id;
|
||||||
unsigned long linux_mem_start;
|
unsigned long linux_mem_start;
|
||||||
unsigned long linux_mem_size;
|
unsigned long linux_mem_size;
|
||||||
@ -70,6 +68,7 @@ struct board_api {
|
|||||||
const struct board_variant const * (*get_board_variant)(void);
|
const struct board_variant const * (*get_board_variant)(void);
|
||||||
int (*is_this_board)(void);
|
int (*is_this_board)(void);
|
||||||
void (*port_init)(void);
|
void (*port_init)(void);
|
||||||
|
void (*putc)(char);
|
||||||
struct kernel_source kernel_source[8];
|
struct kernel_source kernel_source[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __SERIAL_H__
|
#ifndef __SERIAL_S3C24XX_H__
|
||||||
#define __SERIAL_H__
|
#define __SERIAL_S3C24XX_H__
|
||||||
|
|
||||||
#define UART0 0
|
#define UART0 0
|
||||||
#define UART1 1
|
#define UART1 1
|
||||||
@ -65,47 +65,8 @@
|
|||||||
#define WrUTXH2(ch) (*(volatile unsigned char *)0x50008020)=(unsigned char)(ch)
|
#define WrUTXH2(ch) (*(volatile unsigned char *)0x50008020)=(unsigned char)(ch)
|
||||||
#define RdURXH2() (*(volatile unsigned char *)0x50008024)
|
#define RdURXH2() (*(volatile unsigned char *)0x50008024)
|
||||||
|
|
||||||
|
extern void serial_init_115200_s3c24xx(const int uart, const int pclk_MHz);
|
||||||
|
extern void serial_putc_s3c24xx(const int uart, const char c);
|
||||||
// I/O PORT
|
extern int puts(const char *string);
|
||||||
#define rGPACON (*(volatile unsigned *)0x56000000)
|
|
||||||
#define rGPADAT (*(volatile unsigned *)0x56000004)
|
|
||||||
|
|
||||||
#define rGPBCON (*(volatile unsigned *)0x56000010)
|
|
||||||
#define rGPBDAT (*(volatile unsigned *)0x56000014)
|
|
||||||
#define rGPBUP (*(volatile unsigned *)0x56000018)
|
|
||||||
|
|
||||||
#define rGPCCON (*(volatile unsigned *)0x56000020)
|
|
||||||
#define rGPCDAT (*(volatile unsigned *)0x56000024)
|
|
||||||
#define rGPCUP (*(volatile unsigned *)0x56000028)
|
|
||||||
|
|
||||||
#define rGPDCON (*(volatile unsigned *)0x56000030)
|
|
||||||
#define rGPDDAT (*(volatile unsigned *)0x56000034)
|
|
||||||
#define rGPDUP (*(volatile unsigned *)0x56000038)
|
|
||||||
|
|
||||||
#define rGPECON (*(volatile unsigned *)0x56000040)
|
|
||||||
#define rGPEDAT (*(volatile unsigned *)0x56000044)
|
|
||||||
#define rGPEUP (*(volatile unsigned *)0x56000048)
|
|
||||||
|
|
||||||
#define rGPFCON (*(volatile unsigned *)0x56000050)
|
|
||||||
#define rGPFDAT (*(volatile unsigned *)0x56000054)
|
|
||||||
#define rGPFUP (*(volatile unsigned *)0x56000058)
|
|
||||||
|
|
||||||
#define rGPGCON (*(volatile unsigned *)0x56000060)
|
|
||||||
#define rGPGDAT (*(volatile unsigned *)0x56000064)
|
|
||||||
#define rGPGUP (*(volatile unsigned *)0x56000068)
|
|
||||||
|
|
||||||
#define rGPHCON (*(volatile unsigned *)0x56000070)
|
|
||||||
#define rGPHDAT (*(volatile unsigned *)0x56000074)
|
|
||||||
#define rGPHUP (*(volatile unsigned *)0x56000078)
|
|
||||||
|
|
||||||
#define rGPJCON (*(volatile unsigned *)0x560000d0) //Port J control
|
|
||||||
#define rGPJDAT (*(volatile unsigned *)0x560000d4) //Port J data
|
|
||||||
#define rGPJUP (*(volatile unsigned *)0x560000d8) //Port J data
|
|
||||||
|
|
||||||
void serial_init(const int uart, const int ubrdiv_val);
|
|
||||||
void serial_putc(const int uart, const char c);
|
|
||||||
int printk(const char *fmt, ...);
|
|
||||||
int puts(const char *string);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <qi.h>
|
#include <qi.h>
|
||||||
#include <i2c-bitbang.h>
|
#include <i2c-bitbang.h>
|
||||||
|
#include <ports-s3c24xx.h>
|
||||||
|
|
||||||
static char i2c_read_sda_s3c24xx(void)
|
static char i2c_read_sda_s3c24xx(void)
|
||||||
{
|
{
|
||||||
|
@ -21,10 +21,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <qi.h>
|
#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)
|
switch(uart)
|
||||||
{
|
{
|
||||||
case UART0:
|
case UART0:
|
||||||
@ -32,20 +33,20 @@ void serial_init (const int uart, const int ubrdiv_val)
|
|||||||
rUCON0 = 0x245;
|
rUCON0 = 0x245;
|
||||||
rUFCON0 = 0x0;
|
rUFCON0 = 0x0;
|
||||||
rUMCON0 = 0x0;
|
rUMCON0 = 0x0;
|
||||||
rUBRDIV0 = ubrdiv_val;
|
rUBRDIV0 = div;
|
||||||
break;
|
break;
|
||||||
case UART1:
|
case UART1:
|
||||||
rULCON1 = 0x3;
|
rULCON1 = 0x3;
|
||||||
rUCON1 = 0x245;
|
rUCON1 = 0x245;
|
||||||
rUFCON1 = 0x0;
|
rUFCON1 = 0x0;
|
||||||
rUMCON1 = 0x0;
|
rUMCON1 = 0x0;
|
||||||
rUBRDIV1 = ubrdiv_val;
|
rUBRDIV1 = div;
|
||||||
break;
|
break;
|
||||||
case UART2:
|
case UART2:
|
||||||
rULCON2 = 0x3;
|
rULCON2 = 0x3;
|
||||||
rUCON2 = 0x245;
|
rUCON2 = 0x245;
|
||||||
rUFCON2 = 0x1;
|
rUFCON2 = 0x1;
|
||||||
rUBRDIV2 = ubrdiv_val;
|
rUBRDIV2 = div;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -54,7 +55,7 @@ void serial_init (const int uart, const int ubrdiv_val)
|
|||||||
/*
|
/*
|
||||||
* Output a single byte to the serial port.
|
* 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)
|
switch(uart)
|
||||||
{
|
{
|
@ -25,8 +25,12 @@
|
|||||||
|
|
||||||
#include <qi.h>
|
#include <qi.h>
|
||||||
#include <neo_gta02.h>
|
#include <neo_gta02.h>
|
||||||
|
#include <serial-s3c24xx.h>
|
||||||
|
#include <ports-s3c24xx.h>
|
||||||
#include <i2c-bitbang-s3c24xx.h>
|
#include <i2c-bitbang-s3c24xx.h>
|
||||||
|
|
||||||
|
#define GTA02_DEBUG_UART 2
|
||||||
|
|
||||||
#define PCF50633_I2C_ADS 0x73
|
#define PCF50633_I2C_ADS 0x73
|
||||||
|
|
||||||
static const struct board_variant board_variants[] = {
|
static const struct board_variant board_variants[] = {
|
||||||
@ -180,11 +184,11 @@ void port_init_gta02(void)
|
|||||||
"nop\n"\
|
"nop\n"\
|
||||||
"nop\n"\
|
"nop\n"\
|
||||||
"nop\n"\
|
"nop\n"\
|
||||||
);
|
);
|
||||||
/* configure MPLL */
|
/* configure MPLL */
|
||||||
*MPLLCON = ((42 << 12) + (1 << 4) + 0);
|
*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()];
|
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
|
* our API for bootloader on this machine
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const struct board_api board_api_gta02 = {
|
const struct board_api board_api_gta02 = {
|
||||||
.name = "Freerunner / GTA02",
|
.name = "Freerunner / GTA02",
|
||||||
.debug_serial_port = 2,
|
|
||||||
.linux_machine_id = 1304,
|
.linux_machine_id = 1304,
|
||||||
.linux_mem_start = 0x30000000,
|
.linux_mem_start = 0x30000000,
|
||||||
.linux_mem_size = (128 * 1024 * 1024),
|
.linux_mem_size = (128 * 1024 * 1024),
|
||||||
@ -268,6 +276,7 @@ const struct board_api board_api_gta02 = {
|
|||||||
.get_board_variant = get_board_variant_gta02,
|
.get_board_variant = get_board_variant_gta02,
|
||||||
.is_this_board = is_this_board_gta02,
|
.is_this_board = is_this_board_gta02,
|
||||||
.port_init = port_init_gta02,
|
.port_init = port_init_gta02,
|
||||||
|
.putc = putc_gta02,
|
||||||
/* these are the ways we could boot GTA02 in order to try */
|
/* these are the ways we could boot GTA02 in order to try */
|
||||||
.kernel_source = {
|
.kernel_source = {
|
||||||
[0] = {
|
[0] = {
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
#include <qi.h>
|
#include <qi.h>
|
||||||
#include <neo_gta03.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[] = {
|
static const struct board_variant board_variants[] = {
|
||||||
[0] = {
|
[0] = {
|
||||||
@ -108,7 +116,7 @@ void port_init_gta03(void)
|
|||||||
rGPJCON = 0x02AAAAAA;
|
rGPJCON = 0x02AAAAAA;
|
||||||
rGPJUP = 0x1FFFF;
|
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 */
|
/* FIXME: find something gta03 specific */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void putc_gta03(char c)
|
||||||
|
{
|
||||||
|
serial_putc_s3c24xx(GTA03_DEBUG_UART, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* our API for bootloader on this machine
|
* our API for bootloader on this machine
|
||||||
*/
|
*/
|
||||||
const struct board_api board_api_gta03 = {
|
const struct board_api board_api_gta03 = {
|
||||||
.name = "GTA03",
|
.name = "GTA03",
|
||||||
.debug_serial_port = 2,
|
|
||||||
.linux_machine_id = 1808,
|
.linux_machine_id = 1808,
|
||||||
.linux_mem_start = 0x30000000,
|
.linux_mem_start = 0x30000000,
|
||||||
.linux_mem_size = (128 * 1024 * 1024),
|
.linux_mem_size = (128 * 1024 * 1024),
|
||||||
@ -174,6 +188,7 @@ const struct board_api board_api_gta03 = {
|
|||||||
.get_board_variant = get_board_variant_gta03,
|
.get_board_variant = get_board_variant_gta03,
|
||||||
.is_this_board = is_this_board_gta03,
|
.is_this_board = is_this_board_gta03,
|
||||||
.port_init = port_init_gta03,
|
.port_init = port_init_gta03,
|
||||||
|
.putc = putc_gta03,
|
||||||
/* these are the ways we could boot GTA03 in order to try */
|
/* these are the ways we could boot GTA03 in order to try */
|
||||||
.kernel_source = {
|
.kernel_source = {
|
||||||
[0] = {
|
[0] = {
|
||||||
|
@ -71,13 +71,6 @@ static int is_bad_block(unsigned long i)
|
|||||||
NFCMD = NAND_CMD_READSTART;
|
NFCMD = NAND_CMD_READSTART;
|
||||||
nand_wait();
|
nand_wait();
|
||||||
data = (NFDATA & 0xff);
|
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)
|
if (data != 0xff)
|
||||||
return 1;
|
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 ((i & (NAND_BLOCK_SIZE - 1)) == 0) {
|
||||||
if (is_bad_block(i) ||
|
if (is_bad_block(i) ||
|
||||||
is_bad_block(i + NAND_PAGE_SIZE)) {
|
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;
|
i += NAND_BLOCK_SIZE;
|
||||||
size += NAND_BLOCK_SIZE;
|
size += NAND_BLOCK_SIZE;
|
||||||
if (bad_count++ == 4) {
|
if (bad_count++ == 4)
|
||||||
serial_putc(2, '+');
|
|
||||||
serial_putc(2, '\n');
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
serial_putc(2, '\n');
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,12 @@ SECTIONS
|
|||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
.text :
|
.text :
|
||||||
{
|
{
|
||||||
src/start.o (.text .rodata* .data)
|
src/start.o (.text .rodata* .data)
|
||||||
src/lowlevel_init.o (.text .rodata* .data)
|
src/lowlevel_init.o (.text .rodata* .data)
|
||||||
src/start_qi.o (.text .rodata* .data)
|
src/start_qi.o (.text .rodata* .data)
|
||||||
src/blink_led.o (.text .rodata* .data)
|
src/blink_led.o (.text .rodata* .data)
|
||||||
src/nand_read.o (.text .rodata* .data)
|
src/nand_read.o (.text .rodata* .data)
|
||||||
src/serial.o (.text .rodata* .data)
|
src/drivers/serial-s3c24xx.o (.text .rodata* .data)
|
||||||
}
|
}
|
||||||
|
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
|
@ -57,7 +57,7 @@ unsigned int _ntohl(unsigned int n) {
|
|||||||
int puts(const char *string)
|
int puts(const char *string)
|
||||||
{
|
{
|
||||||
while (*string)
|
while (*string)
|
||||||
serial_putc(this_board->debug_serial_port, *string++);
|
this_board->putc(*string++);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -66,9 +66,9 @@ int puts(const char *string)
|
|||||||
void printnybble(unsigned char n)
|
void printnybble(unsigned char n)
|
||||||
{
|
{
|
||||||
if (n < 10)
|
if (n < 10)
|
||||||
serial_putc(this_board->debug_serial_port, '0' + n);
|
this_board->putc('0' + n);
|
||||||
else
|
else
|
||||||
serial_putc(this_board->debug_serial_port, 'a' + n - 10);
|
this_board->putc('a' + n - 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printhex(unsigned char n)
|
void printhex(unsigned char n)
|
||||||
@ -91,13 +91,13 @@ void hexdump(unsigned char *start, int len)
|
|||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
print32((int)start);
|
print32((int)start);
|
||||||
serial_putc(this_board->debug_serial_port, ':');
|
this_board->putc(':');
|
||||||
serial_putc(this_board->debug_serial_port, ' ');
|
this_board->putc(' ');
|
||||||
for (n = 0; n < 16; n++) {
|
for (n = 0; n < 16; n++) {
|
||||||
printhex(*start++);
|
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;
|
len -= 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user