summaryrefslogtreecommitdiff
path: root/board/csb226
diff options
context:
space:
mode:
authorwdenk <wdenk>2002-11-05 00:17:55 +0000
committerwdenk <wdenk>2002-11-05 00:17:55 +0000
commit384ae02506f0673070a3516b1858f058a07f85f3 (patch)
treeb85a18328375b06df150d630d400eb16c75090f4 /board/csb226
parente95b61cfb0c7203964c1a3f163e16a65f04d87ec (diff)
downloadu-boot-imx-384ae02506f0673070a3516b1858f058a07f85f3.zip
u-boot-imx-384ae02506f0673070a3516b1858f058a07f85f3.tar.gz
u-boot-imx-384ae02506f0673070a3516b1858f058a07f85f3.tar.bz2
* Patch by Robert Schwebel, 04 Nov 2002:
- use watchdog to reset PXA250 systems - added progress callbacks to (some of the) ARM code - update for Cogent CSB226 board * Add support for FPS860 board
Diffstat (limited to 'board/csb226')
-rw-r--r--board/csb226/csb226.c81
-rw-r--r--board/csb226/flash.c149
2 files changed, 158 insertions, 72 deletions
diff --git a/board/csb226/csb226.c b/board/csb226/csb226.c
index 1ed4034..0d99aa8 100644
--- a/board/csb226/csb226.c
+++ b/board/csb226/csb226.c
@@ -24,14 +24,25 @@
*/
#include <common.h>
+#include <asm/arch/pxa-regs.h>
-/* ------------------------------------------------------------------------- */
-
+#ifdef CONFIG_SHOW_BOOT_PROGRESS
+# define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
+#else
+# define SHOW_BOOT_PROGRESS(arg)
+#endif
/*
* Miscelaneous platform dependent initialisations
*/
+
+/**
+ * board_init: - setup some data structures
+ *
+ * @return: 0 in case of success
+ */
+
int board_init (void)
{
DECLARE_GLOBAL_DATA_PTR;
@@ -48,6 +59,13 @@ int board_init (void)
return 0;
}
+
+/**
+ * dram_init: - setup dynamic RAM
+ *
+ * @return: 0 in case of success
+ */
+
int dram_init (void)
{
DECLARE_GLOBAL_DATA_PTR;
@@ -57,3 +75,62 @@ int dram_init (void)
return 0;
}
+
+
+/**
+ * csb226_set_led: - switch LEDs on or off
+ *
+ * @param led: LED to switch (0,1,2)
+ * @param state: switch on (1) or off (0)
+ */
+
+void csb226_set_led(int led, int state)
+{
+ switch(led) {
+
+ case 0: if (state==1) {
+ GPCR0 |= CSB226_USER_LED0;
+ } else if (state==0) {
+ GPSR0 |= CSB226_USER_LED0;
+ }
+ break;
+
+ case 1: if (state==1) {
+ GPCR0 |= CSB226_USER_LED1;
+ } else if (state==0) {
+ GPSR0 |= CSB226_USER_LED1;
+ }
+ break;
+
+ case 2: if (state==1) {
+ GPCR0 |= CSB226_USER_LED2;
+ } else if (state==0) {
+ GPSR0 |= CSB226_USER_LED2;
+ }
+ break;
+ }
+
+ return;
+}
+
+
+/**
+ * show_boot_progress: - indicate state of the boot process
+ *
+ * @param status: Status number - see README for details.
+ *
+ * The CSB226 does only have 3 LEDs, so we switch them on at the most
+ * important states (1, 5, 15).
+ */
+
+void show_boot_progress (int status)
+{
+ switch(status) {
+ case 1: csb226_set_led(0,1); break;
+ case 5: csb226_set_led(1,1); break;
+ case 15: csb226_set_led(2,1); break;
+ }
+
+ return;
+}
+
diff --git a/board/csb226/flash.c b/board/csb226/flash.c
index 0b95648..0b4e2f6 100644
--- a/board/csb226/flash.c
+++ b/board/csb226/flash.c
@@ -6,6 +6,9 @@
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
*
+ * (C) Copyright 2002
+ * Robert Schwebel, Pengutronix, <r.schwebel@pengutronix.de>
+ *
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -26,6 +29,7 @@
*/
#include <common.h>
+#include <asm/arch/pxa-regs.h>
#define FLASH_BANK_SIZE 0x02000000
#define MAIN_SECT_SIZE 0x40000 /* 2x16 = 256k per sector */
@@ -33,7 +37,10 @@
flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
-/*-----------------------------------------------------------------------
+/**
+ * flash_init: - initialize data structures for flash chips
+ *
+ * @return: size of the flash
*/
ulong flash_init(void)
@@ -41,8 +48,7 @@ ulong flash_init(void)
int i, j;
ulong size = 0;
- for (i = 0; i < CFG_MAX_FLASH_BANKS; i++)
- {
+ for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
ulong flashbase = 0;
flash_info[i].flash_id =
(INTEL_MANUFACT & FLASH_VENDMASK) |
@@ -51,8 +57,7 @@ ulong flash_init(void)
flash_info[i].sector_count = CFG_MAX_FLASH_SECT;
memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
- switch (i)
- {
+ switch (i) {
case 0:
flashbase = PHYS_FLASH_1;
break;
@@ -60,15 +65,13 @@ ulong flash_init(void)
panic("configured to many flash banks!\n");
break;
}
- for (j = 0; j < flash_info[i].sector_count; j++)
- {
+ for (j = 0; j < flash_info[i].sector_count; j++) {
flash_info[i].start[j] = flashbase + j*MAIN_SECT_SIZE;
}
size += flash_info[i].size;
}
- /* Protect monitor and environment sectors
- */
+ /* Protect monitor and environment sectors */
flash_protect(FLAG_PROTECT_SET,
CFG_FLASH_BASE,
CFG_FLASH_BASE + _armboot_end_data - _armboot_start,
@@ -82,16 +85,21 @@ ulong flash_init(void)
return size;
}
-/*-----------------------------------------------------------------------
+
+/**
+ * flash_print_info: - print information about the flash situation
+ *
+ * @param info:
*/
+
void flash_print_info (flash_info_t *info)
{
int i, j;
- for (j=0; j<CFG_MAX_FLASH_BANKS; j++)
- {
- switch (info->flash_id & FLASH_VENDMASK)
- {
+ for (j=0; j<CFG_MAX_FLASH_BANKS; j++) {
+
+ switch (info->flash_id & FLASH_VENDMASK) {
+
case (INTEL_MANUFACT & FLASH_VENDMASK):
printf("Intel: ");
break;
@@ -100,38 +108,35 @@ void flash_print_info (flash_info_t *info)
break;
}
- switch (info->flash_id & FLASH_TYPEMASK)
- {
+ switch (info->flash_id & FLASH_TYPEMASK) {
+
case (INTEL_ID_28F128J3 & FLASH_TYPEMASK):
printf("28F128J3 (128Mbit)\n");
break;
default:
printf("Unknown Chip Type\n");
- goto Done;
- break;
+ return;
}
printf(" Size: %ld MB in %d Sectors\n",
info->size >> 20, info->sector_count);
printf(" Sector Start Addresses:");
- for (i = 0; i < info->sector_count; i++)
- {
- if ((i % 5) == 0)
- {
- printf ("\n ");
- }
+ for (i = 0; i < info->sector_count; i++) {
+ if ((i % 5) == 0) printf ("\n ");
+
printf (" %08lX%s", info->start[i],
info->protect[i] ? " (RO)" : " ");
}
printf ("\n");
info++;
}
-
-Done:
}
-/*-----------------------------------------------------------------------
+
+/**
+ * flash_erase: - erase flash sectors
+ *
*/
int flash_erase (flash_info_t *info, int s_first, int s_last)
@@ -146,19 +151,15 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
return ERR_INVAL;
}
- if ((info->flash_id & FLASH_VENDMASK) !=
- (INTEL_MANUFACT & FLASH_VENDMASK)) {
+ if ((info->flash_id & FLASH_VENDMASK) != (INTEL_MANUFACT & FLASH_VENDMASK))
return ERR_UNKNOWN_FLASH_VENDOR;
- }
prot = 0;
for (sect=s_first; sect<=s_last; ++sect) {
- if (info->protect[sect]) {
- prot++;
+ if (info->protect[sect]) prot++;
}
- }
- if (prot)
- return ERR_PROTECTED;
+
+ if (prot) return ERR_PROTECTED;
/*
* Disable interrupts which might cause a timeout
@@ -178,57 +179,63 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
reset_timer_masked();
if (info->protect[sect] == 0) { /* not protected */
- /* vushort *addr = (vushort *)(info->start[sect]); */
- ushort *addr = (ushort *)(info->start[sect]);
+ u32 * volatile addr = (u32 * volatile)(info->start[sect]);
+
+ /* erase sector: */
+ /* The strata flashs are aligned side by side on */
+ /* the data bus, so we have to write the commands */
+ /* to both chips here: */
- *addr = 0x20; /* erase setup */
- *addr = 0xD0; /* erase confirm */
+ *addr = 0x00200020; /* erase setup */
+ *addr = 0x00D000D0; /* erase confirm */
- while ((*addr & 0x80) != 0x80) {
+ while ((*addr & 0x00800080) != 0x00800080) {
if (get_timer_masked() > CFG_FLASH_ERASE_TOUT) {
- *addr = 0xB0; /* suspend erase */
- *addr = 0xFF; /* reset to read mode */
+ *addr = 0x00B000B0; /* suspend erase*/
+ *addr = 0x00FF00FF; /* read mode */
rc = ERR_TIMOUT;
goto outahere;
}
}
- /* clear status register command */
- *addr = 0x50;
- /* reset to read mode */
- *addr = 0xFF;
+ *addr = 0x00500050; /* clear status register cmd. */
+ *addr = 0x00FF00FF; /* resest to read mode */
+
}
+
printf("ok.\n");
}
- if (ctrlc())
- printf("User Interrupt!\n");
+
+ if (ctrlc()) printf("User Interrupt!\n");
outahere:
/* allow flash to settle - wait 10 ms */
udelay_masked(10000);
- if (flag)
- enable_interrupts();
+ if (flag) enable_interrupts();
return rc;
}
-/*-----------------------------------------------------------------------
- * Copy memory to flash
+
+/**
+ * write_word: - copy memory to flash
+ *
+ * @param info:
+ * @param dest:
+ * @param data:
+ * @return:
*/
static int write_word (flash_info_t *info, ulong dest, ushort data)
{
- /* vushort *addr = (vushort *)dest, val; */
ushort *addr = (ushort *)dest, val;
int rc = ERR_OK;
int flag;
- /* Check if Flash is (sufficiently) erased
- */
- if ((*addr & data) != data)
- return ERR_NOT_ERASED;
+ /* Check if Flash is (sufficiently) erased */
+ if ((*addr & data) != data) return ERR_NOT_ERASED;
/*
* Disable interrupts which might cause a timeout
@@ -252,12 +259,10 @@ static int write_word (flash_info_t *info, ulong dest, ushort data)
reset_timer_masked();
/* wait while polling the status register */
- while(((val = *addr) & 0x80) != 0x80)
- {
+ while(((val = *addr) & 0x80) != 0x80) {
if (get_timer_masked() > CFG_FLASH_WRITE_TOUT) {
rc = ERR_TIMOUT;
- /* suspend program command */
- *addr = 0xB0;
+ *addr = 0xB0; /* suspend program command */
goto outahere;
}
}
@@ -285,17 +290,23 @@ static int write_word (flash_info_t *info, ulong dest, ushort data)
}
outahere:
- /* read array command */
- *addr = 0xFF;
- if (flag)
- enable_interrupts();
+ *addr = 0xFF; /* read array command */
+ if (flag) enable_interrupts();
return rc;
}
-/*-----------------------------------------------------------------------
- * Copy memory to flash.
+
+/**
+ * write_buf: - Copy memory to flash.
+ *
+ * @param info:
+ * @param src: source of copy transaction
+ * @param addr: where to copy to
+ * @param cnt: number of bytes to copy
+ *
+ * @return error code
*/
int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
@@ -344,9 +355,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
cnt -= 2;
}
- if (cnt == 0) {
- return ERR_OK;
- }
+ if (cnt == 0) return ERR_OK;
/*
* handle unaligned tail bytes