Commit 01026a6e authored by Gerald Van Baren's avatar Gerald Van Baren
Browse files

Merge git://www.denx.de/git/u-boot into uboot

parents 11abe45c 81a0ac62
......@@ -278,7 +278,7 @@ void m48_watchdog_arm(int usec)
/*
* U-Boot RTC support.
*/
void
int
rtc_get( struct rtc_time *tmp )
{
m48_tod_get(&tmp->tm_year,
......@@ -295,6 +295,8 @@ rtc_get( struct rtc_time *tmp )
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec );
#endif
return 0;
}
void
......
......@@ -170,9 +170,9 @@ long int initdram (int board_type)
/* ------------------------------------------------------------------------- */
/* stubs so we can print dates w/o any nvram RTC.*/
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
return;
return 0;
}
void rtc_set (struct rtc_time *tmp)
{
......
......@@ -182,7 +182,7 @@ static int get_century_flag(void)
return flag;
}
void rtc_get( struct rtc_time *tmp)
int rtc_get( struct rtc_time *tmp)
{
if (phantom_flag < 0)
phantom_flag = get_phantom_flag();
......@@ -250,6 +250,8 @@ void rtc_get( struct rtc_time *tmp)
tmp->tm_yday = 0;
tmp->tm_isdst= 0;
}
return 0;
}
void rtc_set( struct rtc_time *tmp )
......
......@@ -96,6 +96,25 @@ int board_early_init_f(void)
gpio_write_bit(CFG_GPIO_FLASH_WP, 1);
#if CONFIG_POST & CFG_POST_BSPEC1
gpio_write_bit(CFG_GPIO_HIGHSIDE, 1);
reg = 0; /* reuse as counter */
out_be32((void *)CFG_DSPIC_TEST_ADDR,
in_be32((void *)CFG_DSPIC_TEST_ADDR)
& ~CFG_DSPIC_TEST_MASK);
while (!gpio_read_in_bit(CFG_GPIO_DSPIC_READY) && reg++ < 1000) {
udelay(1000);
}
gpio_write_bit(CFG_GPIO_HIGHSIDE, 0);
if (gpio_read_in_bit(CFG_GPIO_DSPIC_READY)) {
/* set "boot error" flag */
out_be32((void *)CFG_DSPIC_TEST_ADDR,
in_be32((void *)CFG_DSPIC_TEST_ADDR) |
CFG_DSPIC_TEST_MASK);
}
#endif
/*
* Reset PHY's:
* The PHY's need a 2nd reset pulse, since the MDIO address is latched
......@@ -548,11 +567,13 @@ unsigned int board_video_init (void)
return CFG_LIME_BASE_0;
}
void board_backlight_switch (int flag)
#define DEFAULT_BRIGHTNESS 0x64
static void board_backlight_brightness(int brightness)
{
if (flag) {
if (brightness > 0) {
/* pwm duty, lamp on */
out_be32((void *)(CFG_FPGA_BASE_0 + 0x00000024), 0x64);
out_be32((void *)(CFG_FPGA_BASE_0 + 0x00000024), brightness);
out_be32((void *)(CFG_FPGA_BASE_0 + 0x00000020), 0x701);
} else {
/* lamp off */
......@@ -561,6 +582,22 @@ void board_backlight_switch (int flag)
}
}
void board_backlight_switch (int flag)
{
char * param;
int rc;
if (flag) {
param = getenv("brightness");
rc = param ? simple_strtol(param, NULL, 10) : -1;
if (rc < 0)
rc = DEFAULT_BRIGHTNESS;
} else {
rc = 0;
}
board_backlight_brightness(rc);
}
#if defined(CONFIG_CONSOLE_EXTRA_INFO)
/*
* Return text to be printed besides the logo.
......@@ -575,3 +612,8 @@ void video_get_info_str (int line_number, char *info)
}
#endif
#endif /* CONFIG_VIDEO */
void board_reset(void)
{
gpio_write_bit(CFG_GPIO_BOARD_RESET, 1);
}
......@@ -278,7 +278,7 @@ void m48_watchdog_arm(int usec)
/*
* U-Boot RTC support.
*/
void
int
rtc_get( struct rtc_time *tmp )
{
m48_tod_get(&tmp->tm_year,
......@@ -295,6 +295,8 @@ rtc_get( struct rtc_time *tmp )
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec );
#endif
return 0;
}
void
......
......@@ -545,11 +545,15 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
}
#ifdef CONFIG_LOGBUFFER
#ifndef CONFIG_ALT_LB_ADDR
kbd=gd->bd;
/* Prevent initrd from overwriting logbuffer */
if (initrd_high < (kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD))
initrd_high = kbd->bi_memsize-LOGBUFF_LEN-LOGBUFF_OVERHEAD;
debug ("## Logbuffer at 0x%08lX ", kbd->bi_memsize-LOGBUFF_LEN);
#else
debug ("## Logbuffer at 0x%08lX ", CONFIG_ALT_LB_ADDR);
#endif
#endif
/*
......
......@@ -59,14 +59,25 @@ static char buf[1024];
static unsigned console_loglevel = 3;
static unsigned default_message_loglevel = 4;
static unsigned log_version = 1;
#ifdef CONFIG_ALT_LB_ADDR
static volatile logbuff_t *log;
#else
static logbuff_t *log;
#endif
static char *lbuf;
void logbuff_init_ptrs (void)
{
unsigned long tag, post_word;
char *s;
#ifdef CONFIG_ALT_LB_ADDR
log = (logbuff_t *)CONFIG_ALT_LH_ADDR;
lbuf = (char *)CONFIG_ALT_LB_ADDR;
#else
log = (logbuff_t *)(gd->bd->bi_memsize-LOGBUFF_LEN) - 1;
lbuf = log->buf;
#endif
/* Set up log version */
if ((s = getenv ("logversion")) != NULL)
......@@ -101,11 +112,26 @@ void logbuff_init_ptrs (void)
void logbuff_reset (void)
{
#ifndef CONFIG_ALT_LB_ADDR
memset (log, 0, sizeof (logbuff_t));
if (log_version == 2)
#endif
if (log_version == 2) {
log->v2.tag = LOGBUFF_MAGIC;
else
#ifdef CONFIG_ALT_LB_ADDR
log->v2.start = 0;
log->v2.con = 0;
log->v2.end = 0;
log->v2.chars = 0;
#endif
} else {
log->v1.tag = LOGBUFF_MAGIC;
#ifdef CONFIG_ALT_LB_ADDR
log->v1.dummy = 0;
log->v1.start = 0;
log->v1.size = 0;
log->v1.chars = 0;
#endif
}
}
int drv_logbuff_init (void)
......@@ -188,7 +214,7 @@ int do_log (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
size = log->v1.size;
}
for (i=0; i < (size&LOGBUFF_MASK); i++) {
s = (char *)log->buf+((start+i)&LOGBUFF_MASK);
s = lbuf+((start+i)&LOGBUFF_MASK);
putc (*s);
}
return 0;
......@@ -196,7 +222,7 @@ int do_log (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
logbuff_reset ();
return 0;
} else if (strcmp(argv[1],"info") == 0) {
printf ("Logbuffer at %08lx\n", (unsigned long)log->buf);
printf ("Logbuffer at %08lx\n", (unsigned long)lbuf);
if (log_version == 2) {
printf ("log_start = %08lx\n", log->v2.start);
printf ("log_end = %08lx\n", log->v2.end);
......@@ -257,14 +283,14 @@ static int logbuff_printk(const char *line)
line_feed = 0;
for (; p < buf_end; p++) {
if (log_version == 2) {
log->buf[log->v2.end & LOGBUFF_MASK] = *p;
lbuf[log->v2.end & LOGBUFF_MASK] = *p;
log->v2.end++;
if (log->v2.end - log->v2.start > LOGBUFF_LEN)
log->v2.start++;
log->v2.chars++;
}
else {
log->buf[(log->v1.start + log->v1.size) &
lbuf[(log->v1.start + log->v1.size) &
LOGBUFF_MASK] = *p;
if (log->v1.size < LOGBUFF_LEN)
log->v1.size++;
......
......@@ -40,7 +40,7 @@
#include <post.h>
#ifdef CONFIG_SILENT_CONSOLE
#if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST)
DECLARE_GLOBAL_DATA_PTR;
#endif
......@@ -369,6 +369,12 @@ void main_loop (void)
init_cmd_timeout ();
# endif /* CONFIG_BOOT_RETRY_TIME */
#ifdef CONFIG_POST
if (gd->flags & GD_FLG_POSTFAIL) {
s = getenv("failbootcmd");
}
else
#endif /* CONFIG_POST */
#ifdef CONFIG_BOOTCOUNT_LIMIT
if (bootlimit && (bootcount > bootlimit)) {
printf ("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n",
......
......@@ -155,7 +155,7 @@ int dcache_status (void)
#define HEX2BCD(x) ((((x) / 10) << 4) + (x) % 10)
#endif
void rtc_get (struct rtc_time* tm)
int rtc_get (struct rtc_time* tm)
{
RTCCON |= 1;
tm->tm_year = BCD2HEX(BCDYEAR);
......@@ -184,6 +184,8 @@ void rtc_get (struct rtc_time* tm)
tm->tm_year += 1900;
else
tm->tm_year += 2000;
return 0;
}
void rtc_set (struct rtc_time* tm)
......
......@@ -85,7 +85,7 @@ void rtc_set(struct rtc_time *tmp)
}
/* Read the time from the RTC_STAT. time_in_seconds is seconds since Jan 1970 */
void rtc_get(struct rtc_time *tmp)
int rtc_get(struct rtc_time *tmp)
{
uint32_t cur_rtc_stat;
int time_in_sec;
......@@ -95,7 +95,7 @@ void rtc_get(struct rtc_time *tmp)
if (tmp == NULL) {
puts("Error getting the date/time\n");
return;
return -1;
}
wait_for_complete();
......@@ -112,6 +112,8 @@ void rtc_get(struct rtc_time *tmp)
/* Calculate the total number of seconds since epoch */
time_in_sec = (tm_sec) + MIN_TO_SECS(tm_min) + HRS_TO_SECS(tm_hr) + DAYS_TO_SECS(tm_day);
to_tm(time_in_sec, tmp);
return 0;
}
#endif
......@@ -88,7 +88,7 @@ static unsigned char bin2bcd (unsigned int n)
/* ------------------------------------------------------------------------- */
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
uchar sec, min, hour, mday, wday, mon, year;
......@@ -150,6 +150,8 @@ else
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
#endif
return 0;
}
void rtc_set (struct rtc_time *tmp)
......
......@@ -253,9 +253,10 @@ rtc_reset(void)
/* TODO */
}
void
int
rtc_get(struct rtc_time *tmp)
{
int rel = 0;
struct ds1302_st bbclk;
if(!ds1302_initted) rtc_init();
......@@ -265,6 +266,7 @@ rtc_get(struct rtc_time *tmp)
if (bbclk.CH) {
printf("ds1302: rtc_get: Clock was halted, clock probably "
"corrupt\n");
rel = -1;
}
tmp->tm_sec=10*bbclk.sec10+bbclk.sec;
......@@ -281,6 +283,8 @@ rtc_get(struct rtc_time *tmp)
DPRINTF("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec );
return rel;
}
void
......
......@@ -91,7 +91,7 @@ static void init_spi (void);
/* ------------------------------------------------------------------------- */
/* read clock time from DS1306 and return it in *tmp */
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
volatile immap_t *immap = (immap_t *) CFG_IMMR;
unsigned char spi_byte; /* Data Byte */
......@@ -141,6 +141,8 @@ void rtc_get (struct rtc_time *tmp)
debug ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
return 0;
}
/* ------------------------------------------------------------------------- */
......@@ -304,7 +306,7 @@ static unsigned char rtc_read (unsigned char reg);
static void rtc_write (unsigned char reg, unsigned char val);
/* read clock time from DS1306 and return it in *tmp */
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
unsigned char sec, min, hour, mday, wday, mon, year;
......@@ -349,6 +351,8 @@ void rtc_get (struct rtc_time *tmp)
debug ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
return 0;
}
/* ------------------------------------------------------------------------- */
......
......@@ -83,8 +83,9 @@ static unsigned bcd2bin (uchar c);
/*
* Get the current time from the RTC
*/
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
int rel = 0;
uchar sec, min, hour, mday, wday, mon, year;
sec = rtc_read (RTC_SEC_REG_ADDR);
......@@ -104,6 +105,7 @@ void rtc_get (struct rtc_time *tmp)
/* clear the CH flag */
rtc_write (RTC_SEC_REG_ADDR,
rtc_read (RTC_SEC_REG_ADDR) & ~RTC_SEC_BIT_CH);
rel = -1;
}
tmp->tm_sec = bcd2bin (sec & 0x7F);
......@@ -119,6 +121,8 @@ void rtc_get (struct rtc_time *tmp)
DEBUGR ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
return rel;
}
......
......@@ -84,8 +84,9 @@ static unsigned bcd2bin (uchar c);
/*
* Get the current time from the RTC
*/
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
int rel = 0;
uchar sec, min, hour, mday, wday, mon_cent, year, control, status;
control = rtc_read (RTC_CTL_REG_ADDR);
......@@ -107,6 +108,7 @@ void rtc_get (struct rtc_time *tmp)
/* clear the OSF flag */
rtc_write (RTC_STAT_REG_ADDR,
rtc_read (RTC_STAT_REG_ADDR) & ~RTC_STAT_BIT_OSF);
rel = -1;
}
tmp->tm_sec = bcd2bin (sec & 0x7F);
......@@ -122,6 +124,8 @@ void rtc_get (struct rtc_time *tmp)
DEBUGR ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
return rel;
}
......
......@@ -107,8 +107,8 @@ static void rtc_write_raw (uchar reg, uchar val);
/*
* Get the current time from the RTC
*/
void rtc_get (struct rtc_time *tm){
int rtc_get (struct rtc_time *tm){
int rel = 0;
unsigned long time1, time2;
unsigned int limit;
unsigned char tmp;
......@@ -138,18 +138,23 @@ void rtc_get (struct rtc_time *tm){
if (time1 != time2) {
printf("can't get consistent time from rtc chip\n");
rel = -1;
}
DEBUGR ("Get RTC s since 1.1.1970: %d\n", time1);
to_tm(time1, tm); /* To Gregorian Date */
if (rtc_read(RTC_SR_ADDR) & RTC_SR_BIT_OSF)
if (rtc_read(RTC_SR_ADDR) & RTC_SR_BIT_OSF) {
printf ("### Warning: RTC oscillator has stopped\n");
rel = -1;
}
DEBUGR ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_wday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
return rel;
}
/*
......
......@@ -69,7 +69,7 @@ static unsigned bcd2bin(uchar c);
/* ------------------------------------------------------------------------- */
void rtc_get( struct rtc_time *tmp )
int rtc_get( struct rtc_time *tmp )
{
uchar sec, min, hour;
uchar mday, wday, mon, year;
......@@ -118,6 +118,7 @@ void rtc_get( struct rtc_time *tmp )
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec );
#endif
return 0;
}
void rtc_set( struct rtc_time *tmp )
......
......@@ -70,7 +70,7 @@ static unsigned bcd2bin(uchar c);
/* ------------------------------------------------------------------------- */
void rtc_get( struct rtc_time *tmp )
int rtc_get( struct rtc_time *tmp )
{
uchar sec, min, hour;
uchar mday, wday, mon, year;
......@@ -115,6 +115,8 @@ void rtc_get( struct rtc_time *tmp )
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec );
#endif
return 0;
}
void rtc_set( struct rtc_time *tmp )
......
......@@ -65,7 +65,7 @@ static unsigned bcd2bin(uchar c);
/* ------------------------------------------------------------------------- */
void rtc_get( struct rtc_time *tmp )
int rtc_get( struct rtc_time *tmp )
{
uchar sec, min, hour;
uchar mday, wday, mon, year;
......@@ -142,6 +142,8 @@ void rtc_set( struct rtc_time *tmp )
/* unlock clock registers after read */
rtc_write( RTC_CONTROLA, ( reg_a & ~RTC_CA_WRITE ));
return 0;
}
void rtc_reset (void)
......
......@@ -86,8 +86,9 @@ static unsigned bcd2bin (uchar c);
/*
* Get the current time from the RTC
*/
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
int rel = 0;
uchar sec, min, hour, mday, wday, mon_cent, year, control, status;
control = rtc_read (RTC_CTL_REG_ADDR);
......@@ -109,6 +110,7 @@ void rtc_get (struct rtc_time *tmp)
/* clear the OSF flag */
rtc_write (RTC_STAT_REG_ADDR,
rtc_read (RTC_STAT_REG_ADDR) & ~RTC_STAT_BIT_OSF);
rel = -1;
}
tmp->tm_sec = bcd2bin (sec & 0x7F);
......@@ -124,6 +126,8 @@ void rtc_get (struct rtc_time *tmp)
DEBUGR ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
return rel;
}
......
......@@ -73,8 +73,9 @@ static unsigned bcd2bin (uchar c);
* Get the current time from the RTC
*/
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
int rel = 0;
uchar sec, min, hour, mday, wday, mon, year, status;
status = rtc_read (RTC_STAT_REG_ADDR);
......@@ -94,6 +95,7 @@ void rtc_get (struct rtc_time *tmp)
printf ("### Warning: RTC oscillator has stopped\n");
rtc_write(RTC_STAT_REG_ADDR,
rtc_read(RTC_STAT_REG_ADDR) &~ (RTC_STAT_BIT_BAT|RTC_STAT_BIT_RTCF));
rel = -1;
}
tmp->tm_sec = bcd2bin (sec & 0x7F);
......@@ -109,6 +111,8 @@ void rtc_get (struct rtc_time *tmp)
DEBUGR ("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n",
tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
return rel;
}
/*
......
......@@ -96,14 +96,16 @@ static unsigned char bin2bcd (unsigned int n)
#define M41T11_STORAGE_SZ (64-REG_CNT)
void rtc_get (struct rtc_time *tmp)
int rtc_get (struct rtc_time *tmp)
{
int rel = 0;
uchar data[RTC_REG_CNT];
i2c_read(CFG_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, data, RTC_REG_CNT);
if( data[RTC_SEC_ADDR] & 0x80 ){