×
单片机 > 单片机程序设计 > 详情

TQ210 —— s5pv210 board.c分析(uboot第二阶段)

发布时间:2024-04-30 发布时间:
|

/*

* (C) Copyright 2002-2006

* Wolfgang Denk, DENX Software Engineering, wd@denx.de.

*

* (C) Copyright 2002

* Sysgo Real-Time Solutions, GmbH

* Marius Groeger

*

* See file CREDITS for list of people who contributed to this

* project.

*

* This program is free software; you can redistribute it and/or

* modify it under the terms of the GNU General Public License as

* published by the Free Software Foundation; either version 2 of

* the License, or (at your option) any later version.

*

* This program is distributed in the hope that it will be useful,

* but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

* GNU General Public License for more details.

*

* You should have received a copy of the GNU General Public License

* along with this program; if not, write to the Free Software

* Foundation, Inc., 59 Temple Place, Suite 330, Boston,

* MA 02111-1307 USA

*/

/*

* To match the U-Boot user interface on ARM platforms to the U-Boot

* standard (as on PPC platforms), some messages with debug character

* are removed from the default U-Boot build.

*

* Define DEBUG here if you want additional info as shown below

* printed upon startup:

*

* U-Boot code: 00F00000 -> 00F3C774 BSS: -> 00FC3274

* IRQ Stack: 00ebff7c

* FIQ Stack: 00ebef7c

*/

/*

* /lib_arm/board.c 主要完成了一些初始化的操作,最重要的是有start_armboot函数

*/

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#ifdef CONFIG_GENERIC_MMC

#include

#endif

#undef DEBUG

#ifdef CONFIG_DRIVER_SMC91111

#include "../drivers/net/smc91111.h"

#endif

#ifdef CONFIG_DRIVER_LAN91C96 /* 关于网卡的定义 */

#include "../drivers/net/lan91c96.h"

#endif

DECLARE_GLOBAL_DATA_PTR; /* 声明全局数据指针 */

void nand_init (void);

void onenand_init(void);

ulong monitor_flash_len;

#ifdef CONFIG_HAS_DATAFLASH

extern int AT91F_DataflashInit(void);

extern void dataflash_print_info(void);

#endif

#ifndef CONFIG_IDENT_STRING /* 没有定义CONFIG_IDENT_STRING,定义其为空 */

#define CONFIG_IDENT_STRING ""

#endif

const char version_string[] = /* 版本字符串 */

U_BOOT_VERSION CONFIG_IDENT_STRING;

#ifdef CONFIG_DRIVER_CS8900 /* 定义了CS8900网卡,获取网络地址 */

extern int cs8900_get_enetaddr (uchar * addr);

#endif

#ifdef CONFIG_DRIVER_RTL8019

extern void rtl8019_get_enetaddr (uchar * addr);

#endif

#if defined(CONFIG_HARD_I2C) ||

defined(CONFIG_SOFT_I2C)

#include

#endif

/*

* Begin and End of memory area for malloc(), and current "brk"

* 分配内存

*/

static ulong mem_malloc_start = 0;

static ulong mem_malloc_end = 0;

static ulong mem_malloc_brk = 0;

/* 内存分配初始化 */

static void mem_malloc_init (ulong dest_addr)

{

mem_malloc_start = dest_addr;

mem_malloc_end = dest_addr + CFG_MALLOC_LEN;

mem_malloc_brk = mem_malloc_start;

memset ((void *) mem_malloc_start, 0,

mem_malloc_end - mem_malloc_start);

}

/* 所分配内存区的brk指针调整 */

void *sbrk (ptrdiff_t increment)

{

ulong old = mem_malloc_brk;

ulong new = old + increment;

if ((new < mem_malloc_start) || (new > mem_malloc_end)) {

return (NULL);

}

mem_malloc_brk = new;

return ((void *) old);

}

char *strmhz(char *buf, long hz)

{

long l, n;

long m;

n = hz / 1000000L;

l = sprintf (buf, "%ld", n);

m = (hz % 1000000L) / 1000L;

if (m != 0)

sprintf (buf + l, ".%03ld", m);

return (buf);

}

/************************************************************************

* Coloured LED functionality

************************************************************************

* May be supplied by boards if desired

*/

void __coloured_LED_init (void) {}

void coloured_LED_init (void)

__attribute__((weak, alias("__coloured_LED_init")));

void __red_LED_on (void) {}

void red_LED_on (void)

__attribute__((weak, alias("__red_LED_on")));

void __red_LED_off(void) {}

void red_LED_off(void) __attribute__((weak, alias("__red_LED_off")));

void __green_LED_on(void) {}

void green_LED_on(void) __attribute__((weak, alias("__green_LED_on")));

void __green_LED_off(void) {}

void green_LED_off(void)__attribute__((weak, alias("__green_LED_off")));

void __yellow_LED_on(void) {}

void yellow_LED_on(void)__attribute__((weak, alias("__yellow_LED_on")));

void __yellow_LED_off(void) {}

void yellow_LED_off(void)__attribute__((weak, alias("__yellow_LED_off")));

/************************************************************************

* Init Utilities *

************************************************************************

* Some of this code should be moved into the core functions,

* or dropped completely,

* but let's get it working (again) first...

*/

#if 0

