u-boot/board/bf533-stamp/bf533-stamp.c

278 lines
5.8 KiB
C
Raw Normal View History

2006-03-12 01:12:27 +00:00
/*
* U-boot - stamp.c STAMP board specific routines
*
* Copyright (c) 2005-2007 Analog Devices Inc.
2006-03-12 01:12:27 +00:00
*
* (C) Copyright 2000-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* 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., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301 USA
2006-03-12 01:12:27 +00:00
*/
#include <common.h>
#include <asm/mem_init.h>
2007-03-11 16:25:14 +00:00
#include <asm/io.h>
#include "bf533-stamp.h"
DECLARE_GLOBAL_DATA_PTR;
2006-03-12 01:12:27 +00:00
#define STATUS_LED_OFF 0
2006-03-12 01:55:22 +00:00
#define STATUS_LED_ON 1
2006-03-12 01:12:27 +00:00
#ifdef CONFIG_SHOW_BOOT_PROGRESS
# define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
#else
2006-03-12 01:55:22 +00:00
# define SHOW_BOOT_PROGRESS(arg)
2006-03-12 01:12:27 +00:00
#endif
int checkboard(void)
2006-03-12 01:12:27 +00:00
{
#if (BFIN_CPU == ADSP_BF531)
printf("CPU: ADSP BF531 Rev.: 0.%d\n", *pCHIPID >> 28);
#elif (BFIN_CPU == ADSP_BF532)
printf("CPU: ADSP BF532 Rev.: 0.%d\n", *pCHIPID >> 28);
#else
printf("CPU: ADSP BF533 Rev.: 0.%d\n", *pCHIPID >> 28);
#endif
printf("Board: ADI BF533 Stamp board\n");
printf(" Support: http://blackfin.uclinux.org/\n");
2006-03-12 01:12:27 +00:00
return 0;
}
long int initdram(int board_type)
2006-03-12 01:12:27 +00:00
{
#ifdef DEBUG
printf("SDRAM attributes:\n");
printf
(" tRCD:%d Cycles; tRP:%d Cycles; tRAS:%d Cycles; tWR:%d Cycles; "
"CAS Latency:%d cycles\n", (SDRAM_tRCD >> 15), (SDRAM_tRP >> 11),
(SDRAM_tRAS >> 6), (SDRAM_tWR >> 19), (SDRAM_CL >> 2));
printf("SDRAM Begin: 0x%x\n", CFG_SDRAM_BASE);
printf("Bank size = %d MB\n", 128);
2006-03-12 01:12:27 +00:00
#endif
gd->bd->bi_memstart = CFG_SDRAM_BASE;
gd->bd->bi_memsize = CFG_MAX_RAM_SIZE;
return (gd->bd->bi_memsize);
}
void swap_to(int device_id)
2006-03-12 01:12:27 +00:00
{
2006-03-12 01:55:22 +00:00
if (device_id == ETHERNET) {
2006-03-12 01:12:27 +00:00
*pFIO_DIR = PF0;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
*pFIO_FLAG_S = PF0;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:55:22 +00:00
} else if (device_id == FLASH) {
2006-03-12 01:12:27 +00:00
*pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
2006-03-12 01:55:22 +00:00
*pFIO_FLAG_S = (PF4 | PF3 | PF2);
2006-03-12 01:12:27 +00:00
*pFIO_MASKA_D = (PF8 | PF6 | PF5);
*pFIO_MASKB_D = (PF7);
2006-03-12 01:55:22 +00:00
*pFIO_POLAR = (PF8 | PF6 | PF5);
2006-03-12 01:12:27 +00:00
*pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
*pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
2006-03-12 01:55:22 +00:00
*pFIO_FLAG_D = (PF4 | PF3 | PF2);
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:55:22 +00:00
} else {
printf("Unknown bank to switch\n");
2006-03-12 01:12:27 +00:00
}
2006-03-12 01:55:22 +00:00
2006-03-12 01:12:27 +00:00
return;
}
#if defined(CONFIG_MISC_INIT_R)
/* miscellaneous platform dependent initialisations */
int misc_init_r(void)
2006-03-12 01:12:27 +00:00
{
int i;
int cf_stat = 0;
/* Check whether CF card is inserted */
*pFIO_EDGE = FIO_EDGE_CF_BITS;
*pFIO_POLAR = FIO_POLAR_CF_BITS;
2006-03-12 01:55:22 +00:00
for (i = 0; i < 0x300; i++)
asm("nop;");
2006-03-12 01:55:22 +00:00
if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
2006-03-12 01:12:27 +00:00
cf_stat = 0;
2006-03-12 01:55:22 +00:00
} else {
2006-03-12 01:12:27 +00:00
cf_stat = 1;
}
2006-03-12 01:55:22 +00:00
*pFIO_EDGE = FIO_EDGE_BITS;
2006-03-12 01:12:27 +00:00
*pFIO_POLAR = FIO_POLAR_BITS;
2006-03-12 01:55:22 +00:00
if (cf_stat) {
printf("Booting from COMPACT flash\n");
2006-03-12 01:12:27 +00:00
/* Set cycle time for CF */
*(volatile unsigned long *)ambctl1 = CF_AMBCTL1VAL;
2006-03-12 01:12:27 +00:00
2006-03-12 01:55:22 +00:00
for (i = 0; i < 0x1000; i++)
asm("nop;");
2006-03-12 01:55:22 +00:00
for (i = 0; i < 0x1000; i++)
asm("nop;");
2006-03-12 01:55:22 +00:00
for (i = 0; i < 0x1000; i++)
asm("nop;");
2006-03-12 01:12:27 +00:00
serial_setbrg();
ide_init();
2006-03-12 01:12:27 +00:00
setenv("bootargs", "");
setenv("bootcmd",
"fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
2006-03-12 01:55:22 +00:00
} else {
printf("Booting from FLASH\n");
2006-03-12 01:12:27 +00:00
}
return 0;
2006-03-12 01:12:27 +00:00
}
#endif
#ifdef CONFIG_STAMP_CF
void cf_outb(unsigned char val, volatile unsigned char *addr)
2006-03-12 01:12:27 +00:00
{
2006-03-12 01:55:22 +00:00
/*
2006-03-12 01:12:27 +00:00
* Set PF1 PF0 respectively to 0 1 to divert address
2006-03-12 01:55:22 +00:00
* to the expansion memory banks
2006-03-12 01:12:27 +00:00
*/
*pFIO_FLAG_S = CF_PF0;
*pFIO_FLAG_C = CF_PF1;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
*(addr) = val;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
2006-03-12 01:55:22 +00:00
/* Setback PF1 PF0 to 0 0 to address external
2006-03-12 01:12:27 +00:00
* memory banks */
*(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
}
unsigned char cf_inb(volatile unsigned char *addr)
2006-03-12 01:12:27 +00:00
{
volatile unsigned char c;
*pFIO_FLAG_S = CF_PF0;
*pFIO_FLAG_C = CF_PF1;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
c = *(addr);
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
*pFIO_FLAG_C = CF_PF1_PF0;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
return c;
}
void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
2006-03-12 01:12:27 +00:00
{
int i;
*pFIO_FLAG_S = CF_PF0;
*pFIO_FLAG_C = CF_PF1;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
2006-03-12 01:55:22 +00:00
for (i = 0; i < words; i++) {
2006-03-12 01:12:27 +00:00
*(sect_buf + i) = *(addr);
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
}
*pFIO_FLAG_C = CF_PF1_PF0;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
}
void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
2006-03-12 01:12:27 +00:00
{
int i;
*pFIO_FLAG_S = CF_PF0;
*pFIO_FLAG_C = CF_PF1;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
2006-03-12 01:55:22 +00:00
for (i = 0; i < words; i++) {
2006-03-12 01:12:27 +00:00
*(addr) = *(sect_buf + i);
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
}
*pFIO_FLAG_C = CF_PF1_PF0;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
}
#endif
void stamp_led_set(int LED1, int LED2, int LED3)
2006-03-12 01:12:27 +00:00
{
2006-03-12 01:55:22 +00:00
*pFIO_INEN &= ~(PF2 | PF3 | PF4);
*pFIO_DIR |= (PF2 | PF3 | PF4);
if (LED1 == STATUS_LED_OFF)
2006-03-12 01:12:27 +00:00
*pFIO_FLAG_S = PF2;
else
*pFIO_FLAG_C = PF2;
2006-03-12 01:55:22 +00:00
if (LED2 == STATUS_LED_OFF)
2006-03-12 01:12:27 +00:00
*pFIO_FLAG_S = PF3;
else
*pFIO_FLAG_C = PF3;
2006-03-12 01:55:22 +00:00
if (LED3 == STATUS_LED_OFF)
2006-03-12 01:12:27 +00:00
*pFIO_FLAG_S = PF4;
else
*pFIO_FLAG_C = PF4;
2007-03-11 16:25:14 +00:00
sync();
2006-03-12 01:12:27 +00:00
}
void show_boot_progress(int status)
2006-03-12 01:12:27 +00:00
{
2006-03-12 01:55:22 +00:00
switch (status) {
case 1:
stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
2006-03-12 01:55:22 +00:00
break;
case 2:
stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
2006-03-12 01:55:22 +00:00
break;
case 3:
stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
2006-03-12 01:55:22 +00:00
break;
case 4:
stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
2006-03-12 01:55:22 +00:00
break;
case 5:
case 6:
stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
2006-03-12 01:55:22 +00:00
break;
case 7:
case 8:
stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
2006-03-12 01:55:22 +00:00
break;
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
2006-03-12 01:55:22 +00:00
break;
default:
stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
2006-03-12 01:55:22 +00:00
break;
2006-03-12 01:12:27 +00:00
}
}