typedef struct global_data {

bd_t *bd; // 与板子相关的结构,见下面

unsigned long flags; // 指示标志,如设备已经初始化标志等

unsigned long baudrate; // 波特率

unsigned long have_console; /* serial_init() was called */

unsigned long reloc_off; /* Relocation Offset,重定位偏移,一般为0 */

unsigned long env_addr; /* Address of Environment struct ,存放环境变量结构的地址*/

unsigned long env_valid; /* 环境参数CRC检验有效标志 */

#ifdef CONFIG_VFD // 我们一般没有配置这个,这个是frame buffer的首地址

unsigned long fb_base; /* base address of frame buffer,显存缓存区 基址*/

#endif

void **jt; /* jump table ,保存着些函数的入口地址,在common/Exports.c中进行填充*/

} gd_t;

typedef struct bd_info {

int bi_baudrate; /* serial console baudrate ,串口波特率 */

unsigned long bi_ip_addr; /* IP Address ,IP地址*/

unsigned char bi_enetaddr[6]; /* Ethernet adress ,以太网MAC地址*/

struct environment_s *bi_env; /* 环境变量地址指针 */

ulong bi_arch_number; /* unique id for this board 架构号码*/

ulong bi_boot_params; /* where this board expects params启动参数 */

struct /* RAM configuration */

{

ulong start; /* RAM的起始地址 */

ulong size; /* RAM的大小 */

} bi_dram[CONFIG_NR_DRAM_BANKS];

} bd_t;

#endif

/* 初始化波特率 */

static int init_baudrate (void)

{

char tmp[64]; /* long enough for environment variables */

int i = getenv_r ("baudrate", tmp, sizeof (tmp));

gd->bd->bi_baudrate = gd->baudrate = (i > 0)

? (int) simple_strtoul (tmp, NULL, 10)

: CONFIG_BAUDRATE;

return (0);

}

/* 打开屏幕背光 */

static void open_backlight(void)

{

unsigned int reg;

//open backlight. GPF3_5=1

reg = readl(GPF3CON);

reg = reg & ~(0xf<<20) | (0x1<<20);

writel(reg,GPF3CON);

reg = readl(GPF3PUD);

reg = reg & ~(0x3<<10) | (0x2<<10);

writel(reg,GPF3PUD);

reg = readl(GPF3DAT);

reg |= (0x1<<5);

writel(reg,GPF3DAT);

}

/*

* GPC1_1: GPRS_PWR_EN

* GPJ0_4: CDMAPWR

* GPJ0_1: GSM_RST

* GPJ0_6: GSM_ON_OFF

*/

/* 打开GPRS */

static void open_gprs(void)

{

unsigned int i;

unsigned int reg;

//step0: init gpio

reg = readl(GPC1CON);

reg = reg & ~(0xf<<4) | (0x1<<4); //set GPC1_1 to output and enable pullup

writel(reg,GPC1CON);

reg = readl(GPC1PUD);

reg = reg & ~(0x3<<2) | (0x2<<2);

writel(reg,GPC1PUD);

reg = readl(GPJ0CON);

reg = reg & ~(0xf<<4) | (0x1<<4); //set GPJ0_1 to output and enable pullup

writel(reg,GPJ0CON);

reg = readl(GPJ0PUD);

reg = reg & ~(0x3<<2) | (0x2<<2);

writel(reg,GPJ0PUD);

reg = readl(GPJ0CON);

reg = reg & ~(0xf<<16) | (0x1<<16); //set GPJ0_4 to output and enable pullup

writel(reg,GPJ0CON);

reg = readl(GPJ0PUD);

reg = reg & ~(0x3<<8) | (0x2<<8);

writel(reg,GPJ0PUD);

reg = readl(GPJ0CON);

reg = reg & ~(0xf<<24) | (0x1<<24); //set GPJ0_6 to low level and enable pullup

writel(reg,GPJ0CON);

reg = readl(GPJ0PUD);

reg = reg & ~(0x3<<12) | (0x2<<12);

writel(reg,GPJ0PUD);

reg = readl(GPJ0DAT);

reg &= ~(0x1<<6);

writel(reg,GPJ0DAT);

//step1: disable reset

reg = readl(GPJ0DAT);

reg &= ~(0x1<<1);

writel(reg,GPJ0DAT);

//step2: enable GPRS power(4.2V to GPRS module)

reg = readl(GPC1DAT);

reg |= (0x1<<1);

writel(reg,GPC1DAT);

//step3: enable CDMAPWR(4.2V to GC864)

reg = readl(GPJ0DAT);

reg |= (0x1<<4);

writel(reg,GPJ0DAT);

for(i=0;i<100;i++)

udelay(1000);

//step4: power on GC864

reg = readl(GPJ0DAT);

reg |= (0x1<<6);

writel(reg,GPJ0DAT);

for(i=0;i<1000/*2000*/;i++)

udelay(1000);

reg &= ~(0x1<<6);

writel(reg,GPJ0DAT);

}

/* 一些显示函数。显示IRQ_STACK_START等的地址_armboot_start, _bss_start, _bss_end 这些值 */

static int display_banner (void)

{

printf("**********************************************************n");

printf ("************* %s *************n", vers

[1] [2] [3]
TQ210s5pv210boardc分析uboot第二阶段

『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
单片机的抗干扰措施有哪些