summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
Diffstat (limited to 'board')
-rw-r--r--board/alaska/flash.c37
-rw-r--r--board/c2mon/pcmcia.c8
-rw-r--r--board/cogent/flash.c3
-rw-r--r--board/eltec/mhpc/flash.c7
-rw-r--r--board/ep82xxm/ep82xxm.c3
-rw-r--r--board/esd/cpci5200/strataflash.c4
-rw-r--r--board/esd/pf5200/pf5200.c10
-rw-r--r--board/etin/kvme080/multiverse.c3
-rw-r--r--board/etx094/flash.c393
-rw-r--r--board/fads/fads.c4
-rw-r--r--board/freescale/mpc8266ads/mpc8266ads.c592
-rw-r--r--board/funkwerk/vovpn-gw/vovpn-gw.c3
-rw-r--r--board/genietv/flash.c366
-rw-r--r--board/gw8260/flash.c78
-rw-r--r--board/hymod/input.c3
-rw-r--r--board/icu862/flash.c32
-rw-r--r--board/icu862/pcmcia.c14
-rw-r--r--board/ids8247/ids8247.c3
-rw-r--r--board/kup/common/pcmcia.c42
-rw-r--r--board/kup/kup4k/kup4k.c3
-rw-r--r--board/linkstation/ide.c18
-rw-r--r--board/lwmon/pcmcia.c6
-rw-r--r--board/manroland/uc100/pcmcia.c50
-rw-r--r--board/mbx8xx/mbx8xx.c17
-rw-r--r--board/mbx8xx/pcmcia.c6
-rw-r--r--board/mcc200/auto_update.c7
-rw-r--r--board/mousse/flash.c8
-rw-r--r--board/mpl/common/flash.c15
-rw-r--r--board/netta/codec.c9
-rw-r--r--board/netta/pcmcia.c76
-rw-r--r--board/pm520/flash.c17
-rw-r--r--board/r360mpi/pcmcia.c4
-rw-r--r--board/rbc823/flash.c370
-rw-r--r--board/rpxsuper/flash.c46
-rw-r--r--board/sacsng/sacsng.c1327
-rw-r--r--board/siemens/SCM/scm.c3
-rw-r--r--board/svm_sc8xx/flash.c825
-rw-r--r--board/svm_sc8xx/svm_sc8xx.c5
-rw-r--r--board/tqc/tqm5200/cam5200_flash.c10
-rw-r--r--board/tqc/tqm5200/cmd_stk52xx.c23
-rw-r--r--board/tqc/tqm8272/tqm8272.c3
41 files changed, 2087 insertions, 2366 deletions
diff --git a/board/alaska/flash.c b/board/alaska/flash.c
index aed3b6f59c9..977822ac51e 100644
--- a/board/alaska/flash.c
+++ b/board/alaska/flash.c
@@ -406,7 +406,7 @@ static unsigned char same_chip_banks (int bank1, int bank2)
int flash_erase (flash_info_t * info, int s_first, int s_last)
{
int flag, prot, sect;
- ulong type, start, last;
+ ulong type, start;
int rcode = 0, intel = 0;
if ((s_first < 0) || (s_first > s_last)) {
@@ -444,7 +444,6 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
}
start = get_timer (0);
- last = start;
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts ();
@@ -501,6 +500,9 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
printf (" done\n");
}
}
+ if (flag)
+ enable_interrupts();
+
return rcode;
}
@@ -666,7 +668,7 @@ static int write_data (flash_info_t * info, ulong dest, FPW data)
{
FPWV *addr = (FPWV *) dest;
ulong start;
- int flag;
+ int flag, rc = 0;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
@@ -685,14 +687,18 @@ static int write_data (flash_info_t * info, ulong dest, FPW data)
/* wait while polling the status register */
while ((*addr & (FPW) 0x00800080) != (FPW) 0x00800080) {
if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- *addr = (FPW) 0x00FF00FF; /* restore read mode */
- return (1);
+ rc = 1;
+ goto OUT;
}
}
- *addr = (FPW) 0x00FF00FF; /* restore read mode */
+OUT:
+ *addr = (FPW)0x00FF00FF; /* restore read mode */
- return (0);
+ if (flag)
+ enable_interrupts();
+
+ return rc;
}
/*-----------------------------------------------------------------------
@@ -706,7 +712,7 @@ static int write_data_block (flash_info_t * info, ulong src, ulong dest)
FPWV *srcaddr = (FPWV *) src;
FPWV *dstaddr = (FPWV *) dest;
ulong start;
- int flag, i;
+ int flag, i, rc = 0;
/* Check if Flash is (sufficiently) erased */
for (i = 0; i < WR_BLOCK; i++)
@@ -727,10 +733,10 @@ static int write_data_block (flash_info_t * info, ulong src, ulong dest)
start = get_timer (0);
/* wait while polling the status register */
- while ((*dstaddr & (FPW) 0x00800080) != (FPW) 0x00800080) {
- if (get_timer (start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- *dstaddr = (FPW) 0x00FF00FF; /* restore read mode */
- return (1);
+ while ((*dstaddr & (FPW)0x00800080) != (FPW)0x00800080) {
+ if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
+ rc = 1;
+ goto OUT;
}
}
@@ -752,9 +758,12 @@ static int write_data_block (flash_info_t * info, ulong src, ulong dest)
}
}
- *dstaddr = (FPW) 0x00FF00FF; /* restore read mode */
+OUT:
+ *dstaddr = (FPW)0x00FF00FF; /* restore read mode */
+ if (flag)
+ enable_interrupts();
- return (0);
+ return rc;
}
/*-----------------------------------------------------------------------
diff --git a/board/c2mon/pcmcia.c b/board/c2mon/pcmcia.c
index c833b20b7be..2267829039c 100644
--- a/board/c2mon/pcmcia.c
+++ b/board/c2mon/pcmcia.c
@@ -199,7 +199,6 @@ int pcmcia_hardware_disable(int slot)
int pcmcia_voltage_set(int slot, int vcc, int vpp)
{
volatile immap_t *immap;
- volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
u_long reg;
ushort sreg;
@@ -210,12 +209,11 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
immap = (immap_t *)CONFIG_SYS_IMMR;
- cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
/*
- * Disable PCMCIA buffers (isolate the interface)
- * and assert RESET signal
- */
+ * Disable PCMCIA buffers (isolate the interface)
+ * and assert RESET signal
+ */
debug ("Disable PCMCIA buffers and assert RESET\n");
reg = PCMCIA_PGCRX(_slot_);
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
diff --git a/board/cogent/flash.c b/board/cogent/flash.c
index e6c85b6d9a5..ec3f94d2d5f 100644
--- a/board/cogent/flash.c
+++ b/board/cogent/flash.c
@@ -23,6 +23,7 @@
#include <common.h>
#include <board/cogent/flash.h>
+#include <linux/compiler.h>
flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
@@ -292,7 +293,7 @@ flash_init(void)
{
unsigned long total;
int i;
- flash_info_t *fip;
+ __maybe_unused flash_info_t *fip;
/* Init: no FLASHes known */
for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
diff --git a/board/eltec/mhpc/flash.c b/board/eltec/mhpc/flash.c
index 2fbdb277182..88313287f9f 100644
--- a/board/eltec/mhpc/flash.c
+++ b/board/eltec/mhpc/flash.c
@@ -311,7 +311,7 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
{
ulong cp, wp;
FPW data;
- int count, i, l, rc, port_width;
+ int i, l, rc, port_width;
if (info->flash_id == FLASH_UNKNOWN) {
return 4;
@@ -330,9 +330,9 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
*/
if ((l = addr - wp) != 0) {
data = 0;
- for (i=0, cp=wp; i<l; ++i, ++cp) {
+ for (i=0, cp=wp; i<l; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
+
for (; i<port_width && cnt>0; ++i) {
data = (data << 8) | *src++;
--cnt;
@@ -351,7 +351,6 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
/*
* handle word aligned part
*/
- count = 0;
while (cnt >= port_width) {
data = 0;
for (i=0; i<port_width; ++i) {
diff --git a/board/ep82xxm/ep82xxm.c b/board/ep82xxm/ep82xxm.c
index c1d6e9100ba..182cabca148 100644
--- a/board/ep82xxm/ep82xxm.c
+++ b/board/ep82xxm/ep82xxm.c
@@ -31,6 +31,7 @@
#include <pci.h>
#endif
#include <miiphy.h>
+#include <linux/compiler.h>
/*
* I/O Port configuration table
@@ -230,8 +231,8 @@ phys_size_t initdram(int board_type)
uint psdmr = CONFIG_SYS_PSDMR;
int i;
- unsigned char ramtmp;
unsigned char *ramptr1 = (unsigned char *)0x00000110;
+ __maybe_unused unsigned char ramtmp;
memctl->memc_mptpr = CONFIG_SYS_MPTPR;
diff --git a/board/esd/cpci5200/strataflash.c b/board/esd/cpci5200/strataflash.c
index 9b578b5f5ec..9de51f3eabe 100644
--- a/board/esd/cpci5200/strataflash.c
+++ b/board/esd/cpci5200/strataflash.c
@@ -678,12 +678,10 @@ static ulong flash_get_size(ulong base, int banknum)
static int flash_write_cfiword(flash_info_t * info, ulong dest, cfiword_t cword)
{
- cfiptr_t ctladdr;
cfiptr_t cptr;
int flag;
- ctladdr.cp = flash_make_addr(info, 0, 0);
- cptr.cp = (uchar *) dest;
+ cptr.cp = (uchar *)dest;
/* Check if Flash is (sufficiently) erased */
switch (info->portwidth) {
diff --git a/board/esd/pf5200/pf5200.c b/board/esd/pf5200/pf5200.c
index 83dbfcbbda0..2e07ac12093 100644
--- a/board/esd/pf5200/pf5200.c
+++ b/board/esd/pf5200/pf5200.c
@@ -327,13 +327,11 @@ int phypower(int flag)
int do_phypower(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
- int status;
+ if (argv[1][0] == '0')
+ (void)phypower(0);
+ else
+ (void)phypower(1);
- if (argv[1][0] == '0') {
- status = phypower(0);
- } else {
- status = phypower(1);
- }
return (0);
}
diff --git a/board/etin/kvme080/multiverse.c b/board/etin/kvme080/multiverse.c
index eb895817d5f..93ad57a2697 100644
--- a/board/etin/kvme080/multiverse.c
+++ b/board/etin/kvme080/multiverse.c
@@ -17,6 +17,7 @@
#include <common.h>
#include <asm/io.h>
#include <pci.h>
+#include <linux/compiler.h>
#include "multiverse.h"
@@ -103,7 +104,7 @@ int multiv_reset(unsigned long base)
void multiv_auto_slot_id(unsigned long base)
{
- unsigned int vector;
+ __maybe_unused unsigned int vector;
int slot_id = 1;
if (readb(base + VME_CTRL) & VME_CTRL_SYSFAIL) {
*(volatile unsigned int*)(base + VME_IRQ2_REG) = 0xfe;
diff --git a/board/etx094/flash.c b/board/etx094/flash.c
index fa51c90378b..0958e73d60c 100644
--- a/board/etx094/flash.c
+++ b/board/etx094/flash.c
@@ -24,68 +24,53 @@
#include <common.h>
#include <mpc8xx.h>
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
+flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
/*-----------------------------------------------------------------------
* Functions
*/
-static ulong flash_get_size (vu_long *addr, flash_info_t *info);
-static int write_word (flash_info_t *info, ulong dest, ulong data);
-static void flash_get_offsets (ulong base, flash_info_t *info);
+static ulong flash_get_size(vu_long *addr, flash_info_t *info);
+static int write_word(flash_info_t *info, ulong dest, ulong data);
+static void flash_get_offsets(ulong base, flash_info_t *info);
/*-----------------------------------------------------------------------
*/
-unsigned long flash_init (void)
+unsigned long flash_init(void)
{
volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
volatile memctl8xx_t *memctl = &immap->im_memctl;
- unsigned long size_b0, size_b1;
+ unsigned long size_b0;
int i;
/* Init: no FLASHes known */
- for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
+ for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
flash_info[i].flash_id = FLASH_UNKNOWN;
- }
/* Static FLASH Bank configuration here - FIXME XXX */
size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
if (flash_info[0].flash_id == FLASH_UNKNOWN) {
- printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
+ printf("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
size_b0, size_b0<<20);
}
- size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
-
- if (size_b1 > size_b0) {
- printf ("## ERROR: "
- "Bank 1 (0x%08lx = %ld MB) > Bank 0 (0x%08lx = %ld MB)\n",
- size_b1, size_b1<<20,
- size_b0, size_b0<<20
- );
- flash_info[0].flash_id = FLASH_UNKNOWN;
- flash_info[1].flash_id = FLASH_UNKNOWN;
- flash_info[0].sector_count = -1;
- flash_info[1].sector_count = -1;
- flash_info[0].size = 0;
- flash_info[1].size = 0;
- return (0);
- }
-
/* Remap FLASH according to real size */
memctl->memc_or0 = CONFIG_SYS_OR_TIMING_FLASH | (-size_b0 & 0xFFFF8000);
#ifdef CONFIG_FLASH_16BIT
- memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V | BR_PS_16; /* 16 Bit data port */
+ memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) |
+ BR_MS_GPCM | BR_V | BR_PS_16; /* 16 Bit data port */
#else
- memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V;
+ memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) |
+ BR_MS_GPCM | BR_V;
#endif
/* Re-do sizing to get full correct info */
- size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+ size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE,
+ &flash_info[0]);
- flash_get_offsets (CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+ flash_get_offsets(CONFIG_SYS_FLASH_BASE, &flash_info[0]);
#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
/* monitor protection ON by default */
@@ -95,56 +80,26 @@ unsigned long flash_init (void)
&flash_info[0]);
#endif
- if (size_b1) {
- memctl->memc_or1 = CONFIG_SYS_OR_TIMING_FLASH | (-size_b1 & 0xFFFF8000);
-#ifdef CONFIG_FLASH_16BIT
- memctl->memc_br1 = ((CONFIG_SYS_FLASH_BASE + size_b0) & BR_BA_MSK) |
- BR_MS_GPCM | BR_V | BR_PS_16;
-#else
- memctl->memc_br1 = ((CONFIG_SYS_FLASH_BASE + size_b0) & BR_BA_MSK) |
- BR_MS_GPCM | BR_V;
-#endif
-
- /* Re-do sizing to get full correct info */
- size_b1 = flash_get_size((vu_long *)(CONFIG_SYS_FLASH_BASE + size_b0),
- &flash_info[1]);
-
- flash_get_offsets (CONFIG_SYS_FLASH_BASE + size_b0, &flash_info[1]);
-
-#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
- /* monitor protection ON by default */
- flash_protect(FLAG_PROTECT_SET,
- CONFIG_SYS_MONITOR_BASE,
- CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
- &flash_info[1]);
-#endif
- } else {
- memctl->memc_br1 = 0; /* invalidate bank */
-
- flash_info[1].flash_id = FLASH_UNKNOWN;
- flash_info[1].sector_count = -1;
- }
+ memctl->memc_br1 = 0; /* invalidate bank 1 */
flash_info[0].size = size_b0;
- flash_info[1].size = size_b1;
- return (size_b0 + size_b1);
+ return size_b0;
}
/*-----------------------------------------------------------------------
*/
-static void flash_get_offsets (ulong base, flash_info_t *info)
+static void flash_get_offsets(ulong base, flash_info_t *info)
{
int i;
- if (info->flash_id == FLASH_UNKNOWN) {
+ if (info->flash_id == FLASH_UNKNOWN)
return;
- }
if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) {
- for (i = 0; i < info->sector_count; i++) {
+ for (i = 0; i < info->sector_count; i++)
info->start[i] = base + (i * 0x00002000);
- }
+
return;
}
@@ -156,106 +111,119 @@ static void flash_get_offsets (ulong base, flash_info_t *info)
info->start[1] = base + 0x00004000;
info->start[2] = base + 0x00006000;
info->start[3] = base + 0x00008000;
- for (i = 4; i < info->sector_count; i++) {
+ for (i = 4; i < info->sector_count; i++)
info->start[i] = base + (i * 0x00010000) - 0x00030000;
#else
info->start[0] = base + 0x00000000;
info->start[1] = base + 0x00008000;
info->start[2] = base + 0x0000C000;
info->start[3] = base + 0x00010000;
- for (i = 4; i < info->sector_count; i++) {
+ for (i = 4; i < info->sector_count; i++)
info->start[i] = base + (i * 0x00020000) - 0x00060000;
#endif
- }
} else {
/* set sector offsets for top boot block type */
i = info->sector_count - 1;
info->start[i--] = base + info->size - 0x00008000;
info->start[i--] = base + info->size - 0x0000C000;
info->start[i--] = base + info->size - 0x00010000;
- for (; i >= 0; i--) {
+ for (; i >= 0; i--)
info->start[i] = base + i * 0x00020000;
- }
}
-
}
/*-----------------------------------------------------------------------
*/
-void flash_print_info (flash_info_t *info)
+void flash_print_info(flash_info_t *info)
{
int i;
if (info->flash_id == FLASH_UNKNOWN) {
- printf ("missing or unknown FLASH type\n");
+ printf("missing or unknown FLASH type\n");
return;
}
switch (info->flash_id & FLASH_VENDMASK) {
- case FLASH_MAN_AMD: printf ("AMD "); break;
- case FLASH_MAN_FUJ: printf ("FUJITSU "); break;
- case FLASH_MAN_SST: printf ("SST "); break;
- case FLASH_MAN_STM: printf ("STM "); break;
- default: printf ("Unknown Vendor "); break;
+ case FLASH_MAN_AMD:
+ printf("AMD ");
+ break;
+ case FLASH_MAN_FUJ:
+ printf("FUJITSU ");
+ break;
+ case FLASH_MAN_SST:
+ printf("SST ");
+ break;
+ case FLASH_MAN_STM:
+ printf("STM ");
+ break;
+ default:
+ printf("Unknown Vendor ");
+ break;
}
switch (info->flash_id & FLASH_TYPEMASK) {
- case FLASH_AM400B: printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM400T: printf ("AM29LV400T (4 Mbit, top boot sector)\n");
- break;
- case FLASH_AM800B: printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM800T: printf ("AM29LV800T (8 Mbit, top boot sector)\n");
- break;
- case FLASH_AM160B: printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM160T: printf ("AM29LV160T (16 Mbit, top boot sector)\n");
- break;
- case FLASH_AM320B: printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM320T: printf ("AM29LV320T (32 Mbit, top boot sector)\n");
- break;
- case FLASH_SST200A: printf ("39xF200A (2M = 128K x 16)\n");
- break;
- case FLASH_SST400A: printf ("39xF400A (4M = 256K x 16)\n");
- break;
- case FLASH_SST800A: printf ("39xF800A (8M = 512K x 16)\n");
- break;
- case FLASH_STM800AB: printf ("M29W800AB (8M = 512K x 16)\n");
- break;
- default: printf ("Unknown Chip Type\n");
- break;
+ case FLASH_AM400B:
+ printf("AM29LV400B (4 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM400T:
+ printf("AM29LV400T (4 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM800B:
+ printf("AM29LV800B (8 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM800T:
+ printf("AM29LV800T (8 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM160B:
+ printf("AM29LV160B (16 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM160T:
+ printf("AM29LV160T (16 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM320B:
+ printf("AM29LV320B (32 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM320T:
+ printf("AM29LV320T (32 Mbit, top boot sector)\n");
+ break;
+ case FLASH_SST200A:
+ printf("39xF200A (2M = 128K x 16)\n");
+ break;
+ case FLASH_SST400A:
+ printf("39xF400A (4M = 256K x 16)\n");
+ break;
+ case FLASH_SST800A:
+ printf("39xF800A (8M = 512K x 16)\n");
+ break;
+ case FLASH_STM800AB:
+ printf("M29W800AB (8M = 512K x 16)\n");
+ break;
+ default:
+ printf("Unknown Chip Type\n");
+ break;
}
- printf (" Size: %ld MB in %d Sectors\n",
+ 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) {
+ printf(" Sector Start Addresses:");
+ for (i = 0; i < info->sector_count; ++i) {
if ((i % 5) == 0)
- printf ("\n ");
- printf (" %08lX%s",
+ printf("\n ");
+ printf(" %08lX%s",
info->start[i],
info->protect[i] ? " (RO)" : " "
);
}
- printf ("\n");
+ printf("\n");
return;
}
-/*-----------------------------------------------------------------------
- */
-
-
-/*-----------------------------------------------------------------------
- */
-
/*
* The following code cannot be run from FLASH!
*/
-static ulong flash_get_size (vu_long *addr, flash_info_t *info)
+static ulong flash_get_size(vu_long *addr, flash_info_t *info)
{
short i;
ulong value;
@@ -263,7 +231,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
/* Write auto select command: read Manufacturer ID */
#ifdef CONFIG_FLASH_16BIT
- vu_short *s_addr = (vu_short*)addr;
+ vu_short *s_addr = (vu_short *)addr;
s_addr[0x5555] = 0x00AA;
s_addr[0x2AAA] = 0x0055;
s_addr[0x5555] = 0x0090;
@@ -293,7 +261,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
info->flash_id = FLASH_UNKNOWN;
info->sector_count = 0;
info->size = 0;
- return (0); /* no or unknown flash */
+ return 0; /* no or unknown flash */
}
#ifdef CONFIG_FLASH_16BIT
value = s_addr[1];
@@ -349,32 +317,19 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
#endif
break;
-#if 0 /* enable when device IDs are available */
- case AMD_ID_LV320T:
- info->flash_id += FLASH_AM320T;
- info->sector_count = 67;
- info->size = 0x00800000;
- break; /* => 8 MB */
-
- case AMD_ID_LV320B:
- info->flash_id += FLASH_AM320B;
- info->sector_count = 67;
- info->size = 0x00800000;
- break; /* => 8 MB */
-#endif
case SST_ID_xF200A:
info->flash_id += FLASH_SST200A;
- info->sector_count = 64; /* 39xF200A ID ( 2M = 128K x 16 ) */
+ info->sector_count = 64; /* 39xF200A (2M = 128K x 16) */
info->size = 0x00080000;
break;
case SST_ID_xF400A:
info->flash_id += FLASH_SST400A;
- info->sector_count = 128; /* 39xF400A ID ( 4M = 256K x 16 ) */
+ info->sector_count = 128; /* 39xF400A (4M = 256K x 16) */
info->size = 0x00100000;
break;
case SST_ID_xF800A:
info->flash_id += FLASH_SST800A;
- info->sector_count = 256; /* 39xF800A ID ( 8M = 512K x 16 ) */
+ info->sector_count = 256; /* 39xF800A (8M = 512K x 16) */
info->size = 0x00200000;
break; /* => 2 MB */
case STM_ID_x800AB:
@@ -384,55 +339,55 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
break; /* => 2 MB */
default:
info->flash_id = FLASH_UNKNOWN;
- return (0); /* => no or unknown flash */
+ return 0; /* => no or unknown flash */
}
if (info->sector_count > CONFIG_SYS_MAX_FLASH_SECT) {
- printf ("** ERROR: sector count %d > max (%d) **\n",
+ printf("** ERROR: sector count %d > max (%d) **\n",
info->sector_count, CONFIG_SYS_MAX_FLASH_SECT);
info->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
}
if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) {
- for (i = 0; i < info->sector_count; i++) {
+ for (i = 0; i < info->sector_count; i++)
info->start[i] = base + (i * 0x00002000);
- }
} else { /* AMD and Fujitsu types */
/* set up sector start address table */
if (info->flash_id & FLASH_BTYPE) {
- /* set sector offsets for bottom boot block type */
+ /* set sector offsets for bottom boot block type */
#ifdef CONFIG_FLASH_16BIT
info->start[0] = base + 0x00000000;
info->start[1] = base + 0x00004000;
info->start[2] = base + 0x00006000;
info->start[3] = base + 0x00008000;
- for (i = 4; i < info->sector_count; i++) {
- info->start[i] = base + (i * 0x00010000) - 0x00030000;
+ for (i = 4; i < info->sector_count; i++)
+ info->start[i] = base +
+ (i * 0x00010000) - 0x00030000;
#else
info->start[0] = base + 0x00000000;
info->start[1] = base + 0x00008000;
info->start[2] = base + 0x0000C000;
info->start[3] = base + 0x00010000;
- for (i = 4; i < info->sector_count; i++) {
- info->start[i] = base + (i * 0x00020000) - 0x00060000;
+ for (i = 4; i < info->sector_count; i++)
+ info->start[i] = base +
+ (i * 0x00020000) - 0x00060000;
#endif
- }
} else {
- /* set sector offsets for top boot block type */
+ /* set sector offsets for top boot block type */
i = info->sector_count - 1;
info->start[i--] = base + info->size - 0x00008000;
info->start[i--] = base + info->size - 0x0000C000;
info->start[i--] = base + info->size - 0x00010000;
- for (; i >= 0; i--) {
+ for (; i >= 0; i--)
info->start[i] = base + i * 0x00020000;
- }
}
/* check for protected sectors */
for (i = 0; i < info->sector_count; i++) {
- /* read sector protection at sector address:
+ /*
+ * read sector protection at sector address:
* (A7 .. A0) = 0x02
* D0 = 1 if protected
*/
@@ -459,28 +414,23 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
#endif
}
- return (info->size);
+ return info->size;
}
-
-/*-----------------------------------------------------------------------
- */
-
-int flash_erase (flash_info_t *info, int s_first, int s_last)
+int flash_erase(flash_info_t *info, int s_first, int s_last)
{
- vu_long *addr = (vu_long*)(info->start[0]);
+ vu_long *addr = (vu_long *)(info->start[0]);
int flag, prot, sect;
ulong start, now, last;
#ifdef CONFIG_FLASH_16BIT
- vu_short *s_addr = (vu_short*)addr;
+ vu_short *s_addr = (vu_short *)addr;
#endif
if ((s_first < 0) || (s_first > s_last)) {
- if (info->flash_id == FLASH_UNKNOWN) {
- printf ("- missing\n");
- } else {
- printf ("- no sectors to erase\n");
- }
+ if (info->flash_id == FLASH_UNKNOWN)
+ printf("- missing\n");
+ else
+ printf("- no sectors to erase\n");
return 1;
}
/*#ifndef CONFIG_FLASH_16BIT
@@ -493,30 +443,29 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
}
#endif*/
prot = 0;
- for (sect=s_first; sect<=s_last; ++sect) {
- if (info->protect[sect]) {
+ for (sect = s_first; sect <= s_last; ++sect) {
+ if (info->protect[sect])
prot++;
- }
}
if (prot) {
- printf ("- Warning: %d protected sectors will not be erased!\n",
+ printf("- Warning: %d protected sectors will not be erased!\n",
prot);
} else {
- printf ("\n");
+ printf("\n");
}
- start = get_timer (0);
+ start = get_timer(0);
last = start;
/* Start erase on unprotected sectors */
- for (sect = s_first; sect<=s_last; sect++) {
+ for (sect = s_first; sect <= s_last; sect++) {
if (info->protect[sect] == 0) { /* not protected */
#ifdef CONFIG_FLASH_16BIT
- vu_short *s_sect_addr = (vu_short*)(info->start[sect]);
+ vu_short *s_sect_addr = (vu_short *)(info->start[sect]);
#else
- vu_long *sect_addr = (vu_long*)(info->start[sect]);
+ vu_long *sect_addr = (vu_long *)(info->start[sect]);
#endif
- /* Disable interrupts which might cause a timeout here */
+ /* Disable interrupts which might cause a timeout */
flag = disable_interrupts();
#ifdef CONFIG_FLASH_16BIT
@@ -541,20 +490,21 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
enable_interrupts();
/* wait at least 80us - let's wait 1 ms */
- udelay (1000);
+ udelay(1000);
#ifdef CONFIG_FLASH_16BIT
while ((s_sect_addr[0] & 0x0080) != 0x0080) {
#else
while ((sect_addr[0] & 0x00800080) != 0x00800080) {
#endif
- if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
- printf ("Timeout\n");
+ now = get_timer(start);
+ if (now > CONFIG_SYS_FLASH_ERASE_TOUT) {
+ printf("Timeout\n");
return 1;
}
- /* show that we're waiting */
- if ((now - last) > 1000) { /* every second */
- putc ('.');
+ /* show every second that we're waiting */
+ if ((now - last) > 1000) {
+ putc('.');
last = now;
}
}
@@ -569,7 +519,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
addr[0] = 0x00F000F0; /* reset bank */
#endif
- printf (" done\n");
+ printf(" done\n");
return 0;
}
@@ -581,37 +531,39 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
* 4 - Flash not identified
*/
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
{
ulong cp, wp, data;
int i, l, rc;
- if (info->flash_id == FLASH_UNKNOWN) {
+ if (info->flash_id == FLASH_UNKNOWN)
return 4;
- }
wp = (addr & ~3); /* get lower word aligned address */
/*
* handle unaligned start bytes
*/
- if ((l = addr - wp) != 0) {
+ l = addr - wp;
+
+ if (l != 0) {
data = 0;
- for (i=0, cp=wp; i<l; ++i, ++cp) {
+ for (i = 0, cp = wp; i < l; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- for (; i<4 && cnt>0; ++i) {
+
+ for (; i < 4 && cnt > 0; ++i) {
data = (data << 8) | *src++;
--cnt;
++cp;
}
- for (; cnt==0 && i<4; ++i, ++cp) {
+ for (; cnt == 0 && i < 4; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- if ((rc = write_word(info, wp, data)) != 0) {
- return (rc);
- }
+ rc = write_word(info, wp, data);
+
+ if (rc != 0)
+ return rc;
+
wp += 4;
}
@@ -620,33 +572,32 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
*/
while (cnt >= 4) {
data = 0;
- for (i=0; i<4; ++i) {
+ for (i = 0; i < 4; ++i)
data = (data << 8) | *src++;
- }
- if ((rc = write_word(info, wp, data)) != 0) {
- return (rc);
- }
+
+ rc = write_word(info, wp, data);
+ if (rc != 0)
+ return rc;
+
wp += 4;
cnt -= 4;
}
- if (cnt == 0) {
- return (0);
- }
+ if (cnt == 0)
+ return 0;
/*
* handle unaligned tail bytes
*/
data = 0;
- for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+ for (i = 0, cp = wp; i < 4 && cnt > 0; ++i, ++cp) {
data = (data << 8) | *src++;
--cnt;
}
- for (; i<4; ++i, ++cp) {
+ for (; i < 4; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- return (write_word(info, wp, data));
+ return write_word(info, wp, data);
}
/*-----------------------------------------------------------------------
@@ -655,22 +606,21 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
* 1 - write timeout
* 2 - Flash not erased
*/
-static int write_word (flash_info_t *info, ulong dest, ulong data)
+static int write_word(flash_info_t *info, ulong dest, ulong data)
{
- vu_long *addr = (vu_long*)(info->start[0]);
+ vu_long *addr = (vu_long *)(info->start[0]);
#ifdef CONFIG_FLASH_16BIT
vu_short high_data;
vu_short low_data;
- vu_short *s_addr = (vu_short*)addr;
+ vu_short *s_addr = (vu_short *)addr;
#endif
ulong start;
int flag;
/* Check if Flash is (sufficiently) erased */
- if ((*((vu_long *)dest) & data) != data) {
- return (2);
- }
+ if ((*((vu_long *)dest) & data) != data)
+ return 2;
#ifdef CONFIG_FLASH_16BIT
/* Write the 16 higher-bits */
@@ -685,20 +635,17 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
*((vu_short *)dest) = high_data;
-
/* re-enable interrupts if necessary */
if (flag)
enable_interrupts();
/* data polling for D7 */
- start = get_timer (0);
+ start = get_timer(0);
while ((*((vu_short *)dest) & 0x0080) != (high_data & 0x0080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- return (1);
- }
+ if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT)
+ return 1;
}
-
/* Write the 16 lower-bits */
#endif
@@ -725,7 +672,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
enable_interrupts();
/* data polling for D7 */
- start = get_timer (0);
+ start = get_timer(0);
#ifdef CONFIG_FLASH_16BIT
while ((*((vu_short *)dest) & 0x0080) != (low_data & 0x0080)) {
@@ -733,12 +680,8 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) {
#endif
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- return (1);
- }
+ if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT)
+ return 1;
}
- return (0);
+ return 0;
}
-
-/*-----------------------------------------------------------------------
- */
diff --git a/board/fads/fads.c b/board/fads/fads.c
index 9f7faaf47d7..317d279603a 100644
--- a/board/fads/fads.c
+++ b/board/fads/fads.c
@@ -603,15 +603,17 @@ static int initsdram(uint base, uint *noMbytes)
phys_size_t initdram (int board_type)
{
uint sdramsz = 0; /* size of sdram in Mbytes */
- uint base = 0; /* base of dram in bytes */
uint m = 0; /* size of dram in Mbytes */
#ifndef CONFIG_MPC885ADS
+ uint base = 0; /* base of dram in bytes */
uint k, s;
#endif
#ifdef CONFIG_FADS
if (!initsdram (0x00000000, &sdramsz)) {
+#ifndef CONFIG_MPC885ADS
base = sdramsz << 20;
+#endif
printf ("(%u MB SDRAM) ", sdramsz);
}
#endif
diff --git a/board/freescale/mpc8266ads/mpc8266ads.c b/board/freescale/mpc8266ads/mpc8266ads.c
index 2caf4aa9901..5d489681842 100644
--- a/board/freescale/mpc8266ads/mpc8266ads.c
+++ b/board/freescale/mpc8266ads/mpc8266ads.c
@@ -1,5 +1,5 @@
/*
- * (C) Copyright 2001
+ * (C) Copyright 2001-2011
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* Modified during 2001 by
@@ -61,8 +61,8 @@
const iop_conf_t iop_conf_tab[4][32] = {
- /* Port A configuration */
- { /* conf ppar psor pdir podr pdat */
+ /* Port A configuration */
+ { /* conf ppar psor pdir podr pdat */
/* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
/* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
/* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
@@ -95,10 +95,10 @@ const iop_conf_t iop_conf_tab[4][32] = {
/* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
/* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
/* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
- },
+ },
- /* Port B configuration */
- { /* conf ppar psor pdir podr pdat */
+ /* Port B configuration */
+ { /* conf ppar psor pdir podr pdat */
/* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
/* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
/* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
@@ -131,10 +131,10 @@ const iop_conf_t iop_conf_tab[4][32] = {
/* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
/* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
/* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
- },
+ },
- /* Port C */
- { /* conf ppar psor pdir podr pdat */
+ /* Port C */
+ { /* conf ppar psor pdir podr pdat */
/* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
/* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
/* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
@@ -167,10 +167,10 @@ const iop_conf_t iop_conf_tab[4][32] = {
/* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
/* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
/* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
- },
+ },
- /* Port D */
- { /* conf ppar psor pdir podr pdat */
+ /* Port D */
+ { /* conf ppar psor pdir podr pdat */
/* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
/* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
/* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
@@ -203,7 +203,7 @@ const iop_conf_t iop_conf_tab[4][32] = {
/* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
/* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
/* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
- }
+ }
};
typedef struct bscr_ {
@@ -224,317 +224,329 @@ typedef struct pci_ic_s {
void reset_phy(void)
{
- volatile bcsr_t *bcsr = (bcsr_t *)CONFIG_SYS_BCSR;
+ volatile bcsr_t *bcsr = (bcsr_t *)CONFIG_SYS_BCSR;
- /* reset the FEC port */
- bcsr->bcsr1 &= ~FETH_RST;
- bcsr->bcsr1 |= FETH_RST;
+ /* reset the FEC port */
+ bcsr->bcsr1 &= ~FETH_RST;
+ bcsr->bcsr1 |= FETH_RST;
}
-int board_early_init_f (void)
+int board_early_init_f(void)
{
- volatile bcsr_t *bcsr = (bcsr_t *)CONFIG_SYS_BCSR;
- volatile pci_ic_t *pci_ic = (pci_ic_t *) CONFIG_SYS_PCI_INT;
+ volatile bcsr_t *bcsr = (bcsr_t *)CONFIG_SYS_BCSR;
+ volatile pci_ic_t *pci_ic = (pci_ic_t *)CONFIG_SYS_PCI_INT;
- bcsr->bcsr1 = ~FETHIEN & ~RS232EN_1 & ~RS232EN_2;
+ bcsr->bcsr1 = ~FETHIEN & ~RS232EN_1 & ~RS232EN_2;
- /* mask all PCI interrupts */
- pci_ic->pci_int_mask |= 0xfff00000;
+ /* mask all PCI interrupts */
+ pci_ic->pci_int_mask |= 0xfff00000;
- return 0;
+ return 0;
}
int checkboard(void)
{
- puts ("Board: Motorola MPC8266ADS\n");
- return 0;
+ puts("Board: Motorola MPC8266ADS\n");
+ return 0;
}
phys_size_t initdram(int board_type)
{
/* Autoinit part stolen from board/sacsng/sacsng.c */
- volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
- volatile memctl8260_t *memctl = &immap->im_memctl;
- volatile uchar c = 0xff;
- volatile uchar *ramaddr = (uchar *)(CONFIG_SYS_SDRAM_BASE + 0x8);
- uint psdmr = CONFIG_SYS_PSDMR;
- int i;
-
- uint psrt = 0x21; /* for no SPD */
- uint chipselects = 1; /* for no SPD */
- uint sdram_size = CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; /* for no SPD */
- uint or = CONFIG_SYS_OR2_PRELIM; /* for no SPD */
- uint data_width;
- uint rows;
- uint banks;
- uint cols;
- uint caslatency;
- uint width;
- uint rowst;
- uint sdam;
- uint bsma;
- uint sda10;
- u_char spd_size;
- u_char data;
- u_char cksum;
- int j;
-
- /* Keep the compiler from complaining about potentially uninitialized vars */
- data_width = rows = banks = cols = caslatency = 0;
-
- /*
- * Read the SDRAM SPD EEPROM via I2C.
- */
- i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
-
- i2c_read(SDRAM_SPD_ADDR, 0, 1, &data, 1);
- spd_size = data;
- cksum = data;
- for(j = 1; j < 64; j++)
- { /* read only the checksummed bytes */
- /* note: the I2C address autoincrements when alen == 0 */
+ volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
+ volatile memctl8260_t *memctl = &immap->im_memctl;
+ volatile uchar c = 0xff;
+ volatile uchar *ramaddr = (uchar *) (CONFIG_SYS_SDRAM_BASE + 0x8);
+ uint psdmr = CONFIG_SYS_PSDMR;
+ int i;
+
+ uint psrt = 0x21; /* for no SPD */
+ uint chipselects = 1; /* for no SPD */
+ uint sdram_size = CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; /* for no SPD */
+ uint or = CONFIG_SYS_OR2_PRELIM; /* for no SPD */
+ uint data_width;
+ uint rows;
+ uint banks;
+ uint cols;
+ uint caslatency;
+ uint width;
+ uint rowst;
+ uint sdam;
+ uint bsma;
+ uint sda10;
+ u_char data;
+ u_char cksum;
+ int j;
+
+ /*
+ * Keep the compiler from complaining about
+ * potentially uninitialized vars
+ */
+ data_width = rows = banks = cols = caslatency = 0;
+
+ /*
+ * Read the SDRAM SPD EEPROM via I2C.
+ */
+ i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+
+ i2c_read(SDRAM_SPD_ADDR, 0, 1, &data, 1);
+ cksum = data;
+ for (j = 1; j < 64; j++) { /* read only the checksummed bytes */
+ /* note: the I2C address autoincrements when alen == 0 */
i2c_read(SDRAM_SPD_ADDR, 0, 0, &data, 1);
- /*printf("addr %d = 0x%02x\n", j, data);*/
- if(j == 5) chipselects = data & 0x0F;
- else if(j == 6) data_width = data;
- else if(j == 7) data_width |= data << 8;
- else if(j == 3) rows = data & 0x0F;
- else if(j == 4) cols = data & 0x0F;
- else if(j == 12)
- {
+ /*printf("addr %d = 0x%02x\n", j, data); */
+ if (j == 5)
+ chipselects = data & 0x0F;
+ else if (j == 6)
+ data_width = data;
+ else if (j == 7)
+ data_width |= data << 8;
+ else if (j == 3)
+ rows = data & 0x0F;
+ else if (j == 4)
+ cols = data & 0x0F;
+ else if (j == 12) {
/*
- * Refresh rate: this assumes the prescaler is set to
- * approximately 0.39uSec per tick and the target refresh period
- * is about 85% of maximum.
+ * Refresh rate: this assumes the prescaler is set to
+ * approximately 0.39uSec per tick and the target
+ * refresh period is about 85% of maximum.
*/
- switch(data & 0x7F)
- {
- default:
- case 0: psrt = 0x21; /* 15.625uS */ break;
- case 1: psrt = 0x07; /* 3.9uS */ break;
- case 2: psrt = 0x0F; /* 7.8uS */ break;
- case 3: psrt = 0x43; /* 31.3uS */ break;
- case 4: psrt = 0x87; /* 62.5uS */ break;
- case 5: psrt = 0xFF; /* 125uS */ break;
+ switch (data & 0x7F) {
+ default:
+ case 0:
+ psrt = 0x21; /* 15.625uS */
+ break;
+ case 1:
+ psrt = 0x07; /* 3.9uS */
+ break;
+ case 2:
+ psrt = 0x0F; /* 7.8uS */
+ break;
+ case 3:
+ psrt = 0x43; /* 31.3uS */
+ break;
+ case 4:
+ psrt = 0x87; /* 62.5uS */
+ break;
+ case 5:
+ psrt = 0xFF; /* 125uS */
+ break;
}
- }
- else if(j == 17) banks = data;
- else if(j == 18)
- {
- caslatency = 3; /* default CL */
-# if(PESSIMISTIC_SDRAM)
- if((data & 0x04) != 0) caslatency = 3;
- else if((data & 0x02) != 0) caslatency = 2;
- else if((data & 0x01) != 0) caslatency = 1;
-# else
- if((data & 0x01) != 0) caslatency = 1;
- else if((data & 0x02) != 0) caslatency = 2;
- else if((data & 0x04) != 0) caslatency = 3;
-# endif
- else
- {
- printf ("WARNING: Unknown CAS latency 0x%02X, using 3\n",
+ } else if (j == 17)
+ banks = data;
+ else if (j == 18) {
+ caslatency = 3; /* default CL */
+#if (PESSIMISTIC_SDRAM)
+ if ((data & 0x04) != 0)
+ caslatency = 3;
+ else if ((data & 0x02) != 0)
+ caslatency = 2;
+ else if ((data & 0x01) != 0)
+ caslatency = 1;
+#else
+ if ((data & 0x01) != 0)
+ caslatency = 1;
+ else if ((data & 0x02) != 0)
+ caslatency = 2;
+ else if ((data & 0x04) != 0)
+ caslatency = 3;
+#endif
+ else {
+ printf("WARNING: Unknown CAS latency 0x%02X, using 3\n",
data);
}
- }
- else if(j == 63)
- {
- if(data != cksum)
- {
- printf ("WARNING: Configuration data checksum failure:"
+ } else if (j == 63) {
+ if (data != cksum) {
+ printf("WARNING: Configuration data checksum failure:"
" is 0x%02x, calculated 0x%02x\n",
- data, cksum);
+ data, cksum);
}
}
cksum += data;
- }
+ }
- /* We don't trust CL less than 2 (only saw it on an old 16MByte DIMM) */
- if(caslatency < 2) {
+ /* We don't trust CL less than 2 (only saw it on an old 16MByte DIMM) */
+ if (caslatency < 2) {
printf("CL was %d, forcing to 2\n", caslatency);
caslatency = 2;
- }
- if(rows > 14) {
- printf("This doesn't look good, rows = %d, should be <= 14\n", rows);
+ }
+ if (rows > 14) {
+ printf("This doesn't look good, rows = %d, should be <= 14\n",
+ rows);
rows = 14;
- }
- if(cols > 11) {
- printf("This doesn't look good, columns = %d, should be <= 11\n", cols);
+ }
+ if (cols > 11) {
+ printf("This doesn't look good, columns = %d, should be <= 11\n",
+ cols);
cols = 11;
- }
+ }
- if((data_width != 64) && (data_width != 72))
- {
+ if ((data_width != 64) && (data_width != 72)) {
printf("WARNING: SDRAM width unsupported, is %d, expected 64 or 72.\n",
data_width);
- }
- width = 3; /* 2^3 = 8 bytes = 64 bits wide */
- /*
- * Convert banks into log2(banks)
- */
- if (banks == 2) banks = 1;
- else if(banks == 4) banks = 2;
- else if(banks == 8) banks = 3;
-
-
- sdram_size = 1 << (rows + cols + banks + width);
- /* hack for high density memory (512MB per CS) */
- /* !!!!! Will ONLY work with Page Based Interleave !!!!!
- ( PSDMR[PBI] = 1 )
- */
- /* mamory actually has 11 column addresses, but the memory controller
- doesn't really care.
- the calculations that follow will however move the rows so that
- they are muxed one bit off if you use 11 bit columns.
- The solution is to tell the memory controller the correct size of the memory
- but change the number of columns to 10 afterwards.
- The 11th column addre will still be mucxed correctly onto the bus.
-
- Also be aware that the MPC8266ADS board Rev B has not connected
- Row address 13 to anything.
-
- The fix is to connect ADD16 (from U37-47) to SADDR12 (U28-126)
- */
- if (cols > 10)
- cols = 10;
-
-#if(CONFIG_PBI == 0) /* bank-based interleaving */
- rowst = ((32 - 6) - (rows + cols + width)) * 2;
+ }
+ width = 3; /* 2^3 = 8 bytes = 64 bits wide */
+ /*
+ * Convert banks into log2(banks)
+ */
+ if (banks == 2)
+ banks = 1;
+ else if (banks == 4)
+ banks = 2;
+ else if (banks == 8)
+ banks = 3;
+
+
+ sdram_size = 1 << (rows + cols + banks + width);
+ /* hack for high density memory (512MB per CS) */
+ /* !!!!! Will ONLY work with Page Based Interleave !!!!!
+ ( PSDMR[PBI] = 1 )
+ */
+ /*
+ * memory actually has 11 column addresses, but the memory
+ * controller doesn't really care.
+ *
+ * the calculations that follow will however move the rows so
+ * that they are muxed one bit off if you use 11 bit columns.
+ *
+ * The solution is to tell the memory controller the correct
+ * size of the memory but change the number of columns to 10
+ * afterwards.
+ *
+ * The 11th column addre will still be mucxed correctly onto
+ * the bus.
+ *
+ * Also be aware that the MPC8266ADS board Rev B has not
+ * connected Row address 13 to anything.
+ *
+ * The fix is to connect ADD16 (from U37-47) to SADDR12 (U28-126)
+ */
+ if (cols > 10)
+ cols = 10;
+
+#if (CONFIG_PBI == 0) /* bank-based interleaving */
+ rowst = ((32 - 6) - (rows + cols + width)) * 2;
#else
- rowst = 32 - (rows + banks + cols + width);
+ rowst = 32 - (rows + banks + cols + width);
#endif
- or = ~(sdram_size - 1) | /* SDAM address mask */
- ((banks-1) << 13) | /* banks per device */
- (rowst << 9) | /* rowst */
- ((rows - 9) << 6); /* numr */
-
-
- /*printf("memctl->memc_or2 = 0x%08x\n", or);*/
-
- /*
- * SDAM specifies the number of columns that are multiplexed
- * (reference AN2165/D), defined to be (columns - 6) for page
- * interleave, (columns - 8) for bank interleave.
- *
- * BSMA is 14 - max(rows, cols). The bank select lines come
- * into play above the highest "address" line going into the
- * the SDRAM.
- */
-#if(CONFIG_PBI == 0) /* bank-based interleaving */
- sdam = cols - 8;
- bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
- sda10 = sdam + 2;
+ or = ~(sdram_size - 1) | /* SDAM address mask */
+ ((banks - 1) << 13) | /* banks per device */
+ (rowst << 9) | /* rowst */
+ ((rows - 9) << 6); /* numr */
+
+
+ /*printf("memctl->memc_or2 = 0x%08x\n", or); */
+
+ /*
+ * SDAM specifies the number of columns that are multiplexed
+ * (reference AN2165/D), defined to be (columns - 6) for page
+ * interleave, (columns - 8) for bank interleave.
+ *
+ * BSMA is 14 - max(rows, cols). The bank select lines come
+ * into play above the highest "address" line going into the
+ * the SDRAM.
+ */
+#if (CONFIG_PBI == 0) /* bank-based interleaving */
+ sdam = cols - 8;
+ bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
+ sda10 = sdam + 2;
#else
- sdam = cols + banks - 8;
- bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
- sda10 = sdam;
+ sdam = cols + banks - 8;
+ bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
+ sda10 = sdam;
#endif
-#if(PESSIMISTIC_SDRAM)
- psdmr = (CONFIG_PBI |\
- PSDMR_RFEN |\
- PSDMR_RFRC_16_CLK |\
- PSDMR_PRETOACT_8W |\
- PSDMR_ACTTORW_8W |\
- PSDMR_WRC_4C |\
- PSDMR_EAMUX |\
- PSDMR_BUFCMD) |\
- caslatency |\
- ((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */ \
- (sdam << 24) |\
- (bsma << 21) |\
- (sda10 << 18);
+#if (PESSIMISTIC_SDRAM)
+ psdmr = (CONFIG_PBI | PSDMR_RFEN | PSDMR_RFRC_16_CLK |
+ PSDMR_PRETOACT_8W | PSDMR_ACTTORW_8W | PSDMR_WRC_4C |
+ PSDMR_EAMUX | PSDMR_BUFCMD) | caslatency |
+ ((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */
+ (sdam << 24) | (bsma << 21) | (sda10 << 18);
#else
- psdmr = (CONFIG_PBI |\
- PSDMR_RFEN |\
- PSDMR_RFRC_7_CLK |\
- PSDMR_PRETOACT_3W | /* 1 for 7E parts (fast PC-133) */ \
- PSDMR_ACTTORW_2W | /* 1 for 7E parts (fast PC-133) */ \
- PSDMR_WRC_1C | /* 1 clock + 7nSec */
- EAMUX |\
- BUFCMD) |\
- caslatency |\
- ((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */ \
- (sdam << 24) |\
- (bsma << 21) |\
- (sda10 << 18);
+ psdmr = (CONFIG_PBI | PSDMR_RFEN | PSDMR_RFRC_7_CLK |
+ PSDMR_PRETOACT_3W | /* 1 for 7E parts (fast PC-133) */
+ PSDMR_ACTTORW_2W | /* 1 for 7E parts (fast PC-133) */
+ PSDMR_WRC_1C | /* 1 clock + 7nSec */
+ EAMUX | BUFCMD) | caslatency |
+ ((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */
+ (sdam << 24) | (bsma << 21) | (sda10 << 18);
#endif
- /*printf("psdmr = 0x%08x\n", psdmr);*/
-
- /*
- * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
- *
- * "At system reset, initialization software must set up the
- * programmable parameters in the memory controller banks registers
- * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
- * system software should execute the following initialization sequence
- * for each SDRAM device.
- *
- * 1. Issue a PRECHARGE-ALL-BANKS command
- * 2. Issue eight CBR REFRESH commands
- * 3. Issue a MODE-SET command to initialize the mode register
- *
- * Quote from Micron MT48LC8M16A2 data sheet:
- *
- * "...the SDRAM requires a 100uS delay prior to issuing any
- * command other than a COMMAND INHIBIT or NOP. Starting at some
- * point during this 100uS period and continuing at least through
- * the end of this period, COMMAND INHIBIT or NOP commands should
- * be applied."
- *
- * "Once the 100uS delay has been satisfied with at least one COMMAND
- * INHIBIT or NOP command having been applied, a /PRECHARGE command/
- * should be applied. All banks must then be precharged, thereby
- * placing the device in the all banks idle state."
- *
- * "Once in the idle state, /two/ AUTO REFRESH cycles must be
- * performed. After the AUTO REFRESH cycles are complete, the
- * SDRAM is ready for mode register programming."
- *
- * (/emphasis/ mine, gvb)
- *
- * The way I interpret this, Micron start up sequence is:
- * 1. Issue a PRECHARGE-BANK command (initial precharge)
- * 2. Issue a PRECHARGE-ALL-BANKS command ("all banks ... precharged")
- * 3. Issue two (presumably, doing eight is OK) CBR REFRESH commands
- * 4. Issue a MODE-SET command to initialize the mode register
- *
- * --------
- *
- * The initial commands are executed by setting P/LSDMR[OP] and
- * accessing the SDRAM with a single-byte transaction."
- *
- * The appropriate BRx/ORx registers have already been set when we
- * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
- */
-
- memctl->memc_mptpr = CONFIG_SYS_MPTPR;
- memctl->memc_psrt = psrt;
-
- memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
- memctl->memc_or2 = or;
-
- memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
- *ramaddr = c;
-
- memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
- for (i = 0; i < 8; i++)
+ /*printf("psdmr = 0x%08x\n", psdmr); */
+
+ /*
+ * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
+ *
+ * "At system reset, initialization software must set up the
+ * programmable parameters in the memory controller banks registers
+ * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
+ * system software should execute the following initialization sequence
+ * for each SDRAM device.
+ *
+ * 1. Issue a PRECHARGE-ALL-BANKS command
+ * 2. Issue eight CBR REFRESH commands
+ * 3. Issue a MODE-SET command to initialize the mode register
+ *
+ * Quote from Micron MT48LC8M16A2 data sheet:
+ *
+ * "...the SDRAM requires a 100uS delay prior to issuing any
+ * command other than a COMMAND INHIBIT or NOP. Starting at some
+ * point during this 100uS period and continuing at least through
+ * the end of this period, COMMAND INHIBIT or NOP commands should
+ * be applied."
+ *
+ * "Once the 100uS delay has been satisfied with at least one COMMAND
+ * INHIBIT or NOP command having been applied, a /PRECHARGE command/
+ * should be applied. All banks must then be precharged, thereby
+ * placing the device in the all banks idle state."
+ *
+ * "Once in the idle state, /two/ AUTO REFRESH cycles must be
+ * performed. After the AUTO REFRESH cycles are complete, the
+ * SDRAM is ready for mode register programming."
+ *
+ * (/emphasis/ mine, gvb)
+ *
+ * The way I interpret this, Micron start up sequence is:
+ * 1. Issue a PRECHARGE-BANK command (initial precharge)
+ * 2. Issue a PRECHARGE-ALL-BANKS command ("all banks ... precharged")
+ * 3. Issue two (presumably, doing eight is OK) CBR REFRESH commands
+ * 4. Issue a MODE-SET command to initialize the mode register
+ *
+ * --------
+ *
+ * The initial commands are executed by setting P/LSDMR[OP] and
+ * accessing the SDRAM with a single-byte transaction."
+ *
+ * The appropriate BRx/ORx registers have already been set
+ * when we get here. The SDRAM can be accessed at the address
+ * CONFIG_SYS_SDRAM_BASE.
+ */
+
+ memctl->memc_mptpr = CONFIG_SYS_MPTPR;
+ memctl->memc_psrt = psrt;
+
+ memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM;
+ memctl->memc_or2 = or;
+
+ memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
*ramaddr = c;
- memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
- *ramaddr = c;
+ memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
+ for (i = 0; i < 8; i++)
+ *ramaddr = c;
+
+ memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
+ *ramaddr = c;
- memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
- *ramaddr = c;
+ memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
+ *ramaddr = c;
- /*
- * Do it a second time for the second set of chips if the DIMM has
- * two chip selects (double sided).
- */
- if(chipselects > 1)
- {
- ramaddr += sdram_size;
+ /*
+ * Do it a second time for the second set of chips if the DIMM has
+ * two chip selects (double sided).
+ */
+ if (chipselects > 1) {
+ ramaddr += sdram_size;
memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM + sdram_size;
memctl->memc_or3 = or;
@@ -551,28 +563,28 @@ phys_size_t initdram(int board_type)
memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
*ramaddr = c;
- }
+ }
/* print info */
printf("SDRAM configuration read from SPD\n");
printf("\tSize per side = %dMB\n", sdram_size >> 20);
- printf("\tOrganization: %d sides, %d banks, %d Columns, %d Rows, Data width = %d bits\n", chipselects, 1<<(banks), cols, rows, data_width);
+ printf("\tOrganization: %d sides, %d banks, %d Columns, %d Rows, Data width = %d bits\n",
+ chipselects, 1 << (banks), cols, rows, data_width);
printf("\tRefresh rate = %d, CAS latency = %d", psrt, caslatency);
-#if(CONFIG_PBI == 0) /* bank-based interleaving */
- printf(", Using Bank Based Interleave\n");
+#if (CONFIG_PBI == 0) /* bank-based interleaving */
+ printf(", Using Bank Based Interleave\n");
#else
- printf(", Using Page Based Interleave\n");
+ printf(", Using Page Based Interleave\n");
#endif
printf("\tTotal size: ");
- /* this delay only needed for original 16MB DIMM...
- * Not needed for any other memory configuration */
- if ((sdram_size * chipselects) == (16 *1024 *1024))
- udelay (250000);
- return (sdram_size * chipselects);
- /*return (16 * 1024 * 1024);*/
-}
+ /* this delay only needed for original 16MB DIMM...
+ * Not needed for any other memory configuration */
+ if ((sdram_size * chipselects) == (16 * 1024 * 1024))
+ udelay(250000);
+ return sdram_size * chipselects;
+}
#ifdef CONFIG_PCI
struct pci_controller hose;
diff --git a/board/funkwerk/vovpn-gw/vovpn-gw.c b/board/funkwerk/vovpn-gw/vovpn-gw.c
index a4bfbc97802..57bd21fc295 100644
--- a/board/funkwerk/vovpn-gw/vovpn-gw.c
+++ b/board/funkwerk/vovpn-gw/vovpn-gw.c
@@ -25,6 +25,7 @@
#include <mpc8260.h>
#include <asm/m8260_pci.h>
#include <miiphy.h>
+#include <linux/compiler.h>
#include "m88e6060.h"
@@ -263,7 +264,7 @@ int board_early_init_f (void)
int misc_init_r (void)
{
volatile ioport_t *iop;
- unsigned char temp;
+ __maybe_unused unsigned char temp;
#if 0
/* DUMP UPMA RAM */
volatile immap_t *immap;
diff --git a/board/genietv/flash.c b/board/genietv/flash.c
index 5313ad8b0a2..19a428abb81 100644
--- a/board/genietv/flash.c
+++ b/board/genietv/flash.c
@@ -1,5 +1,5 @@
/*
- * (C) Copyright 2000
+ * (C) Copyright 2000-2011
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
@@ -24,32 +24,33 @@
#include <common.h>
#include <mpc8xx.h>
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
+flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
/*-----------------------------------------------------------------------
* Functions
*/
-static ulong flash_get_size (vu_long *addr, flash_info_t *info);
-static int write_word (flash_info_t *info, ulong dest, ulong data);
-static void flash_get_offsets (ulong base, flash_info_t *info);
+static ulong flash_get_size(vu_long *addr, flash_info_t *info);
+static int write_word(flash_info_t *info, ulong dest, ulong data);
+static void flash_get_offsets(ulong base, flash_info_t *info);
/*-----------------------------------------------------------------------
*/
-unsigned long flash_init (void)
+unsigned long flash_init(void)
{
- unsigned long size_b0, size_b1;
+ unsigned long size_b0;
int i;
/* Init: no FLASHes known */
- for (i=0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
- flash_info[i].flash_id = FLASH_UNKNOWN;
+ for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
+ flash_info[i].flash_id = FLASH_UNKNOWN;
/* Detect size */
- size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+ size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE,
+ &flash_info[0]);
/* Setup offsets */
- flash_get_offsets (CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+ flash_get_offsets(CONFIG_SYS_FLASH_BASE, &flash_info[0]);
#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
/* Monitor protection ON by default */
@@ -59,21 +60,15 @@ unsigned long flash_init (void)
&flash_info[0]);
#endif
- size_b1 = 0 ;
-
- flash_info[1].flash_id = FLASH_UNKNOWN;
- flash_info[1].sector_count = -1;
-
flash_info[0].size = size_b0;
- flash_info[1].size = size_b1;
- return (size_b0 + size_b1);
+ return size_b0;
}
/*-----------------------------------------------------------------------
* Fix this to support variable sector sizes
*/
-static void flash_get_offsets (ulong base, flash_info_t *info)
+static void flash_get_offsets(ulong base, flash_info_t *info)
{
int i;
@@ -87,73 +82,85 @@ static void flash_get_offsets (ulong base, flash_info_t *info)
/*-----------------------------------------------------------------------
*/
-void flash_print_info (flash_info_t *info)
+void flash_print_info(flash_info_t *info)
{
int i;
- if (info->flash_id == FLASH_UNKNOWN)
- {
- puts ("missing or unknown FLASH type\n");
+ if (info->flash_id == FLASH_UNKNOWN) {
+ puts("missing or unknown FLASH type\n");
return;
}
- switch (info->flash_id & FLASH_VENDMASK)
- {
- case FLASH_MAN_AMD: printf ("AMD "); break;
- case FLASH_MAN_FUJ: printf ("FUJITSU "); break;
- case FLASH_MAN_BM: printf ("BRIGHT MICRO "); break;
- default: printf ("Unknown Vendor "); break;
+ switch (info->flash_id & FLASH_VENDMASK) {
+ case FLASH_MAN_AMD:
+ printf("AMD ");
+ break;
+ case FLASH_MAN_FUJ:
+ printf("FUJITSU ");
+ break;
+ case FLASH_MAN_BM:
+ printf("BRIGHT MICRO ");
+ break;
+ default:
+ printf("Unknown Vendor ");
+ break;
}
- switch (info->flash_id & FLASH_TYPEMASK)
- {
- case FLASH_AM040: printf ("29F040 or 29LV040 (4 Mbit, uniform sectors)\n");
- break;
- case FLASH_AM400B: printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM400T: printf ("AM29LV400T (4 Mbit, top boot sector)\n");
- break;
- case FLASH_AM800B: printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM800T: printf ("AM29LV800T (8 Mbit, top boot sector)\n");
- break;
- case FLASH_AM160B: printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM160T: printf ("AM29LV160T (16 Mbit, top boot sector)\n");
- break;
- case FLASH_AM320B: printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM320T: printf ("AM29LV320T (32 Mbit, top boot sector)\n");
- break;
- default: printf ("Unknown Chip Type\n");
- break;
+ switch (info->flash_id & FLASH_TYPEMASK) {
+ case FLASH_AM040:
+ printf("29F040 or 29LV040 (4 Mbit, uniform sectors)\n");
+ break;
+ case FLASH_AM400B:
+ printf("AM29LV400B (4 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM400T:
+ printf("AM29LV400T (4 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM800B:
+ printf("AM29LV800B (8 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM800T:
+ printf("AM29LV800T (8 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM160B:
+ printf("AM29LV160B (16 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM160T:
+ printf("AM29LV160T (16 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM320B:
+ printf("AM29LV320B (32 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM320T:
+ printf("AM29LV320T (32 Mbit, top boot sector)\n");
+ break;
+ default:
+ printf("Unknown Chip Type\n");
+ break;
}
if (info->size >> 20) {
- printf (" Size: %ld MB in %d Sectors\n",
- info->size >> 20,
- info->sector_count);
+ printf(" Size: %ld MB in %d Sectors\n",
+ info->size >> 20,
+ info->sector_count);
} else {
- printf (" Size: %ld KB in %d Sectors\n",
- info->size >> 10,
- info->sector_count);
+ printf(" Size: %ld KB in %d Sectors\n",
+ info->size >> 10,
+ info->sector_count);
}
- puts (" Sector Start Addresses:");
+ puts(" Sector Start Addresses:");
- for (i=0; i<info->sector_count; ++i)
- {
+ for (i = 0; i < info->sector_count; ++i) {
if ((i % 5) == 0)
- {
- puts ("\n ");
- }
+ puts("\n ");
- printf (" %08lX%s",
+ printf(" %08lX%s",
info->start[i],
info->protect[i] ? " (RO)" : " ");
}
- putc ('\n');
+ putc('\n');
return;
}
/*-----------------------------------------------------------------------
@@ -163,7 +170,7 @@ void flash_print_info (flash_info_t *info)
* The following code cannot be run from FLASH!
*/
-static ulong flash_get_size (vu_long *addr, flash_info_t *info)
+static ulong flash_get_size(vu_long *addr, flash_info_t *info)
{
short i;
volatile unsigned char *caddr;
@@ -173,9 +180,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
/* Write auto select command: read Manufacturer ID */
-#if 0
- printf("Base address is: %08x\n", caddr);
-#endif
+ debug("Base address is: %8p\n", caddr);
caddr[0x0555] = 0xAA;
caddr[0x02AA] = 0x55;
@@ -183,51 +188,47 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
value = caddr[0];
-#if 0
- printf("Manufact ID: %02x\n", value);
-#endif
- switch (value)
- {
- case 0x1: /* AMD_MANUFACT */
- info->flash_id = FLASH_MAN_AMD;
- break;
+ debug("Manufact ID: %02x\n", value);
- case 0x4: /* FUJ_MANUFACT */
- info->flash_id = FLASH_MAN_FUJ;
+ switch (value) {
+ case 0x1: /* AMD_MANUFACT */
+ info->flash_id = FLASH_MAN_AMD;
+ break;
+ case 0x4: /* FUJ_MANUFACT */
+ info->flash_id = FLASH_MAN_FUJ;
+ break;
+ default:
+ info->flash_id = FLASH_UNKNOWN;
+ info->sector_count = 0;
+ info->size = 0;
break;
-
- default:
- info->flash_id = FLASH_UNKNOWN;
- info->sector_count = 0;
- info->size = 0;
- break;
}
value = caddr[1]; /* device ID */
-#if 0
- printf("Device ID: %02x\n", value);
-#endif
- switch (value)
- {
- case AMD_ID_LV040B:
- info->flash_id += FLASH_AM040;
- info->sector_count = 8;
- info->size = 0x00080000;
- break; /* => 512Kb */
-
- default:
- info->flash_id = FLASH_UNKNOWN;
- return (0); /* => no or unknown flash */
+ debug("Device ID: %02x\n", value);
+
+ switch (value) {
+ case AMD_ID_LV040B:
+ info->flash_id += FLASH_AM040;
+ info->sector_count = 8;
+ info->size = 0x00080000;
+ break; /* => 512Kb */
+
+ default:
+ info->flash_id = FLASH_UNKNOWN;
+ return 0; /* => no or unknown flash */
}
- flash_get_offsets ((ulong)addr, &flash_info[0]);
+ flash_get_offsets((ulong)addr, &flash_info[0]);
/* check for protected sectors */
- for (i = 0; i < info->sector_count; i++)
- {
- /* read sector protection at sector address, (A7 .. A0) = 0x02 */
- /* D0 = 1 if protected */
+ for (i = 0; i < info->sector_count; i++) {
+ /*
+ * read sector protection at sector address,
+ * (A7 .. A0) = 0x02
+ * D0 = 1 if protected
+ */
caddr = (volatile unsigned char *)(info->start[i]);
info->protect[i] = caddr[2] & 1;
}
@@ -235,52 +236,47 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
/*
* Prevent writes to uninitialized FLASH.
*/
- if (info->flash_id != FLASH_UNKNOWN)
- {
+ if (info->flash_id != FLASH_UNKNOWN) {
caddr = (volatile unsigned char *)info->start[0];
*caddr = 0xF0; /* reset bank */
}
- return (info->size);
+ return info->size;
}
-
-/*-----------------------------------------------------------------------
- */
-
-int flash_erase (flash_info_t *info, int s_first, int s_last)
+int flash_erase(flash_info_t *info, int s_first, int s_last)
{
- volatile unsigned char *addr = (volatile unsigned char *)(info->start[0]);
+ volatile unsigned char *addr =
+ (volatile unsigned char *)(info->start[0]);
int flag, prot, sect, l_sect;
ulong start, now, last;
if ((s_first < 0) || (s_first > s_last)) {
- if (info->flash_id == FLASH_UNKNOWN) {
- printf ("- missing\n");
- } else {
- printf ("- no sectors to erase\n");
- }
+ if (info->flash_id == FLASH_UNKNOWN)
+ printf("- missing\n");
+ else
+ printf("- no sectors to erase\n");
+
return 1;
}
if ((info->flash_id == FLASH_UNKNOWN) ||
(info->flash_id > FLASH_AMD_COMP)) {
- printf ("Can't erase unknown flash type - aborted\n");
+ printf("Can't erase unknown flash type - aborted\n");
return 1;
}
prot = 0;
- for (sect=s_first; sect<=s_last; ++sect) {
- if (info->protect[sect]) {
+ for (sect = s_first; sect <= s_last; ++sect) {
+ if (info->protect[sect])
prot++;
- }
}
if (prot) {
- printf ("- Warning: %d protected sectors will not be erased!\n",
+ printf("- Warning: %d protected sectors will not be erased!\n",
prot);
} else {
- printf ("\n");
+ printf("\n");
}
l_sect = -1;
@@ -295,7 +291,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
addr[0x02AA] = 0x55;
/* Start erase on unprotected sectors */
- for (sect = s_first; sect<=s_last; sect++) {
+ for (sect = s_first; sect <= s_last; sect++) {
if (info->protect[sect] == 0) { /* not protected */
addr = (volatile unsigned char *)(info->start[sect]);
addr[0] = 0x30;
@@ -308,7 +304,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
enable_interrupts();
/* wait at least 80us - let's wait 1 ms */
- udelay (1000);
+ udelay(1000);
/*
* We wait for the last triggered sector
@@ -316,19 +312,21 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
if (l_sect < 0)
goto DONE;
- start = get_timer (0);
+ start = get_timer(0);
last = start;
addr = (volatile unsigned char *)(info->start[l_sect]);
- while ((addr[0] & 0xFF) != 0xFF)
- {
- if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
- printf ("Timeout\n");
+ while ((addr[0] & 0xFF) != 0xFF) {
+
+ now = get_timer(start);
+
+ if (now > CONFIG_SYS_FLASH_ERASE_TOUT) {
+ printf("Timeout\n");
return 1;
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- putc ('.');
+ putc('.');
last = now;
}
}
@@ -339,7 +337,7 @@ DONE:
addr[0] = 0xF0; /* reset bank */
- printf (" done\n");
+ printf(" done\n");
return 0;
}
@@ -350,7 +348,7 @@ DONE:
* 2 - Flash not erased
*/
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
{
ulong cp, wp, data;
int i, l, rc;
@@ -360,23 +358,26 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
/*
* handle unaligned start bytes
*/
- if ((l = addr - wp) != 0) {
+ l = addr - wp;
+
+ if (l != 0) {
data = 0;
- for (i=0, cp=wp; i<l; ++i, ++cp) {
+ for (i = 0, cp = wp; i < l; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- for (; i<4 && cnt>0; ++i) {
+
+ for (; i < 4 && cnt > 0; ++i) {
data = (data << 8) | *src++;
--cnt;
++cp;
}
- for (; cnt==0 && i<4; ++i, ++cp) {
+ for (; cnt == 0 && i < 4; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- if ((rc = write_word(info, wp, data)) != 0) {
- return (rc);
- }
+ rc = write_word(info, wp, data);
+
+ if (rc != 0)
+ return rc;
+
wp += 4;
}
@@ -385,33 +386,33 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
*/
while (cnt >= 4) {
data = 0;
- for (i=0; i<4; ++i) {
+ for (i = 0; i < 4; ++i)
data = (data << 8) | *src++;
- }
- if ((rc = write_word(info, wp, data)) != 0) {
- return (rc);
- }
+
+ rc = write_word(info, wp, data);
+
+ if (rc != 0)
+ return rc;
+
wp += 4;
cnt -= 4;
}
- if (cnt == 0) {
- return (0);
- }
+ if (cnt == 0)
+ return 0;
/*
* handle unaligned tail bytes
*/
data = 0;
- for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+ for (i = 0, cp = wp; i < 4 && cnt > 0; ++i, ++cp) {
data = (data << 8) | *src++;
--cnt;
}
- for (; i<4; ++i, ++cp) {
+ for (; i < 4; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- return (write_word(info, wp, data));
+ return write_word(info, wp, data);
}
/*-----------------------------------------------------------------------
@@ -420,10 +421,11 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
* 1 - write timeout
* 2 - Flash not erased
*/
-static int write_word (flash_info_t *info, ulong dest, ulong data)
+static int write_word(flash_info_t *info, ulong dest, ulong data)
{
- volatile unsigned char *addr = (volatile unsigned char*)(info->start[0]),
- *cdest,*cdata;
+ volatile unsigned char *cdest, *cdata;
+ volatile unsigned char *addr =
+ (volatile unsigned char *)(info->start[0]);
ulong start;
int flag, count = 4 ;
@@ -431,39 +433,33 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
cdata = (volatile unsigned char *)&data ;
/* Check if Flash is (sufficiently) erased */
- if ((*((vu_long *)dest) & data) != data) {
- return (2);
- }
+ if ((*((vu_long *)dest) & data) != data)
+ return 2;
- while(count--)
- {
- /* Disable interrupts which might cause a timeout here */
- flag = disable_interrupts();
+ while (count--) {
- addr[0x0555] = 0xAA;
- addr[0x02AA] = 0x55;
- addr[0x0555] = 0xA0;
+ /* Disable interrupts which might cause a timeout here */
+ flag = disable_interrupts();
- *cdest = *cdata;
+ addr[0x0555] = 0xAA;
+ addr[0x02AA] = 0x55;
+ addr[0x0555] = 0xA0;
- /* re-enable interrupts if necessary */
- if (flag)
- enable_interrupts();
+ *cdest = *cdata;
- /* data polling for D7 */
- start = get_timer (0);
- while ((*cdest ^ *cdata) & 0x80)
- {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- return (1);
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+
+ /* data polling for D7 */
+ start = get_timer(0);
+ while ((*cdest ^ *cdata) & 0x80) {
+ if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT)
+ return 1;
}
- }
- cdata++ ;
- cdest++ ;
+ cdata++ ;
+ cdest++ ;
}
- return (0);
+ return 0;
}
-
-/*-----------------------------------------------------------------------
- */
diff --git a/board/gw8260/flash.c b/board/gw8260/flash.c
index 6035f6976c7..fb29659e290 100644
--- a/board/gw8260/flash.c
+++ b/board/gw8260/flash.c
@@ -63,54 +63,50 @@ static int write_word (flash_info_t *info, ulong dest, ulong data);
/* functions */
/*********************************************************************/
-/*********************************************************************/
-/* NAME: flash_init() - initializes flash banks */
-/* */
-/* DESCRIPTION: */
-/* This function initializes the flash bank(s). */
-/* */
-/* RETURNS: */
-/* The size in bytes of the flash */
-/* */
-/* RESTRICTIONS/LIMITATIONS: */
-/* */
-/* */
-/*********************************************************************/
-unsigned long flash_init (void)
+/*
+ * NAME: flash_init() - initializes flash banks
+ *
+ * DESCRIPTION:
+ * This function initializes the flash bank(s).
+ *
+ * RETURNS:
+ * The size in bytes of the flash
+ *
+ * RESTRICTIONS/LIMITATIONS:
+ *
+ *
+ */
+unsigned long flash_init(void)
{
- unsigned long size;
- int i;
-
- /* Init: no FLASHes known */
- for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
- flash_info[i].flash_id = FLASH_UNKNOWN;
- }
-
- /* for now, only support the 4 MB Flash SIMM */
- size = flash_get_size((vu_long *)CONFIG_SYS_FLASH0_BASE, &flash_info[0]);
-
- /*
- * protect monitor and environment sectors
- */
-
+ int i;
+
+ /* Init: no FLASHes known */
+ for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
+ flash_info[i].flash_id = FLASH_UNKNOWN;
+
+ /* for now, only support the 4 MB Flash SIMM */
+ (void)flash_get_size((vu_long *) CONFIG_SYS_FLASH0_BASE,
+ &flash_info[0]);
+ /*
+ * protect monitor and environment sectors
+ */
#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH0_BASE
- flash_protect(FLAG_PROTECT_SET,
- CONFIG_SYS_MONITOR_BASE,
- CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
- &flash_info[0]);
+ flash_protect(FLAG_PROTECT_SET,
+ CONFIG_SYS_MONITOR_BASE,
+ CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
+ &flash_info[0]);
#endif
#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
-# ifndef CONFIG_ENV_SIZE
-# define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
-# endif
- flash_protect(FLAG_PROTECT_SET,
- CONFIG_ENV_ADDR,
- CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
- &flash_info[0]);
+#ifndef CONFIG_ENV_SIZE
+#define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
+#endif
+ flash_protect(FLAG_PROTECT_SET,
+ CONFIG_ENV_ADDR,
+ CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
#endif
- return (CONFIG_SYS_FLASH0_SIZE * 1024 * 1024); /*size*/
+ return CONFIG_SYS_FLASH0_SIZE * 1024 * 1024; /*size */
}
/*********************************************************************/
diff --git a/board/hymod/input.c b/board/hymod/input.c
index 998132d6594..1a2b8d23a7b 100644
--- a/board/hymod/input.c
+++ b/board/hymod/input.c
@@ -76,7 +76,6 @@ hymod_get_ethaddr (void)
if (n == 17) {
int i;
char *p, *q;
- uchar ea[6];
/* see if it looks like an ethernet address */
@@ -85,7 +84,7 @@ hymod_get_ethaddr (void)
for (i = 0; i < 6; i++) {
char term = (i == 5 ? '\0' : ':');
- ea[i] = simple_strtol (p, &q, 16);
+ (void)simple_strtol (p, &q, 16);
if ((q - p) != 2 || *q++ != term)
break;
diff --git a/board/icu862/flash.c b/board/icu862/flash.c
index 2afeff4b517..7f72258f1ae 100644
--- a/board/icu862/flash.c
+++ b/board/icu862/flash.c
@@ -52,13 +52,12 @@ unsigned long flash_init (void)
{
volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
volatile memctl8xx_t *memctl = &immap->im_memctl;
- unsigned long size_b0, size_b1;
+ unsigned long size_b0;
int i;
/* Init: no FLASHes known */
- for (i=0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
+ for (i=0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
flash_info[i].flash_id = FLASH_UNKNOWN;
- }
/* Static FLASH Bank configuration here - FIXME XXX */
@@ -70,27 +69,6 @@ unsigned long flash_init (void)
size_b0 >> 20);
}
- if (FLASH_BASE1_PRELIM != 0x0) {
- size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
-
- if (size_b1 > size_b0) {
- printf ("## ERROR: Bank 1 (0x%08lx = %ld MB)"
- " > Bank 0 (0x%08lx = %ld MB)\n",
- size_b1, size_b1 >> 20,
- size_b0, size_b0 >> 20);
-
- flash_info[0].flash_id = FLASH_UNKNOWN;
- flash_info[1].flash_id = FLASH_UNKNOWN;
- flash_info[0].sector_count = -1;
- flash_info[1].sector_count = -1;
- flash_info[0].size = 0;
- flash_info[1].size = 0;
- return (0);
- }
- } else {
- size_b1 = 0;
- }
-
/* Remap FLASH according to real size */
memctl->memc_or0 = CONFIG_SYS_OR_TIMING_FLASH | (-size_b0 & OR_AM_MSK);
memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V;
@@ -117,13 +95,9 @@ unsigned long flash_init (void)
#endif
/* ICU862 Board has only one Flash Bank */
- flash_info[1].flash_id = FLASH_UNKNOWN;
- flash_info[1].sector_count = -1;
-
flash_info[0].size = size_b0;
- flash_info[1].size = size_b1;
- return (size_b0 + size_b1);
+ return size_b0;
}
diff --git a/board/icu862/pcmcia.c b/board/icu862/pcmcia.c
index a4c0b54bc17..dbe3c3cf72f 100644
--- a/board/icu862/pcmcia.c
+++ b/board/icu862/pcmcia.c
@@ -18,18 +18,16 @@
static void cfg_port_B (void)
{
- volatile immap_t *immap;
volatile cpm8xx_t *cp;
uint reg;
- immap = (immap_t *)CONFIG_SYS_IMMR;
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
/*
- * Configure Port B for TPS2205 PC-Card Power-Interface Switch
- *
- * Switch off all voltages, assert shutdown
- */
+ * Configure Port B for TPS2205 PC-Card Power-Interface Switch
+ *
+ * Switch off all voltages, assert shutdown
+ */
reg = cp->cp_pbdat;
reg |= (TPS2205_VPP_PGM | TPS2205_VPP_VCC | /* VAVPP => Hi-Z */
TPS2205_VCC3 | TPS2205_VCC5 | /* VAVCC => Hi-Z */
@@ -47,7 +45,6 @@ static void cfg_port_B (void)
int pcmcia_hardware_enable(int slot)
{
- volatile immap_t *immap;
volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
volatile sysconf8xx_t *sysp;
@@ -58,7 +55,6 @@ int pcmcia_hardware_enable(int slot)
udelay(10000);
- immap = (immap_t *)CONFIG_SYS_IMMR;
sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
@@ -188,7 +184,6 @@ int pcmcia_hardware_disable(int slot)
int pcmcia_voltage_set(int slot, int vcc, int vpp)
{
- volatile immap_t *immap;
volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
u_long reg;
@@ -198,7 +193,6 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
" Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
- immap = (immap_t *)CONFIG_SYS_IMMR;
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
/*
diff --git a/board/ids8247/ids8247.c b/board/ids8247/ids8247.c
index d621833cc11..02db07f1dbb 100644
--- a/board/ids8247/ids8247.c
+++ b/board/ids8247/ids8247.c
@@ -281,10 +281,9 @@ phys_size_t initdram (int board_type)
volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
volatile memctl8260_t *memctl = &immap->im_memctl;
- long psize, lsize;
+ long psize;
psize = 16 * 1024 * 1024;
- lsize = 0;
memctl->memc_psrt = CONFIG_SYS_PSRT;
memctl->memc_mptpr = CONFIG_SYS_MPTPR;
diff --git a/board/kup/common/pcmcia.c b/board/kup/common/pcmcia.c
index ce6b1861db6..61ba586e178 100644
--- a/board/kup/common/pcmcia.c
+++ b/board/kup/common/pcmcia.c
@@ -20,7 +20,6 @@
int pcmcia_hardware_enable(int slot)
{
- volatile immap_t *immap;
volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
volatile sysconf8xx_t *sysp;
@@ -30,15 +29,14 @@ int pcmcia_hardware_enable(int slot)
udelay(10000);
- immap = (immap_t *)CONFIG_SYS_IMMR;
sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
/*
- * Configure SIUMCR to enable PCMCIA port B
- * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
- */
+ * Configure SIUMCR to enable PCMCIA port B
+ * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
+ */
sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
/* clear interrupt state, and disable interrupts */
@@ -46,9 +44,9 @@ int pcmcia_hardware_enable(int slot)
pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
/*
- * Disable interrupts, DMA, and PCMCIA buffers
- * (isolate the interface) and assert RESET signal
- */
+ * Disable interrupts, DMA, and PCMCIA buffers
+ * (isolate the interface) and assert RESET signal
+ */
debug ("Disable PCMCIA buffers and assert RESET\n");
reg = 0;
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
@@ -57,9 +55,9 @@ int pcmcia_hardware_enable(int slot)
udelay(2500);
/*
- * Configure Port B pins for
- * 3 Volts enable
- */
+ * Configure Port B pins for
+ * 3 Volts enable
+ */
if (slot) { /* Slot A is built-in */
cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
@@ -67,8 +65,8 @@ int pcmcia_hardware_enable(int slot)
cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
}
/*
- * Make sure there is a card in the slot, then configure the interface.
- */
+ * Make sure there is a card in the slot, then configure the interface.
+ */
udelay(10000);
debug ("[%d] %s: PIPR(%p)=0x%x\n",
__LINE__,__FUNCTION__,
@@ -79,8 +77,8 @@ int pcmcia_hardware_enable(int slot)
}
/*
- * Power On.
- */
+ * Power On.
+ */
printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
reg = pcmp->pcmc_pipr;
@@ -149,7 +147,6 @@ int pcmcia_hardware_disable(int slot)
int pcmcia_voltage_set(int slot, int vcc, int vpp)
{
- volatile immap_t *immap;
volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
u_long reg;
@@ -162,14 +159,13 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
if (!slot) /* Slot A is not configurable */
return 0;
- immap = (immap_t *)CONFIG_SYS_IMMR;
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
/*
- * Disable PCMCIA buffers (isolate the interface)
- * and assert RESET signal
- */
+ * Disable PCMCIA buffers (isolate the interface)
+ * and assert RESET signal
+ */
debug ("Disable PCMCIA buffers and assert RESET\n");
reg = PCMCIA_PGCRX(slot);
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
@@ -179,9 +175,9 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
debug ("PCMCIA power OFF\n");
/*
- * Configure Port B pins for
- * 3 Volts enable
- */
+ * Configure Port B pins for
+ * 3 Volts enable
+ */
cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
/* remove all power */
diff --git a/board/kup/kup4k/kup4k.c b/board/kup/kup4k/kup4k.c
index 267821c48f5..e1dc8f7cf84 100644
--- a/board/kup/kup4k/kup4k.c
+++ b/board/kup/kup4k/kup4k.c
@@ -152,7 +152,7 @@ phys_size_t initdram(int board_type)
volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
volatile memctl8xx_t *memctl = &immap->im_memctl;
long int size = 0;
- uchar *latch,rev,mod,tmp;
+ uchar *latch, rev, tmp;
/*
* Init ChipSelect #4 (CAN + HW-Latch) to determine Hardware Revision
@@ -164,7 +164,6 @@ phys_size_t initdram(int board_type)
latch = (uchar *)0x90000200;
tmp = swapbyte(*latch);
rev = (tmp & 0xF8) >> 3;
- mod = (tmp & 0x07);
upmconfig(UPMA, (uint *) sdram_table,
sizeof (sdram_table) / sizeof (uint));
diff --git a/board/linkstation/ide.c b/board/linkstation/ide.c
index 568fdf5f2e8..f3e3fce8242 100644
--- a/board/linkstation/ide.c
+++ b/board/linkstation/ide.c
@@ -62,14 +62,16 @@ int ide_preinit (void)
&ide_bus_offset32);
ide_bus_offset[0] = ide_bus_offset32 & 0xfffffffe;
ide_bus_offset[0] = pci_hose_bus_to_phys(&hose,
- ide_bus_offset[0] & 0xfffffffe,
- PCI_REGION_IO);
- pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_2,
- (u32 *) &ide_bus_offset[1]);
- ide_bus_offset[1] &= 0xfffffffe;
- ide_bus_offset[1] = pci_hose_bus_to_phys(&hose,
- ide_bus_offset[1] & 0xfffffffe,
- PCI_REGION_IO);
+ ide_bus_offset[0] & 0xfffffffe,
+ PCI_REGION_IO);
+ if (CONFIG_SYS_IDE_MAXBUS > 1) {
+ pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_2,
+ (u32 *) &ide_bus_offset[1]);
+ ide_bus_offset[1] &= 0xfffffffe;
+ ide_bus_offset[1] = pci_hose_bus_to_phys(&hose,
+ ide_bus_offset[1] & 0xfffffffe,
+ PCI_REGION_IO);
+ }
}
if (pci_find_device (PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8212, 0) != -1) {
diff --git a/board/lwmon/pcmcia.c b/board/lwmon/pcmcia.c
index ad2e60d590f..acbb9d54d21 100644
--- a/board/lwmon/pcmcia.c
+++ b/board/lwmon/pcmcia.c
@@ -29,8 +29,6 @@
int pcmcia_hardware_enable(int slot)
{
- volatile immap_t *immap;
- volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
volatile sysconf8xx_t *sysp;
uint reg, mask;
@@ -51,10 +49,8 @@ int pcmcia_hardware_enable(int slot)
#endif
udelay(10000);
- immap = (immap_t *)CONFIG_SYS_IMMR;
sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
- cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
/*
* Configure SIUMCR to enable PCMCIA port B
@@ -171,7 +167,6 @@ int pcmcia_hardware_disable(int slot)
int pcmcia_voltage_set(int slot, int vcc, int vpp)
{
- volatile immap_t *immap;
volatile pcmconf8xx_t *pcmp;
u_long reg;
uchar val;
@@ -181,7 +176,6 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
" Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
- immap = (immap_t *)CONFIG_SYS_IMMR;
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
/*
* Disable PCMCIA buffers (isolate the interface)
diff --git a/board/manroland/uc100/pcmcia.c b/board/manroland/uc100/pcmcia.c
index ad256783ce6..db3821a5e43 100644
--- a/board/manroland/uc100/pcmcia.c
+++ b/board/manroland/uc100/pcmcia.c
@@ -27,8 +27,8 @@ static void cfg_ports (void)
immap = (immap_t *)CONFIG_SYS_IMMR;
/*
- * Configure Port A for MAX1602 PC-Card Power-Interface Switch
- */
+ * Configure Port A for MAX1602 PC-Card Power-Interface Switch
+ */
immap->im_ioport.iop_padat &= ~0x8000; /* set port x output to low */
immap->im_ioport.iop_padir |= 0x8000; /* enable port x as output */
@@ -40,7 +40,6 @@ static void cfg_ports (void)
int pcmcia_hardware_enable(int slot)
{
volatile immap_t *immap;
- volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
volatile sysconf8xx_t *sysp;
uint reg, mask;
@@ -52,15 +51,14 @@ int pcmcia_hardware_enable(int slot)
immap = (immap_t *)CONFIG_SYS_IMMR;
sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
- cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
/* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
cfg_ports ();
/*
- * Configure SIUMCR to enable PCMCIA port B
- * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
- */
+ * Configure SIUMCR to enable PCMCIA port B
+ * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
+ */
sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
/* clear interrupt state, and disable interrupts */
@@ -68,9 +66,9 @@ int pcmcia_hardware_enable(int slot)
pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
/*
- * Disable interrupts, DMA, and PCMCIA buffers
- * (isolate the interface) and assert RESET signal
- */
+ * Disable interrupts, DMA, and PCMCIA buffers
+ * (isolate the interface) and assert RESET signal
+ */
debug ("Disable PCMCIA buffers and assert RESET\n");
reg = 0;
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
@@ -78,8 +76,8 @@ int pcmcia_hardware_enable(int slot)
udelay(500);
/*
- * Make sure there is a card in the slot, then configure the interface.
- */
+ * Make sure there is a card in the slot, then configure the interface.
+ */
udelay(10000);
debug ("[%d] %s: PIPR(%p)=0x%x\n",
__LINE__,__FUNCTION__,
@@ -90,19 +88,19 @@ int pcmcia_hardware_enable(int slot)
}
/*
- * Power On.
- */
+ * Power On.
+ */
mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
reg = pcmp->pcmc_pipr;
debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
reg,
(reg&PCMCIA_VS1(slot))?"n":"ff",
(reg&PCMCIA_VS2(slot))?"n":"ff");
- if ((reg & mask) == mask) {
+
+ if ((reg & mask) == mask)
puts (" 5.0V card found: ");
- } else {
+ else
puts (" 3.3V card found: ");
- }
/* switch VCC on */
immap->im_ioport.iop_padat |= 0x8000; /* power enable 3.3V */
@@ -154,8 +152,6 @@ int pcmcia_hardware_disable(int slot)
int pcmcia_voltage_set(int slot, int vcc, int vpp)
{
- volatile immap_t *immap;
- volatile pcmconf8xx_t *pcmp;
u_long reg;
debug ("voltage_set: "
@@ -163,12 +159,10 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
" Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
- immap = (immap_t *)CONFIG_SYS_IMMR;
- pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
/*
- * Disable PCMCIA buffers (isolate the interface)
- * and assert RESET signal
- */
+ * Disable PCMCIA buffers (isolate the interface)
+ * and assert RESET signal
+ */
debug ("Disable PCMCIA buffers and assert RESET\n");
reg = PCMCIA_PGCRX(_slot_);
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
@@ -176,10 +170,10 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
udelay(500);
/*
- * Configure Port C pins for
- * 5 Volts Enable and 3 Volts enable,
- * Turn all power pins to Hi-Z
- */
+ * Configure Port C pins for
+ * 5 Volts Enable and 3 Volts enable,
+ * Turn all power pins to Hi-Z
+ */
debug ("PCMCIA power OFF\n");
cfg_ports (); /* Enables switch, but all in Hi-Z */
diff --git a/board/mbx8xx/mbx8xx.c b/board/mbx8xx/mbx8xx.c
index 255796bd10c..0f014e1ad4e 100644
--- a/board/mbx8xx/mbx8xx.c
+++ b/board/mbx8xx/mbx8xx.c
@@ -117,14 +117,16 @@ static const uint sdram_table_50[] = {
/* ------------------------------------------------------------------------- */
+#ifdef CONFIG_SYS_USE_OSCCLK
static unsigned int get_reffreq(void);
+#endif
static unsigned int board_get_cpufreq(void);
void mbx_init (void)
{
volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
volatile memctl8xx_t *memctl = &immr->im_memctl;
- ulong speed, refclock, plprcr, sccr;
+ ulong speed, plprcr, sccr;
ulong br0_32 = memctl->memc_br0 & 0x400;
/* real-time clock status and control register */
@@ -152,7 +154,6 @@ void mbx_init (void)
immr->im_clkrst.car_sccr = sccr;
speed = board_get_cpufreq ();
- refclock = get_reffreq ();
#if ((CONFIG_SYS_PLPRCR & PLPRCR_MF_MSK) != 0)
plprcr = CONFIG_SYS_PLPRCR;
@@ -163,7 +164,7 @@ void mbx_init (void)
#endif
#ifdef CONFIG_SYS_USE_OSCCLK /* See doc/README.MBX ! */
- plprcr |= ((speed + refclock / 2) / refclock - 1) << 20;
+ plprcr |= ((speed + get_reffreq() / 2) / refclock - 1) << 20;
#endif
immr->im_clkrstk.cark_plprcrk = KAPWR_KEY;
@@ -226,21 +227,27 @@ static unsigned int board_get_cpufreq (void)
{
#ifndef CONFIG_8xx_GCLK_FREQ
vpd_packet_t *packet;
+ ulong *p;
packet = vpd_find_packet (VPD_PID_ICS);
- return *((ulong *) packet->data);
+ p = (ulong *)packet->data;
+ return *p;
#else
return((unsigned int)CONFIG_8xx_GCLK_FREQ );
#endif /* CONFIG_8xx_GCLK_FREQ */
}
+#ifdef CONFIG_SYS_USE_OSCCLK
static unsigned int get_reffreq (void)
{
vpd_packet_t *packet;
+ ulong *p;
packet = vpd_find_packet (VPD_PID_RCS);
- return *((ulong *) packet->data);
+ p = (ulong *)packet->data;
+ return *p;
}
+#endif
static void board_get_enetaddr(uchar *addr)
{
diff --git a/board/mbx8xx/pcmcia.c b/board/mbx8xx/pcmcia.c
index e672d8c78c8..497e260a0a4 100644
--- a/board/mbx8xx/pcmcia.c
+++ b/board/mbx8xx/pcmcia.c
@@ -77,10 +77,7 @@ int pcmcia_voltage_set (int slot, int vcc, int vpp)
int pcmcia_hardware_enable (int slot)
{
- volatile immap_t *immap;
- volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
- volatile sysconf8xx_t *sysp;
uint reg, mask;
debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n",
@@ -88,10 +85,7 @@ int pcmcia_hardware_enable (int slot)
udelay (10000);
- immap = (immap_t *) CONFIG_SYS_IMMR;
- sysp = (sysconf8xx_t *) (&(((immap_t *) CONFIG_SYS_IMMR)->im_siu_conf));
pcmp = (pcmconf8xx_t *) (&(((immap_t *) CONFIG_SYS_IMMR)->im_pcmcia));
- cp = (cpm8xx_t *) (&(((immap_t *) CONFIG_SYS_IMMR)->im_cpm));
/* clear interrupt state, and disable interrupts */
pcmp->pcmc_pscr = PCMCIA_MASK (_slot_);
diff --git a/board/mcc200/auto_update.c b/board/mcc200/auto_update.c
index 49213d0b388..4152873845d 100644
--- a/board/mcc200/auto_update.c
+++ b/board/mcc200/auto_update.c
@@ -341,7 +341,7 @@ int do_auto_update(void)
{
block_dev_desc_t *stor_dev;
long sz;
- int i, res = 0, bitmap_first, cnt, old_ctrlc, got_ctrlc;
+ int i, res = 0, cnt, old_ctrlc;
char *env;
long start, end;
@@ -450,8 +450,6 @@ int do_auto_update(void)
/* make sure that we see CTRL-C and save the old state */
old_ctrlc = disable_ctrlc(0);
- bitmap_first = 0;
-
/* validate the images first */
for (i = 0; i < AU_MAXFILES; i++) {
ulong imsize;
@@ -506,14 +504,11 @@ int do_auto_update(void)
/* this is really not a good idea, but it's what the */
/* customer wants. */
cnt = 0;
- got_ctrlc = 0;
do {
res = au_do_update(i, sz);
/* let the user break out of the loop */
if (ctrlc() || had_ctrlc()) {
clear_ctrlc();
- if (res < 0)
- got_ctrlc = 1;
break;
}
cnt++;
diff --git a/board/mousse/flash.c b/board/mousse/flash.c
index d729f33f935..cc405356dc6 100644
--- a/board/mousse/flash.c
+++ b/board/mousse/flash.c
@@ -776,8 +776,7 @@ void flash_print_info (flash_info_t * info)
*/
int flash_erase (flash_info_t * info, int s_first, int s_last)
{
- vu_long *addr = (vu_long *) (info->start[0]);
- int prot, sect, l_sect;
+ int prot, sect;
flash_dev_t *dev = NULL;
if ((s_first < 0) || (s_first > s_last)) {
@@ -803,17 +802,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
printf ("\n");
}
- l_sect = -1;
-
/* Start erase on unprotected sectors */
dev = getFlashDevFromInfo (info);
if (dev) {
printf ("Erase FLASH[%s] -%d sectors:", dev->name, dev->sectors);
for (sect = s_first; sect <= s_last; sect++) {
if (info->protect[sect] == 0) { /* not protected */
- addr = (vu_long *) (dev->base);
- /* printf("erase_sector: sector=%d, addr=0x%x\n",
- sect, addr); */
printf (".");
if (ERROR == flashEraseSector (dev, sect)) {
printf ("ERROR: could not erase sector %d on FLASH[%s]\n", sect, dev->name);
diff --git a/board/mpl/common/flash.c b/board/mpl/common/flash.c
index 61f031aabe8..81d7271a1bf 100644
--- a/board/mpl/common/flash.c
+++ b/board/mpl/common/flash.c
@@ -600,7 +600,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
{
volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[0]);
volatile FLASH_WORD_SIZE *addr2;
- int flag, prot, sect, l_sect;
+ int flag, prot, sect;
int i, rcode = 0;
@@ -632,8 +632,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
printf ("\n");
}
- l_sect = -1;
-
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();
@@ -672,7 +670,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
rcode |= wait_for_DQ7(info, sect);
}
}
- l_sect = sect;
/*
* Wait for each sector to complete, it's more
* reliable. According to AMD Spec, you must
@@ -691,16 +688,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
/* wait at least 80us - let's wait 1 ms */
udelay (1000);
-#if 0
- /*
- * We wait for the last triggered sector
- */
- if (l_sect < 0)
- goto DONE;
- wait_for_DQ7(info, l_sect);
-
-DONE:
-#endif
/* reset to read mode */
addr = (FLASH_WORD_SIZE *)info->start[0];
addr[0] = (FLASH_WORD_SIZE)0x00F000F0; /* reset bank */
diff --git a/board/netta/codec.c b/board/netta/codec.c
index c8d31d72e4c..e303aa47802 100644
--- a/board/netta/codec.c
+++ b/board/netta/codec.c
@@ -1386,34 +1386,31 @@ static inline unsigned int s_transfer_internal(int s_id, unsigned int address, u
static void s_write_BR(int s_id, unsigned int regno, unsigned int val)
{
unsigned int address;
- unsigned int v;
address = 0x70 | (regno & 15);
val &= 0xff;
- v = s_transfer_internal(s_id, address, val);
+ (void)s_transfer_internal(s_id, address, val);
}
static void s_write_OR(int s_id, unsigned int regno, unsigned int val)
{
unsigned int address;
- unsigned int v;
address = 0x70 | (regno & 15);
val &= 0xff;
- v = s_transfer_internal(s_id, address, val);
+ (void)s_transfer_internal(s_id, address, val);
}
static void s_write_NR(int s_id, unsigned int regno, unsigned int val)
{
unsigned int address;
- unsigned int v;
address = (regno & 7) << 4;
val &= 0xf;
- v = s_transfer_internal(s_id, address | val, 0x00);
+ (void)s_transfer_internal(s_id, address | val, 0x00);
}
#define BR7_IFR 0x08 /* IDL2 free run */
diff --git a/board/netta/pcmcia.c b/board/netta/pcmcia.c
index ed58f2c85e3..3fa1925f4c7 100644
--- a/board/netta/pcmcia.c
+++ b/board/netta/pcmcia.c
@@ -147,23 +147,16 @@ static void set_shdn(int what)
static void cfg_ports (void)
{
- volatile immap_t *immap;
- volatile cpm8xx_t *cp;
-
- immap = (immap_t *)CONFIG_SYS_IMMR;
- cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
-
-
cfg_vppd(0); cfg_vppd(1); /* VPPD0,VPPD1 VAVPP => Hi-Z */
cfg_vccd(0); cfg_vccd(1); /* 3V and 5V off */
cfg_shdn();
cfg_oc();
/*
- * Configure Port A for TPS2211 PC-Card Power-Interface Switch
- *
- * Switch off all voltages, assert shutdown
- */
+ * Configure Port A for TPS2211 PC-Card Power-Interface Switch
+ *
+ * Switch off all voltages, assert shutdown
+ */
set_vppd(0, 1); set_vppd(1, 1);
set_vccd(0, 0); set_vccd(1, 0);
set_shdn(1);
@@ -173,10 +166,7 @@ static void cfg_ports (void)
int pcmcia_hardware_enable(int slot)
{
- volatile immap_t *immap;
- volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
- volatile sysconf8xx_t *sysp;
uint reg, pipr, mask;
int i;
@@ -184,10 +174,7 @@ int pcmcia_hardware_enable(int slot)
udelay(10000);
- immap = (immap_t *)CONFIG_SYS_IMMR;
- sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
- cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
/* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
cfg_ports ();
@@ -197,9 +184,9 @@ int pcmcia_hardware_enable(int slot)
pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
/*
- * Disable interrupts, DMA, and PCMCIA buffers
- * (isolate the interface) and assert RESET signal
- */
+ * Disable interrupts, DMA, and PCMCIA buffers
+ * (isolate the interface) and assert RESET signal
+ */
debug ("Disable PCMCIA buffers and assert RESET\n");
reg = 0;
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
@@ -221,8 +208,8 @@ int pcmcia_hardware_enable(int slot)
}
/*
- * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
- */
+ * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
+ */
mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
pipr = pcmp->pcmc_pipr;
debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
@@ -267,15 +254,10 @@ int pcmcia_hardware_enable(int slot)
#if defined(CONFIG_CMD_PCMCIA)
int pcmcia_hardware_disable(int slot)
{
- volatile immap_t *immap;
- volatile pcmconf8xx_t *pcmp;
u_long reg;
debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
- immap = (immap_t *)CONFIG_SYS_IMMR;
- pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
-
/* Configure PCMCIA General Control Register */
debug ("Disable PCMCIA buffers and assert RESET\n");
reg = 0;
@@ -296,24 +278,19 @@ int pcmcia_hardware_disable(int slot)
int pcmcia_voltage_set(int slot, int vcc, int vpp)
{
- volatile immap_t *immap;
- volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
u_long reg;
- ushort sreg;
debug ("voltage_set: "
PCMCIA_BOARD_MSG
" Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
- immap = (immap_t *)CONFIG_SYS_IMMR;
- cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
/*
- * Disable PCMCIA buffers (isolate the interface)
- * and assert RESET signal
- */
+ * Disable PCMCIA buffers (isolate the interface)
+ * and assert RESET signal
+ */
debug ("Disable PCMCIA buffers and assert RESET\n");
reg = PCMCIA_PGCRX(_slot_);
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
@@ -322,30 +299,29 @@ int pcmcia_voltage_set(int slot, int vcc, int vpp)
udelay(500);
/*
- * Configure Port C pins for
- * 5 Volts Enable and 3 Volts enable,
- * Turn all power pins to Hi-Z
- */
+ * Configure Port C pins for
+ * 5 Volts Enable and 3 Volts enable,
+ * Turn all power pins to Hi-Z
+ */
debug ("PCMCIA power OFF\n");
cfg_ports (); /* Enables switch, but all in Hi-Z */
- sreg = immap->im_ioport.iop_pcdat;
set_vppd(0, 1); set_vppd(1, 1);
switch(vcc) {
- case 0:
- break; /* Switch off */
+ case 0:
+ break; /* Switch off */
- case 33:
- set_vccd(0, 1); set_vccd(1, 0);
- break;
+ case 33:
+ set_vccd(0, 1); set_vccd(1, 0);
+ break;
- case 50:
- set_vccd(0, 0); set_vccd(1, 1);
- break;
+ case 50:
+ set_vccd(0, 0); set_vccd(1, 1);
+ break;
- default:
- goto done;
+ default:
+ goto done;
}
/* Checking supported voltages */
diff --git a/board/pm520/flash.c b/board/pm520/flash.c
index 64c86241579..01dcd560c9b 100644
--- a/board/pm520/flash.c
+++ b/board/pm520/flash.c
@@ -370,7 +370,7 @@ static unsigned char intel_sector_protected (flash_info_t *info, ushort sector)
int flash_erase (flash_info_t *info, int s_first, int s_last)
{
int flag, prot, sect;
- ulong type, start, last;
+ ulong type, start;
int rcode = 0;
if ((s_first < 0) || (s_first > s_last)) {
@@ -404,7 +404,6 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
}
start = get_timer (0);
- last = start;
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts ();
@@ -440,6 +439,10 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
printf (" done\n");
}
}
+
+ if (flag)
+ enable_interrupts();
+
return rcode;
}
@@ -543,6 +546,7 @@ static int write_data (flash_info_t *info, ulong dest, FPW data)
ulong status;
ulong start;
int flag;
+ int rcode = 0;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
@@ -561,14 +565,17 @@ static int write_data (flash_info_t *info, ulong dest, FPW data)
/* wait while polling the status register */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- *addr = (FPW) 0x00FF00FF; /* restore read mode */
- return (1);
+ rcode = 1;
+ break;
}
}
*addr = (FPW) 0x00FF00FF; /* restore read mode */
- return (0);
+ if (flag)
+ enable_interrupts();
+
+ return rcode;
}
void inline spin_wheel (void)
diff --git a/board/r360mpi/pcmcia.c b/board/r360mpi/pcmcia.c
index 85da41bd22d..a939b31d47a 100644
--- a/board/r360mpi/pcmcia.c
+++ b/board/r360mpi/pcmcia.c
@@ -19,7 +19,6 @@
int pcmcia_hardware_enable(int slot)
{
volatile immap_t *immap;
- volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
volatile sysconf8xx_t *sysp;
uint reg, mask;
@@ -31,7 +30,6 @@ int pcmcia_hardware_enable(int slot)
immap = (immap_t *)CONFIG_SYS_IMMR;
sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
- cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
/*
* Configure SIUMCR to enable PCMCIA port B
@@ -127,13 +125,11 @@ int pcmcia_hardware_enable(int slot)
int pcmcia_hardware_disable(int slot)
{
volatile immap_t *immap;
- volatile pcmconf8xx_t *pcmp;
u_long reg;
debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
immap = (immap_t *)CONFIG_SYS_IMMR;
- pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
/* remove all power */
immap->im_ioport.iop_pcdat |= 0x0400;
diff --git a/board/rbc823/flash.c b/board/rbc823/flash.c
index cb1e089f38e..6be2bc92f45 100644
--- a/board/rbc823/flash.c
+++ b/board/rbc823/flash.c
@@ -24,32 +24,30 @@
#include <common.h>
#include <mpc8xx.h>
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
+flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
-/*-----------------------------------------------------------------------
+/*
* Functions
*/
-static ulong flash_get_size (vu_long *addr, flash_info_t *info);
-static int write_word (flash_info_t *info, ulong dest, ulong data);
-static void flash_get_offsets (ulong base, flash_info_t *info);
-
-/*-----------------------------------------------------------------------
- */
+static ulong flash_get_size(vu_long *addr, flash_info_t *info);
+static int write_word(flash_info_t *info, ulong dest, ulong data);
+static void flash_get_offsets(ulong base, flash_info_t *info);
-unsigned long flash_init (void)
+unsigned long flash_init(void)
{
- unsigned long size_b0, size_b1;
+ unsigned long size_b0;
int i;
/* Init: no FLASHes known */
- for (i=0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
- flash_info[i].flash_id = FLASH_UNKNOWN;
+ for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
+ flash_info[i].flash_id = FLASH_UNKNOWN;
/* Detect size */
- size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+ size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE,
+ &flash_info[0]);
/* Setup offsets */
- flash_get_offsets (CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+ flash_get_offsets(CONFIG_SYS_FLASH_BASE, &flash_info[0]);
#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
/* Monitor protection ON by default */
@@ -59,21 +57,15 @@ unsigned long flash_init (void)
&flash_info[0]);
#endif
- size_b1 = 0 ;
-
- flash_info[1].flash_id = FLASH_UNKNOWN;
- flash_info[1].sector_count = -1;
-
flash_info[0].size = size_b0;
- flash_info[1].size = size_b1;
- return (size_b0 + size_b1);
+ return size_b0;
}
/*-----------------------------------------------------------------------
* Fix this to support variable sector sizes
*/
-static void flash_get_offsets (ulong base, flash_info_t *info)
+static void flash_get_offsets(ulong base, flash_info_t *info)
{
int i;
@@ -87,83 +79,93 @@ static void flash_get_offsets (ulong base, flash_info_t *info)
/*-----------------------------------------------------------------------
*/
-void flash_print_info (flash_info_t *info)
+void flash_print_info(flash_info_t *info)
{
int i;
- if (info->flash_id == FLASH_UNKNOWN)
- {
- puts ("missing or unknown FLASH type\n");
+ if (info->flash_id == FLASH_UNKNOWN) {
+ puts("missing or unknown FLASH type\n");
return;
}
- switch (info->flash_id & FLASH_VENDMASK)
- {
- case FLASH_MAN_AMD: printf ("AMD "); break;
- case FLASH_MAN_FUJ: printf ("FUJITSU "); break;
- case FLASH_MAN_BM: printf ("BRIGHT MICRO "); break;
- default: printf ("Unknown Vendor "); break;
+ switch (info->flash_id & FLASH_VENDMASK) {
+ case FLASH_MAN_AMD:
+ printf("AMD ");
+ break;
+ case FLASH_MAN_FUJ:
+ printf("FUJITSU ");
+ break;
+ case FLASH_MAN_BM:
+ printf("BRIGHT MICRO ");
+ break;
+ default:
+ printf("Unknown Vendor ");
+ break;
}
- switch (info->flash_id & FLASH_TYPEMASK)
- {
- case FLASH_AM040: printf ("29F040 or 29LV040 (4 Mbit, uniform sectors)\n");
- break;
- case FLASH_AM400B: printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM400T: printf ("AM29LV400T (4 Mbit, top boot sector)\n");
- break;
- case FLASH_AM800B: printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM800T: printf ("AM29LV800T (8 Mbit, top boot sector)\n");
- break;
- case FLASH_AM160B: printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM160T: printf ("AM29LV160T (16 Mbit, top boot sector)\n");
- break;
- case FLASH_AM320B: printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM320T: printf ("AM29LV320T (32 Mbit, top boot sector)\n");
- break;
- default: printf ("Unknown Chip Type\n");
- break;
+ switch (info->flash_id & FLASH_TYPEMASK) {
+ case FLASH_AM040:
+ printf("29F040 or 29LV040 (4 Mbit, uniform sectors)\n");
+ break;
+ case FLASH_AM400B:
+ printf("AM29LV400B (4 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM400T:
+ printf("AM29LV400T (4 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM800B:
+ printf("AM29LV800B (8 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM800T:
+ printf("AM29LV800T (8 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM160B:
+ printf("AM29LV160B (16 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM160T:
+ printf("AM29LV160T (16 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM320B:
+ printf("AM29LV320B (32 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM320T:
+ printf("AM29LV320T (32 Mbit, top boot sector)\n");
+ break;
+ default:
+ printf("Unknown Chip Type\n");
+ break;
}
if (info->size >> 20) {
- printf (" Size: %ld MB in %d Sectors\n",
- info->size >> 20,
- info->sector_count);
+ printf(" Size: %ld MB in %d Sectors\n",
+ info->size >> 20,
+ info->sector_count);
} else {
- printf (" Size: %ld KB in %d Sectors\n",
- info->size >> 10,
- info->sector_count);
+ printf(" Size: %ld KB in %d Sectors\n",
+ info->size >> 10,
+ info->sector_count);
}
- puts (" Sector Start Addresses:");
+ puts(" Sector Start Addresses:");
- for (i=0; i<info->sector_count; ++i)
- {
+ for (i = 0; i < info->sector_count; ++i) {
if ((i % 5) == 0)
- {
- puts ("\n ");
- }
+ puts("\n ");
- printf (" %08lX%s",
+ printf(" %08lX%s",
info->start[i],
info->protect[i] ? " (RO)" : " ");
}
- putc ('\n');
+ putc('\n');
return;
}
-/*-----------------------------------------------------------------------
- */
/*
* The following code cannot be run from FLASH!
*/
-static ulong flash_get_size (vu_long *addr, flash_info_t *info)
+static ulong flash_get_size(vu_long *addr, flash_info_t *info)
{
short i;
volatile unsigned char *caddr;
@@ -173,9 +175,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
/* Write auto select command: read Manufacturer ID */
-#if 0
- printf("Base address is: %08x\n", caddr);
-#endif
+ debug("Base address is: %8p\n", caddr);
caddr[0x0555] = 0xAA;
caddr[0x02AA] = 0x55;
@@ -183,51 +183,49 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
value = caddr[0];
-#if 0
- printf("Manufact ID: %02x\n", value);
-#endif
- switch (value)
- {
- case 0x01: /*AMD_MANUFACT*/
- info->flash_id = FLASH_MAN_AMD;
+ debug("Manufact ID: %02x\n", value);
+
+ switch (value) {
+ case 0x01: /*AMD_MANUFACT*/
+ info->flash_id = FLASH_MAN_AMD;
break;
- case 0x04: /*FUJ_MANUFACT*/
- info->flash_id = FLASH_MAN_FUJ;
+ case 0x04: /*FUJ_MANUFACT*/
+ info->flash_id = FLASH_MAN_FUJ;
break;
- default:
- info->flash_id = FLASH_UNKNOWN;
- info->sector_count = 0;
- info->size = 0;
- break;
+ default:
+ info->flash_id = FLASH_UNKNOWN;
+ info->sector_count = 0;
+ info->size = 0;
+ break;
}
value = caddr[1]; /* device ID */
-#if 0
- printf("Device ID: %02x\n", value);
-#endif
- switch (value)
- {
- case AMD_ID_LV040B:
- info->flash_id += FLASH_AM040;
- info->sector_count = 8;
- info->size = 0x00080000;
- break; /* => 512Kb */
-
- default:
- info->flash_id = FLASH_UNKNOWN;
- return (0); /* => no or unknown flash */
+ debug("Device ID: %02x\n", value);
+
+ switch (value) {
+ case AMD_ID_LV040B:
+ info->flash_id += FLASH_AM040;
+ info->sector_count = 8;
+ info->size = 0x00080000;
+ break; /* => 512Kb */
+
+ default:
+ info->flash_id = FLASH_UNKNOWN;
+ return 0; /* => no or unknown flash */
}
- flash_get_offsets ((ulong)addr, &flash_info[0]);
+ flash_get_offsets((ulong)addr, &flash_info[0]);
/* check for protected sectors */
- for (i = 0; i < info->sector_count; i++)
- {
- /* read sector protection at sector address, (A7 .. A0) = 0x02 */
- /* D0 = 1 if protected */
+ for (i = 0; i < info->sector_count; i++) {
+ /*
+ * read sector protection at sector address,
+ * (A7 .. A0) = 0x02
+ * D0 = 1 if protected
+ */
caddr = (volatile unsigned char *)(info->start[i]);
info->protect[i] = caddr[2] & 1;
}
@@ -235,52 +233,48 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
/*
* Prevent writes to uninitialized FLASH.
*/
- if (info->flash_id != FLASH_UNKNOWN)
- {
+ if (info->flash_id != FLASH_UNKNOWN) {
caddr = (volatile unsigned char *)info->start[0];
*caddr = 0xF0; /* reset bank */
}
- return (info->size);
+ return info->size;
}
-/*-----------------------------------------------------------------------
- */
-
-int flash_erase (flash_info_t *info, int s_first, int s_last)
+int flash_erase(flash_info_t *info, int s_first, int s_last)
{
- volatile unsigned char *addr = (volatile unsigned char *)(info->start[0]);
+ volatile unsigned char *addr =
+ (volatile unsigned char *)(info->start[0]);
int flag, prot, sect, l_sect;
ulong start, now, last;
if ((s_first < 0) || (s_first > s_last)) {
- if (info->flash_id == FLASH_UNKNOWN) {
- printf ("- missing\n");
- } else {
- printf ("- no sectors to erase\n");
- }
+ if (info->flash_id == FLASH_UNKNOWN)
+ printf("- missing\n");
+ else
+ printf("- no sectors to erase\n");
+
return 1;
}
if ((info->flash_id == FLASH_UNKNOWN) ||
(info->flash_id > FLASH_AMD_COMP)) {
- printf ("Can't erase unknown flash type - aborted\n");
+ printf("Can't erase unknown flash type - aborted\n");
return 1;
}
prot = 0;
- for (sect=s_first; sect<=s_last; ++sect) {
- if (info->protect[sect]) {
+ for (sect = s_first; sect <= s_last; ++sect) {
+ if (info->protect[sect])
prot++;
- }
}
if (prot) {
- printf ("- Warning: %d protected sectors will not be erased!\n",
+ printf("- Warning: %d protected sectors will not be erased!\n",
prot);
} else {
- printf ("\n");
+ printf("\n");
}
l_sect = -1;
@@ -295,7 +289,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
addr[0x02AA] = 0x55;
/* Start erase on unprotected sectors */
- for (sect = s_first; sect<=s_last; sect++) {
+ for (sect = s_first; sect <= s_last; sect++) {
if (info->protect[sect] == 0) { /* not protected */
addr = (volatile unsigned char *)(info->start[sect]);
addr[0] = 0x30;
@@ -308,7 +302,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
enable_interrupts();
/* wait at least 80us - let's wait 1 ms */
- udelay (1000);
+ udelay(1000);
/*
* We wait for the last triggered sector
@@ -316,19 +310,19 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
if (l_sect < 0)
goto DONE;
- start = get_timer (0);
+ start = get_timer(0);
last = start;
addr = (volatile unsigned char *)(info->start[l_sect]);
- while ((addr[0] & 0xFF) != 0xFF)
- {
- if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
- printf ("Timeout\n");
+ while ((addr[0] & 0xFF) != 0xFF) {
+ now = get_timer(start);
+ if (now > CONFIG_SYS_FLASH_ERASE_TOUT) {
+ printf("Timeout\n");
return 1;
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- putc ('.');
+ putc('.');
last = now;
}
}
@@ -339,18 +333,18 @@ DONE:
addr[0] = 0xF0; /* reset bank */
- printf (" done\n");
+ printf(" done\n");
return 0;
}
-/*-----------------------------------------------------------------------
+/*
* Copy memory to flash, returns:
* 0 - OK
* 1 - write timeout
* 2 - Flash not erased
*/
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
{
ulong cp, wp, data;
int i, l, rc;
@@ -360,23 +354,27 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
/*
* handle unaligned start bytes
*/
- if ((l = addr - wp) != 0) {
+ l = addr - wp;
+
+ if (l != 0) {
data = 0;
- for (i=0, cp=wp; i<l; ++i, ++cp) {
+ for (i = 0, cp = wp; i < l; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- for (; i<4 && cnt>0; ++i) {
+
+ for (; i < 4 && cnt > 0; ++i) {
data = (data << 8) | *src++;
--cnt;
++cp;
}
- for (; cnt==0 && i<4; ++i, ++cp) {
+
+ for (; cnt == 0 && i < 4; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- if ((rc = write_word(info, wp, data)) != 0) {
- return (rc);
- }
+ rc = write_word(info, wp, data);
+
+ if (rc != 0)
+ return rc;
+
wp += 4;
}
@@ -385,45 +383,46 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
*/
while (cnt >= 4) {
data = 0;
- for (i=0; i<4; ++i) {
+ for (i = 0; i < 4; ++i)
data = (data << 8) | *src++;
- }
- if ((rc = write_word(info, wp, data)) != 0) {
- return (rc);
- }
+
+ rc = write_word(info, wp, data);
+
+ if (rc != 0)
+ return rc;
+
wp += 4;
cnt -= 4;
}
- if (cnt == 0) {
- return (0);
- }
+ if (cnt == 0)
+ return 0;
/*
* handle unaligned tail bytes
*/
data = 0;
- for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+ for (i = 0, cp = wp; i < 4 && cnt > 0; ++i, ++cp) {
data = (data << 8) | *src++;
--cnt;
}
- for (; i<4; ++i, ++cp) {
+ for (; i < 4; ++i, ++cp)
data = (data << 8) | (*(uchar *)cp);
- }
- return (write_word(info, wp, data));
+ return write_word(info, wp, data);
}
-/*-----------------------------------------------------------------------
+/*
* Write a word to Flash, returns:
* 0 - OK
* 1 - write timeout
* 2 - Flash not erased
*/
-static int write_word (flash_info_t *info, ulong dest, ulong data)
+static int write_word(flash_info_t *info, ulong dest, ulong data)
{
- volatile unsigned char *addr = (volatile unsigned char*)(info->start[0]),
- *cdest,*cdata;
+ volatile unsigned char *cdest, *cdata;
+ volatile unsigned char *addr =
+ (volatile unsigned char *)(info->start[0]);
ulong start;
int flag, count = 4 ;
@@ -431,39 +430,32 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
cdata = (volatile unsigned char *)&data ;
/* Check if Flash is (sufficiently) erased */
- if ((*((vu_long *)dest) & data) != data) {
- return (2);
- }
+ if ((*((vu_long *)dest)&data) != data)
+ return 2;
- while(count--)
- {
- /* Disable interrupts which might cause a timeout here */
- flag = disable_interrupts();
+ while (count--) {
+ /* Disable interrupts which might cause a timeout here */
+ flag = disable_interrupts();
- addr[0x0555] = 0xAA;
- addr[0x02AA] = 0x55;
- addr[0x0555] = 0xA0;
+ addr[0x0555] = 0xAA;
+ addr[0x02AA] = 0x55;
+ addr[0x0555] = 0xA0;
- *cdest = *cdata;
+ *cdest = *cdata;
- /* re-enable interrupts if necessary */
- if (flag)
- enable_interrupts();
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
- /* data polling for D7 */
- start = get_timer (0);
- while ((*cdest ^ *cdata) & 0x80)
- {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- return (1);
+ /* data polling for D7 */
+ start = get_timer(0);
+ while ((*cdest ^ *cdata) & 0x80) {
+ if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT)
+ return 1;
}
- }
- cdata++ ;
- cdest++ ;
+ cdata++ ;
+ cdest++ ;
}
- return (0);
+ return 0;
}
-
-/*-----------------------------------------------------------------------
- */
diff --git a/board/rpxsuper/flash.c b/board/rpxsuper/flash.c
index be29b65cf44..70ae1d2ff93 100644
--- a/board/rpxsuper/flash.c
+++ b/board/rpxsuper/flash.c
@@ -47,41 +47,39 @@ static int write_word (flash_info_t *info, ulong dest, ulong data);
/*-----------------------------------------------------------------------
*/
-unsigned long flash_init (void)
+unsigned long flash_init(void)
{
- unsigned long size;
- int i;
+ int i;
- /* Init: no FLASHes known */
- for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
- flash_info[i].flash_id = FLASH_UNKNOWN;
- }
+ /* Init: no FLASHes known */
+ for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
+ flash_info[i].flash_id = FLASH_UNKNOWN;
- /* for now, only support the 4 MB Flash SIMM */
- size = flash_get_size((vu_long *)CONFIG_SYS_FLASH0_BASE, &flash_info[0]);
+ /* for now, only support the 4 MB Flash SIMM */
+ (void)flash_get_size((vu_long *) CONFIG_SYS_FLASH0_BASE,
+ &flash_info[0]);
- /*
- * protect monitor and environment sectors
- */
+ /*
+ * protect monitor and environment sectors
+ */
#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH0_BASE
- flash_protect(FLAG_PROTECT_SET,
- CONFIG_SYS_MONITOR_BASE,
- CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
- &flash_info[0]);
+ flash_protect(FLAG_PROTECT_SET,
+ CONFIG_SYS_MONITOR_BASE,
+ CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
+ &flash_info[0]);
#endif
#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
-# ifndef CONFIG_ENV_SIZE
-# define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
-# endif
- flash_protect(FLAG_PROTECT_SET,
- CONFIG_ENV_ADDR,
- CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
- &flash_info[0]);
+#ifndef CONFIG_ENV_SIZE
+#define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE
+#endif
+ flash_protect(FLAG_PROTECT_SET,
+ CONFIG_ENV_ADDR,
+ CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
#endif
- return /*size*/ (CONFIG_SYS_FLASH0_SIZE * 1024 * 1024);
+ return CONFIG_SYS_FLASH0_SIZE * 1024 * 1024;
}
/*-----------------------------------------------------------------------
diff --git a/board/sacsng/sacsng.c b/board/sacsng/sacsng.c
index 61cab87035f..536d7de0e04 100644
--- a/board/sacsng/sacsng.c
+++ b/board/sacsng/sacsng.c
@@ -39,7 +39,7 @@ extern void eth_loopback_test(void);
#endif /* CONFIG_ETHER_LOOPBACK_TEST */
#include "clkinit.h"
-#include "ioconfig.h" /* I/O configuration table */
+#include "ioconfig.h" /* I/O configuration table */
/*
* PBI Page Based Interleaving
@@ -61,88 +61,86 @@ extern void eth_loopback_test(void);
/*
* ADC/DAC Defines:
*/
-#define INITIAL_SAMPLE_RATE 10016 /* Initial Daq sample rate */
-#define INITIAL_RIGHT_JUST 0 /* Initial DAC right justification */
-#define INITIAL_MCLK_DIVIDE 0 /* Initial MCLK Divide */
-#define INITIAL_SAMPLE_64X 1 /* Initial 64x clocking mode */
-#define INITIAL_SAMPLE_128X 0 /* Initial 128x clocking mode */
+#define INITIAL_SAMPLE_RATE 10016 /* Initial Daq sample rate */
+#define INITIAL_RIGHT_JUST 0 /* Initial DAC right justification */
+#define INITIAL_MCLK_DIVIDE 0 /* Initial MCLK Divide */
+#define INITIAL_SAMPLE_64X 1 /* Initial 64x clocking mode */
+#define INITIAL_SAMPLE_128X 0 /* Initial 128x clocking mode */
/*
* ADC Defines:
*/
-#define I2C_ADC_1_ADDR 0x0E /* I2C Address of the ADC #1 */
-#define I2C_ADC_2_ADDR 0x0F /* I2C Address of the ADC #2 */
+#define I2C_ADC_1_ADDR 0x0E /* I2C Address of the ADC #1 */
+#define I2C_ADC_2_ADDR 0x0F /* I2C Address of the ADC #2 */
-#define ADC_SDATA1_MASK 0x00020000 /* PA14 - CH12SDATA_PU */
-#define ADC_SDATA2_MASK 0x00010000 /* PA15 - CH34SDATA_PU */
+#define ADC_SDATA1_MASK 0x00020000 /* PA14 - CH12SDATA_PU */
+#define ADC_SDATA2_MASK 0x00010000 /* PA15 - CH34SDATA_PU */
-#define ADC_VREF_CAP 100 /* VREF capacitor in uF */
-#define ADC_INITIAL_DELAY (10 * ADC_VREF_CAP) /* 10 usec per uF, in usec */
-#define ADC_SDATA_DELAY 100 /* ADC SDATA release delay in usec */
+#define ADC_VREF_CAP 100 /* VREF capacitor in uF */
+#define ADC_INITIAL_DELAY (10 * ADC_VREF_CAP) /* 10 usec per uF, in usec */
+#define ADC_SDATA_DELAY 100 /* ADC SDATA release delay in usec */
#define ADC_CAL_DELAY (1000000 / INITIAL_SAMPLE_RATE * 4500)
- /* Wait at least 4100 LRCLK's */
-
-#define ADC_REG1_FRAME_START 0x80 /* Frame start */
-#define ADC_REG1_GROUND_CAL 0x40 /* Ground calibration enable */
-#define ADC_REG1_ANA_MOD_PDOWN 0x20 /* Analog modulator section in power down */
-#define ADC_REG1_DIG_MOD_PDOWN 0x10 /* Digital modulator section in power down */
-
-#define ADC_REG2_128x 0x80 /* Oversample at 128x */
-#define ADC_REG2_CAL 0x40 /* System calibration enable */
-#define ADC_REG2_CHANGE_SIGN 0x20 /* Change sign enable */
-#define ADC_REG2_LR_DISABLE 0x10 /* Left/Right output disable */
-#define ADC_REG2_HIGH_PASS_DIS 0x08 /* High pass filter disable */
-#define ADC_REG2_SLAVE_MODE 0x04 /* Slave mode */
-#define ADC_REG2_DFS 0x02 /* Digital format select */
-#define ADC_REG2_MUTE 0x01 /* Mute */
-
-#define ADC_REG7_ADDR_ENABLE 0x80 /* Address enable */
-#define ADC_REG7_PEAK_ENABLE 0x40 /* Peak enable */
-#define ADC_REG7_PEAK_UPDATE 0x20 /* Peak update */
-#define ADC_REG7_PEAK_FORMAT 0x10 /* Peak display format */
-#define ADC_REG7_DIG_FILT_PDOWN 0x04 /* Digital filter power down enable */
-#define ADC_REG7_FIR2_IN_EN 0x02 /* External FIR2 input enable */
-#define ADC_REG7_PSYCHO_EN 0x01 /* External pyscho filter input enable */
+ /* Wait at least 4100 LRCLK's */
+
+#define ADC_REG1_FRAME_START 0x80 /* Frame start */
+#define ADC_REG1_GROUND_CAL 0x40 /* Ground calibration enable */
+#define ADC_REG1_ANA_MOD_PDOWN 0x20 /* Analog modulator section in power down */
+#define ADC_REG1_DIG_MOD_PDOWN 0x10 /* Digital modulator section in power down */
+
+#define ADC_REG2_128x 0x80 /* Oversample at 128x */
+#define ADC_REG2_CAL 0x40 /* System calibration enable */
+#define ADC_REG2_CHANGE_SIGN 0x20 /* Change sign enable */
+#define ADC_REG2_LR_DISABLE 0x10 /* Left/Right output disable */
+#define ADC_REG2_HIGH_PASS_DIS 0x08 /* High pass filter disable */
+#define ADC_REG2_SLAVE_MODE 0x04 /* Slave mode */
+#define ADC_REG2_DFS 0x02 /* Digital format select */
+#define ADC_REG2_MUTE 0x01 /* Mute */
+
+#define ADC_REG7_ADDR_ENABLE 0x80 /* Address enable */
+#define ADC_REG7_PEAK_ENABLE 0x40 /* Peak enable */
+#define ADC_REG7_PEAK_UPDATE 0x20 /* Peak update */
+#define ADC_REG7_PEAK_FORMAT 0x10 /* Peak display format */
+#define ADC_REG7_DIG_FILT_PDOWN 0x04 /* Digital filter power down enable */
+#define ADC_REG7_FIR2_IN_EN 0x02 /* External FIR2 input enable */
+#define ADC_REG7_PSYCHO_EN 0x01 /* External pyscho filter input enable */
/*
* DAC Defines:
*/
-#define I2C_DAC_ADDR 0x11 /* I2C Address of the DAC */
+#define I2C_DAC_ADDR 0x11 /* I2C Address of the DAC */
-#define DAC_RST_MASK 0x00008000 /* PA16 - DAC_RST* */
-#define DAC_RESET_DELAY 100 /* DAC reset delay in usec */
-#define DAC_INITIAL_DELAY 5000 /* DAC initialization delay in usec */
+#define DAC_RST_MASK 0x00008000 /* PA16 - DAC_RST* */
+#define DAC_RESET_DELAY 100 /* DAC reset delay in usec */
+#define DAC_INITIAL_DELAY 5000 /* DAC initialization delay in usec */
-#define DAC_REG1_AMUTE 0x80 /* Auto-mute */
+#define DAC_REG1_AMUTE 0x80 /* Auto-mute */
-#define DAC_REG1_LEFT_JUST_24_BIT (0 << 4) /* Fmt 0: Left justified 24 bit */
-#define DAC_REG1_I2S_24_BIT (1 << 4) /* Fmt 1: I2S up to 24 bit */
-#define DAC_REG1_RIGHT_JUST_16BIT (2 << 4) /* Fmt 2: Right justified 16 bit */
-#define DAC_REG1_RIGHT_JUST_24BIT (3 << 4) /* Fmt 3: Right justified 24 bit */
-#define DAC_REG1_RIGHT_JUST_20BIT (4 << 4) /* Fmt 4: Right justified 20 bit */
-#define DAC_REG1_RIGHT_JUST_18BIT (5 << 4) /* Fmt 5: Right justified 18 bit */
+#define DAC_REG1_LEFT_JUST_24_BIT (0 << 4) /* Fmt 0: Left justified 24 bit */
+#define DAC_REG1_I2S_24_BIT (1 << 4) /* Fmt 1: I2S up to 24 bit */
+#define DAC_REG1_RIGHT_JUST_16BIT (2 << 4) /* Fmt 2: Right justified 16 bit */
+#define DAC_REG1_RIGHT_JUST_24BIT (3 << 4) /* Fmt 3: Right justified 24 bit */
+#define DAC_REG1_RIGHT_JUST_20BIT (4 << 4) /* Fmt 4: Right justified 20 bit */
+#define DAC_REG1_RIGHT_JUST_18BIT (5 << 4) /* Fmt 5: Right justified 18 bit */
-#define DAC_REG1_DEM_NO (0 << 2) /* No De-emphasis */
-#define DAC_REG1_DEM_44KHZ (1 << 2) /* 44.1KHz De-emphasis */
-#define DAC_REG1_DEM_48KHZ (2 << 2) /* 48KHz De-emphasis */
-#define DAC_REG1_DEM_32KHZ (3 << 2) /* 32KHz De-emphasis */
+#define DAC_REG1_DEM_NO (0 << 2) /* No De-emphasis */
+#define DAC_REG1_DEM_44KHZ (1 << 2) /* 44.1KHz De-emphasis */
+#define DAC_REG1_DEM_48KHZ (2 << 2) /* 48KHz De-emphasis */
+#define DAC_REG1_DEM_32KHZ (3 << 2) /* 32KHz De-emphasis */
-#define DAC_REG1_SINGLE 0 /* 4- 50KHz sample rate */
-#define DAC_REG1_DOUBLE 1 /* 50-100KHz sample rate */
-#define DAC_REG1_QUAD 2 /* 100-200KHz sample rate */
-#define DAC_REG1_DSD 3 /* Direct Stream Data, DSD */
+#define DAC_REG1_SINGLE 0 /* 4- 50KHz sample rate */
+#define DAC_REG1_DOUBLE 1 /* 50-100KHz sample rate */
+#define DAC_REG1_QUAD 2 /* 100-200KHz sample rate */
+#define DAC_REG1_DSD 3 /* Direct Stream Data, DSD */
-#define DAC_REG5_INVERT_A 0x80 /* Invert channel A */
-#define DAC_REG5_INVERT_B 0x40 /* Invert channel B */
-#define DAC_REG5_I2C_MODE 0x20 /* Control port (I2C) mode */
-#define DAC_REG5_POWER_DOWN 0x10 /* Power down mode */
-#define DAC_REG5_MUTEC_A_B 0x08 /* Mutec A=B */
-#define DAC_REG5_FREEZE 0x04 /* Freeze */
-#define DAC_REG5_MCLK_DIV 0x02 /* MCLK divide by 2 */
-#define DAC_REG5_RESERVED 0x01 /* Reserved */
-
-/* ------------------------------------------------------------------------- */
+#define DAC_REG5_INVERT_A 0x80 /* Invert channel A */
+#define DAC_REG5_INVERT_B 0x40 /* Invert channel B */
+#define DAC_REG5_I2C_MODE 0x20 /* Control port (I2C) mode */
+#define DAC_REG5_POWER_DOWN 0x10 /* Power down mode */
+#define DAC_REG5_MUTEC_A_B 0x08 /* Mutec A=B */
+#define DAC_REG5_FREEZE 0x04 /* Freeze */
+#define DAC_REG5_MCLK_DIV 0x02 /* MCLK divide by 2 */
+#define DAC_REG5_RESERVED 0x01 /* Reserved */
/*
* Check Board Identity:
@@ -150,290 +148,297 @@ extern void eth_loopback_test(void);
int checkboard(void)
{
- printf ("SACSng\n");
+ printf("SACSng\n");
- return 0;
+ return 0;
}
-/* ------------------------------------------------------------------------- */
-
phys_size_t initdram(int board_type)
{
- volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
- volatile memctl8260_t *memctl = &immap->im_memctl;
- volatile uchar c = 0;
- volatile uchar *ramaddr = (uchar *)(CONFIG_SYS_SDRAM_BASE + 0x8);
- uint psdmr = CONFIG_SYS_PSDMR;
- int i;
- uint psrt = 14; /* for no SPD */
- uint chipselects = 1; /* for no SPD */
- uint sdram_size = CONFIG_SYS_SDRAM0_SIZE * 1024 * 1024; /* for no SPD */
- uint or = CONFIG_SYS_OR2_PRELIM; /* for no SPD */
+ volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
+ volatile memctl8260_t *memctl = &immap->im_memctl;
+ volatile uchar c = 0;
+ volatile uchar *ramaddr = (uchar *)(CONFIG_SYS_SDRAM_BASE + 0x8);
+ uint psdmr = CONFIG_SYS_PSDMR;
+ int i;
+ uint psrt = 14; /* for no SPD */
+ uint chipselects = 1; /* for no SPD */
+ uint sdram_size = CONFIG_SYS_SDRAM0_SIZE * 1024 * 1024; /* for no SPD */
+ uint or = CONFIG_SYS_OR2_PRELIM; /* for no SPD */
+
#ifdef SDRAM_SPD_ADDR
- uint data_width;
- uint rows;
- uint banks;
- uint cols;
- uint caslatency;
- uint width;
- uint rowst;
- uint sdam;
- uint bsma;
- uint sda10;
- u_char spd_size;
- u_char data;
- u_char cksum;
- int j;
+ uint data_width;
+ uint rows;
+ uint banks;
+ uint cols;
+ uint caslatency;
+ uint width;
+ uint rowst;
+ uint sdam;
+ uint bsma;
+ uint sda10;
+ u_char data;
+ u_char cksum;
+ int j;
#endif
#ifdef SDRAM_SPD_ADDR
- /* Keep the compiler from complaining about potentially uninitialized vars */
- data_width = chipselects = rows = banks = cols = caslatency = psrt = 0;
-
- /*
- * Read the SDRAM SPD EEPROM via I2C.
- */
- i2c_read(SDRAM_SPD_ADDR, 0, 1, &data, 1);
- spd_size = data;
- cksum = data;
- for(j = 1; j < 64; j++) { /* read only the checksummed bytes */
- /* note: the I2C address autoincrements when alen == 0 */
- i2c_read(SDRAM_SPD_ADDR, 0, 0, &data, 1);
- if(j == 5) chipselects = data & 0x0F;
- else if(j == 6) data_width = data;
- else if(j == 7) data_width |= data << 8;
- else if(j == 3) rows = data & 0x0F;
- else if(j == 4) cols = data & 0x0F;
- else if(j == 12) {
- /*
- * Refresh rate: this assumes the prescaler is set to
- * approximately 1uSec per tick.
- */
- switch(data & 0x7F) {
- default:
- case 0: psrt = 14 ; /* 15.625uS */ break;
- case 1: psrt = 2; /* 3.9uS */ break;
- case 2: psrt = 6; /* 7.8uS */ break;
- case 3: psrt = 29; /* 31.3uS */ break;
- case 4: psrt = 60; /* 62.5uS */ break;
- case 5: psrt = 120; /* 125uS */ break;
- }
- }
- else if(j == 17) banks = data;
- else if(j == 18) {
- caslatency = 3; /* default CL */
+ /* Keep the compiler from complaining about potentially uninitialized vars */
+ data_width = chipselects = rows = banks = cols = caslatency = psrt =
+ 0;
+
+ /*
+ * Read the SDRAM SPD EEPROM via I2C.
+ */
+ i2c_read(SDRAM_SPD_ADDR, 0, 1, &data, 1);
+ cksum = data;
+ for (j = 1; j < 64; j++) { /* read only the checksummed bytes */
+ /* note: the I2C address autoincrements when alen == 0 */
+ i2c_read(SDRAM_SPD_ADDR, 0, 0, &data, 1);
+ if (j == 5)
+ chipselects = data & 0x0F;
+ else if (j == 6)
+ data_width = data;
+ else if (j == 7)
+ data_width |= data << 8;
+ else if (j == 3)
+ rows = data & 0x0F;
+ else if (j == 4)
+ cols = data & 0x0F;
+ else if (j == 12) {
+ /*
+ * Refresh rate: this assumes the prescaler is set to
+ * approximately 1uSec per tick.
+ */
+ switch (data & 0x7F) {
+ default:
+ case 0:
+ psrt = 14; /* 15.625uS */
+ break;
+ case 1:
+ psrt = 2; /* 3.9uS */
+ break;
+ case 2:
+ psrt = 6; /* 7.8uS */
+ break;
+ case 3:
+ psrt = 29; /* 31.3uS */
+ break;
+ case 4:
+ psrt = 60; /* 62.5uS */
+ break;
+ case 5:
+ psrt = 120; /* 125uS */
+ break;
+ }
+ } else if (j == 17)
+ banks = data;
+ else if (j == 18) {
+ caslatency = 3; /* default CL */
#if(PESSIMISTIC_SDRAM)
- if((data & 0x04) != 0) caslatency = 3;
- else if((data & 0x02) != 0) caslatency = 2;
- else if((data & 0x01) != 0) caslatency = 1;
+ if ((data & 0x04) != 0)
+ caslatency = 3;
+ else if ((data & 0x02) != 0)
+ caslatency = 2;
+ else if ((data & 0x01) != 0)
+ caslatency = 1;
#else
- if((data & 0x01) != 0) caslatency = 1;
- else if((data & 0x02) != 0) caslatency = 2;
- else if((data & 0x04) != 0) caslatency = 3;
+ if ((data & 0x01) != 0)
+ caslatency = 1;
+ else if ((data & 0x02) != 0)
+ caslatency = 2;
+ else if ((data & 0x04) != 0)
+ caslatency = 3;
#endif
- else {
- printf ("WARNING: Unknown CAS latency 0x%02X, using 3\n",
- data);
- }
+ else {
+ printf("WARNING: Unknown CAS latency 0x%02X, using 3\n", data);
+ }
+ } else if (j == 63) {
+ if (data != cksum) {
+ printf("WARNING: Configuration data checksum failure:" " is 0x%02x, calculated 0x%02x\n", data, cksum);
+ }
+ }
+ cksum += data;
}
- else if(j == 63) {
- if(data != cksum) {
- printf ("WARNING: Configuration data checksum failure:"
- " is 0x%02x, calculated 0x%02x\n",
- data, cksum);
- }
+
+ /* We don't trust CL less than 2 (only saw it on an old 16MByte DIMM) */
+ if (caslatency < 2) {
+ printf("WARNING: CL was %d, forcing to 2\n", caslatency);
+ caslatency = 2;
+ }
+ if (rows > 14) {
+ printf("WARNING: This doesn't look good, rows = %d, should be <= 14\n",
+ rows);
+ rows = 14;
+ }
+ if (cols > 11) {
+ printf("WARNING: This doesn't look good, columns = %d, should be <= 11\n",
+ cols);
+ cols = 11;
+ }
+
+ if ((data_width != 64) && (data_width != 72)) {
+ printf("WARNING: SDRAM width unsupported, is %d, expected 64 or 72.\n",
+ data_width);
}
- cksum += data;
- }
-
- /* We don't trust CL less than 2 (only saw it on an old 16MByte DIMM) */
- if(caslatency < 2) {
- printf("WARNING: CL was %d, forcing to 2\n", caslatency);
- caslatency = 2;
- }
- if(rows > 14) {
- printf("WARNING: This doesn't look good, rows = %d, should be <= 14\n", rows);
- rows = 14;
- }
- if(cols > 11) {
- printf("WARNING: This doesn't look good, columns = %d, should be <= 11\n", cols);
- cols = 11;
- }
-
- if((data_width != 64) && (data_width != 72))
- {
- printf("WARNING: SDRAM width unsupported, is %d, expected 64 or 72.\n",
- data_width);
- }
- width = 3; /* 2^3 = 8 bytes = 64 bits wide */
- /*
- * Convert banks into log2(banks)
- */
- if (banks == 2) banks = 1;
- else if(banks == 4) banks = 2;
- else if(banks == 8) banks = 3;
-
- sdram_size = 1 << (rows + cols + banks + width);
-
-#if(CONFIG_PBI == 0) /* bank-based interleaving */
- rowst = ((32 - 6) - (rows + cols + width)) * 2;
+ width = 3; /* 2^3 = 8 bytes = 64 bits wide */
+ /*
+ * Convert banks into log2(banks)
+ */
+ if (banks == 2)
+ banks = 1;
+ else if (banks == 4)
+ banks = 2;
+ else if (banks == 8)
+ banks = 3;
+
+ sdram_size = 1 << (rows + cols + banks + width);
+
+#if(CONFIG_PBI == 0) /* bank-based interleaving */
+ rowst = ((32 - 6) - (rows + cols + width)) * 2;
#else
- rowst = 32 - (rows + banks + cols + width);
+ rowst = 32 - (rows + banks + cols + width);
#endif
- or = ~(sdram_size - 1) | /* SDAM address mask */
- ((banks-1) << 13) | /* banks per device */
- (rowst << 9) | /* rowst */
- ((rows - 9) << 6); /* numr */
-
- memctl->memc_or2 = or;
-
- /*
- * SDAM specifies the number of columns that are multiplexed
- * (reference AN2165/D), defined to be (columns - 6) for page
- * interleave, (columns - 8) for bank interleave.
- *
- * BSMA is 14 - max(rows, cols). The bank select lines come
- * into play above the highest "address" line going into the
- * the SDRAM.
- */
-#if(CONFIG_PBI == 0) /* bank-based interleaving */
- sdam = cols - 8;
- bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
- sda10 = sdam + 2;
+ or = ~(sdram_size - 1) | /* SDAM address mask */
+ ((banks - 1) << 13) | /* banks per device */
+ (rowst << 9) | /* rowst */
+ ((rows - 9) << 6); /* numr */
+
+ memctl->memc_or2 = or;
+
+ /*
+ * SDAM specifies the number of columns that are multiplexed
+ * (reference AN2165/D), defined to be (columns - 6) for page
+ * interleave, (columns - 8) for bank interleave.
+ *
+ * BSMA is 14 - max(rows, cols). The bank select lines come
+ * into play above the highest "address" line going into the
+ * the SDRAM.
+ */
+#if(CONFIG_PBI == 0) /* bank-based interleaving */
+ sdam = cols - 8;
+ bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
+ sda10 = sdam + 2;
#else
- sdam = cols - 6;
- bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
- sda10 = sdam;
+ sdam = cols - 6;
+ bsma = ((31 - width) - 14) - ((rows > cols) ? rows : cols);
+ sda10 = sdam;
#endif
#if(PESSIMISTIC_SDRAM)
- psdmr = (CONFIG_PBI |\
- PSDMR_RFEN |\
- PSDMR_RFRC_16_CLK |\
- PSDMR_PRETOACT_8W |\
- PSDMR_ACTTORW_8W |\
- PSDMR_WRC_4C |\
- PSDMR_EAMUX |\
- PSDMR_BUFCMD) |\
- caslatency |\
- ((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */ \
- (sdam << 24) |\
- (bsma << 21) |\
- (sda10 << 18);
+ psdmr = (CONFIG_PBI | PSDMR_RFEN | PSDMR_RFRC_16_CLK |
+ PSDMR_PRETOACT_8W | PSDMR_ACTTORW_8W | PSDMR_WRC_4C |
+ PSDMR_EAMUX | PSDMR_BUFCMD) | caslatency |
+ ((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */
+ (sdam << 24) | (bsma << 21) | (sda10 << 18);
#else
- psdmr = (CONFIG_PBI |\
- PSDMR_RFEN |\
- PSDMR_RFRC_7_CLK |\
- PSDMR_PRETOACT_3W | /* 1 for 7E parts (fast PC-133) */ \
- PSDMR_ACTTORW_2W | /* 1 for 7E parts (fast PC-133) */ \
- PSDMR_WRC_1C | /* 1 clock + 7nSec */
- EAMUX |\
- BUFCMD) |\
- caslatency |\
- ((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */ \
- (sdam << 24) |\
- (bsma << 21) |\
- (sda10 << 18);
+ psdmr = (CONFIG_PBI | PSDMR_RFEN | PSDMR_RFRC_7_CLK |
+ PSDMR_PRETOACT_3W | /* 1 for 7E parts (fast PC-133) */
+ PSDMR_ACTTORW_2W | /* 1 for 7E parts (fast PC-133) */
+ PSDMR_WRC_1C | /* 1 clock + 7nSec */
+ EAMUX | BUFCMD) |
+ caslatency | ((caslatency - 1) << 6) | /* LDOTOPRE is CL - 1 */
+ (sdam << 24) | (bsma << 21) | (sda10 << 18);
#endif
#endif
- /*
- * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
- *
- * "At system reset, initialization software must set up the
- * programmable parameters in the memory controller banks registers
- * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
- * system software should execute the following initialization sequence
- * for each SDRAM device.
- *
- * 1. Issue a PRECHARGE-ALL-BANKS command
- * 2. Issue eight CBR REFRESH commands
- * 3. Issue a MODE-SET command to initialize the mode register
- *
- * Quote from Micron MT48LC8M16A2 data sheet:
- *
- * "...the SDRAM requires a 100uS delay prior to issuing any
- * command other than a COMMAND INHIBIT or NOP. Starting at some
- * point during this 100uS period and continuing at least through
- * the end of this period, COMMAND INHIBIT or NOP commands should
- * be applied."
- *
- * "Once the 100uS delay has been satisfied with at least one COMMAND
- * INHIBIT or NOP command having been applied, a /PRECHARGE command/
- * should be applied. All banks must then be precharged, thereby
- * placing the device in the all banks idle state."
- *
- * "Once in the idle state, /two/ AUTO REFRESH cycles must be
- * performed. After the AUTO REFRESH cycles are complete, the
- * SDRAM is ready for mode register programming."
- *
- * (/emphasis/ mine, gvb)
- *
- * The way I interpret this, Micron start up sequence is:
- * 1. Issue a PRECHARGE-BANK command (initial precharge)
- * 2. Issue a PRECHARGE-ALL-BANKS command ("all banks ... precharged")
- * 3. Issue two (presumably, doing eight is OK) CBR REFRESH commands
- * 4. Issue a MODE-SET command to initialize the mode register
- *
- * --------
- *
- * The initial commands are executed by setting P/LSDMR[OP] and
- * accessing the SDRAM with a single-byte transaction."
- *
- * The appropriate BRx/ORx registers have already been set when we
- * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
- */
-
- memctl->memc_mptpr = CONFIG_SYS_MPTPR;
- memctl->memc_psrt = psrt;
-
- memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
- *ramaddr = c;
-
- memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
- for (i = 0; i < 8; i++)
- *ramaddr = c;
-
- memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
- *ramaddr = c;
-
- memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
- *ramaddr = c;
-
- /*
- * Do it a second time for the second set of chips if the DIMM has
- * two chip selects (double sided).
- */
- if(chipselects > 1) {
- ramaddr += sdram_size;
+ /*
+ * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
+ *
+ * "At system reset, initialization software must set up the
+ * programmable parameters in the memory controller banks registers
+ * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
+ * system software should execute the following initialization sequence
+ * for each SDRAM device.
+ *
+ * 1. Issue a PRECHARGE-ALL-BANKS command
+ * 2. Issue eight CBR REFRESH commands
+ * 3. Issue a MODE-SET command to initialize the mode register
+ *
+ * Quote from Micron MT48LC8M16A2 data sheet:
+ *
+ * "...the SDRAM requires a 100uS delay prior to issuing any
+ * command other than a COMMAND INHIBIT or NOP. Starting at some
+ * point during this 100uS period and continuing at least through
+ * the end of this period, COMMAND INHIBIT or NOP commands should
+ * be applied."
+ *
+ * "Once the 100uS delay has been satisfied with at least one COMMAND
+ * INHIBIT or NOP command having been applied, a /PRECHARGE command/
+ * should be applied. All banks must then be precharged, thereby
+ * placing the device in the all banks idle state."
+ *
+ * "Once in the idle state, /two/ AUTO REFRESH cycles must be
+ * performed. After the AUTO REFRESH cycles are complete, the
+ * SDRAM is ready for mode register programming."
+ *
+ * (/emphasis/ mine, gvb)
+ *
+ * The way I interpret this, Micron start up sequence is:
+ * 1. Issue a PRECHARGE-BANK command (initial precharge)
+ * 2. Issue a PRECHARGE-ALL-BANKS command ("all banks ... precharged")
+ * 3. Issue two (presumably, doing eight is OK) CBR REFRESH commands
+ * 4. Issue a MODE-SET command to initialize the mode register
+ *
+ * --------
+ *
+ * The initial commands are executed by setting P/LSDMR[OP] and
+ * accessing the SDRAM with a single-byte transaction."
+ *
+ * The appropriate BRx/ORx registers have already been set when we
+ * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
+ */
- memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM + sdram_size;
- memctl->memc_or3 = or;
+ memctl->memc_mptpr = CONFIG_SYS_MPTPR;
+ memctl->memc_psrt = psrt;
memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
*ramaddr = c;
memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
for (i = 0; i < 8; i++)
- *ramaddr = c;
+ *ramaddr = c;
memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
*ramaddr = c;
memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
*ramaddr = c;
- }
- /* return total ram size */
- return (sdram_size * chipselects);
+ /*
+ * Do it a second time for the second set of chips if the DIMM has
+ * two chip selects (double sided).
+ */
+ if (chipselects > 1) {
+ ramaddr += sdram_size;
+
+ memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM + sdram_size;
+ memctl->memc_or3 = or;
+
+ memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
+ *ramaddr = c;
+
+ memctl->memc_psdmr = psdmr | PSDMR_OP_CBRR;
+ for (i = 0; i < 8; i++)
+ *ramaddr = c;
+
+ memctl->memc_psdmr = psdmr | PSDMR_OP_MRW;
+ *ramaddr = c;
+
+ memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
+ *ramaddr = c;
+ }
+
+ /* return total ram size */
+ return (sdram_size * chipselects);
}
/*-----------------------------------------------------------------------
* Board Control Functions
*/
-void board_poweroff (void)
+void board_poweroff(void)
{
- while (1); /* hang forever */
+ while (1); /* hang forever */
}
@@ -441,301 +446,288 @@ void board_poweroff (void)
/* ------------------------------------------------------------------------- */
int misc_init_r(void)
{
- /*
- * Note: iop is used by the I2C macros, and iopa by the ADC/DAC initialization.
- */
- volatile ioport_t *iopa = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 0 /* port A */);
- volatile ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT);
-
- int reg; /* I2C register value */
- char *ep; /* Environment pointer */
- char str_buf[12] ; /* sprintf output buffer */
- int sample_rate; /* ADC/DAC sample rate */
- int sample_64x; /* Use 64/4 clocking for the ADC/DAC */
- int sample_128x; /* Use 128/4 clocking for the ADC/DAC */
- int right_just; /* Is the data to the DAC right justified? */
- int mclk_divide; /* MCLK Divide */
- int quiet; /* Quiet or minimal output mode */
-
- quiet = 0;
- if ((ep = getenv("quiet")) != NULL) {
- quiet = simple_strtol(ep, NULL, 10);
- }
- else {
- setenv("quiet", "0");
- }
-
- /*
- * SACSng custom initialization:
- * Start the ADC and DAC clocks, since the Crystal parts do not
- * work on the I2C bus until the clocks are running.
- */
-
- sample_rate = INITIAL_SAMPLE_RATE;
- if ((ep = getenv("DaqSampleRate")) != NULL) {
- sample_rate = simple_strtol(ep, NULL, 10);
- }
-
- sample_64x = INITIAL_SAMPLE_64X;
- sample_128x = INITIAL_SAMPLE_128X;
- if ((ep = getenv("Daq64xSampling")) != NULL) {
- sample_64x = simple_strtol(ep, NULL, 10);
+ /*
+ * Note: iop is used by the I2C macros, and iopa by the ADC/DAC initialization.
+ */
+ volatile ioport_t *iopa =
+ ioport_addr((immap_t *)CONFIG_SYS_IMMR, 0 /* port A */ );
+ volatile ioport_t *iop =
+ ioport_addr((immap_t *)CONFIG_SYS_IMMR, I2C_PORT);
+
+ int reg; /* I2C register value */
+ char *ep; /* Environment pointer */
+ char str_buf[12]; /* sprintf output buffer */
+ int sample_rate; /* ADC/DAC sample rate */
+ int sample_64x; /* Use 64/4 clocking for the ADC/DAC */
+ int sample_128x; /* Use 128/4 clocking for the ADC/DAC */
+ int right_just; /* Is the data to the DAC right justified? */
+ int mclk_divide; /* MCLK Divide */
+ int quiet; /* Quiet or minimal output mode */
+
+ quiet = 0;
+
+ if ((ep = getenv("quiet")) != NULL)
+ quiet = simple_strtol(ep, NULL, 10);
+ else
+ setenv("quiet", "0");
+
+ /*
+ * SACSng custom initialization:
+ * Start the ADC and DAC clocks, since the Crystal parts do not
+ * work on the I2C bus until the clocks are running.
+ */
+
+ sample_rate = INITIAL_SAMPLE_RATE;
+ if ((ep = getenv("DaqSampleRate")) != NULL)
+ sample_rate = simple_strtol(ep, NULL, 10);
+
+ sample_64x = INITIAL_SAMPLE_64X;
+ sample_128x = INITIAL_SAMPLE_128X;
+ if ((ep = getenv("Daq64xSampling")) != NULL) {
+ sample_64x = simple_strtol(ep, NULL, 10);
+ if (sample_64x)
+ sample_128x = 0;
+ else
+ sample_128x = 1;
+ } else {
+ if ((ep = getenv("Daq128xSampling")) != NULL) {
+ sample_128x = simple_strtol(ep, NULL, 10);
+ if (sample_128x)
+ sample_64x = 0;
+ else
+ sample_64x = 1;
+ }
+ }
+
+ /*
+ * Stop the clocks and wait for at least 1 LRCLK period
+ * to make sure the clocking has really stopped.
+ */
+ Daq_Stop_Clocks();
+ udelay((1000000 / sample_rate) * NUM_LRCLKS_TO_STABILIZE);
+
+ /*
+ * Initialize the clocks with the new rates
+ */
+ Daq_Init_Clocks(sample_rate, sample_64x);
+ sample_rate = Daq_Get_SampleRate();
+
+ /*
+ * Start the clocks and wait for at least 1 LRCLK period
+ * to make sure the clocking has become stable.
+ */
+ Daq_Start_Clocks(sample_rate);
+ udelay((1000000 / sample_rate) * NUM_LRCLKS_TO_STABILIZE);
+
+ sprintf(str_buf, "%d", sample_rate);
+ setenv("DaqSampleRate", str_buf);
+
if (sample_64x) {
- sample_128x = 0;
+ setenv("Daq64xSampling", "1");
+ setenv("Daq128xSampling", NULL);
+ } else {
+ setenv("Daq64xSampling", NULL);
+ setenv("Daq128xSampling", "1");
}
- else {
- sample_128x = 1;
+
+ /*
+ * Display the ADC/DAC clocking information
+ */
+ if (!quiet)
+ Daq_Display_Clocks();
+
+ /*
+ * Determine the DAC data justification
+ */
+
+ right_just = INITIAL_RIGHT_JUST;
+ if ((ep = getenv("DaqDACRightJustified")) != NULL)
+ right_just = simple_strtol(ep, NULL, 10);
+
+ sprintf(str_buf, "%d", right_just);
+ setenv("DaqDACRightJustified", str_buf);
+
+ /*
+ * Determine the DAC MCLK Divide
+ */
+
+ mclk_divide = INITIAL_MCLK_DIVIDE;
+ if ((ep = getenv("DaqDACMClockDivide")) != NULL)
+ mclk_divide = simple_strtol(ep, NULL, 10);
+
+ sprintf(str_buf, "%d", mclk_divide);
+ setenv("DaqDACMClockDivide", str_buf);
+
+ /*
+ * Initializing the I2C address in the Crystal A/Ds:
+ *
+ * 1) Wait for VREF cap to settle (10uSec per uF)
+ * 2) Release pullup on SDATA
+ * 3) Write the I2C address to register 6
+ * 4) Enable address matching by setting the MSB in register 7
+ */
+
+ if (!quiet)
+ printf("Initializing the ADC...\n");
+
+ udelay(ADC_INITIAL_DELAY); /* 10uSec per uF of VREF cap */
+
+ iopa->pdat &= ~ADC_SDATA1_MASK; /* release SDATA1 */
+ udelay(ADC_SDATA_DELAY); /* arbitrary settling time */
+
+ i2c_reg_write(0x00, 0x06, I2C_ADC_1_ADDR); /* set address */
+ i2c_reg_write(I2C_ADC_1_ADDR, 0x07, /* turn on ADDREN */
+ ADC_REG7_ADDR_ENABLE);
+
+ i2c_reg_write(I2C_ADC_1_ADDR, 0x02, /* 128x, slave mode, !HPEN */
+ (sample_64x ? 0 : ADC_REG2_128x) |
+ ADC_REG2_HIGH_PASS_DIS | ADC_REG2_SLAVE_MODE);
+
+ reg = i2c_reg_read(I2C_ADC_1_ADDR, 0x06) & 0x7F;
+ if (reg != I2C_ADC_1_ADDR) {
+ printf("Init of ADC U10 failed: address is 0x%02X should be 0x%02X\n",
+ reg, I2C_ADC_1_ADDR);
}
- }
- else {
- if ((ep = getenv("Daq128xSampling")) != NULL) {
- sample_128x = simple_strtol(ep, NULL, 10);
- if (sample_128x) {
- sample_64x = 0;
- }
- else {
- sample_64x = 1;
- }
+
+ iopa->pdat &= ~ADC_SDATA2_MASK; /* release SDATA2 */
+ udelay(ADC_SDATA_DELAY); /* arbitrary settling time */
+
+ /* set address (do not set ADDREN yet) */
+ i2c_reg_write(0x00, 0x06, I2C_ADC_2_ADDR);
+
+ i2c_reg_write(I2C_ADC_2_ADDR, 0x02, /* 64x, slave mode, !HPEN */
+ (sample_64x ? 0 : ADC_REG2_128x) |
+ ADC_REG2_HIGH_PASS_DIS | ADC_REG2_SLAVE_MODE);
+
+ reg = i2c_reg_read(I2C_ADC_2_ADDR, 0x06) & 0x7F;
+ if (reg != I2C_ADC_2_ADDR) {
+ printf("Init of ADC U15 failed: address is 0x%02X should be 0x%02X\n",
+ reg, I2C_ADC_2_ADDR);
}
- }
-
- /*
- * Stop the clocks and wait for at least 1 LRCLK period
- * to make sure the clocking has really stopped.
- */
- Daq_Stop_Clocks();
- udelay((1000000 / sample_rate) * NUM_LRCLKS_TO_STABILIZE);
-
- /*
- * Initialize the clocks with the new rates
- */
- Daq_Init_Clocks(sample_rate, sample_64x);
- sample_rate = Daq_Get_SampleRate();
-
- /*
- * Start the clocks and wait for at least 1 LRCLK period
- * to make sure the clocking has become stable.
- */
- Daq_Start_Clocks(sample_rate);
- udelay((1000000 / sample_rate) * NUM_LRCLKS_TO_STABILIZE);
-
- sprintf(str_buf, "%d", sample_rate);
- setenv("DaqSampleRate", str_buf);
-
- if (sample_64x) {
- setenv("Daq64xSampling", "1");
- setenv("Daq128xSampling", NULL);
- }
- else {
- setenv("Daq64xSampling", NULL);
- setenv("Daq128xSampling", "1");
- }
-
- /*
- * Display the ADC/DAC clocking information
- */
- if (!quiet) {
- Daq_Display_Clocks();
- }
-
- /*
- * Determine the DAC data justification
- */
-
- right_just = INITIAL_RIGHT_JUST;
- if ((ep = getenv("DaqDACRightJustified")) != NULL) {
- right_just = simple_strtol(ep, NULL, 10);
- }
-
- sprintf(str_buf, "%d", right_just);
- setenv("DaqDACRightJustified", str_buf);
-
- /*
- * Determine the DAC MCLK Divide
- */
-
- mclk_divide = INITIAL_MCLK_DIVIDE;
- if ((ep = getenv("DaqDACMClockDivide")) != NULL) {
- mclk_divide = simple_strtol(ep, NULL, 10);
- }
-
- sprintf(str_buf, "%d", mclk_divide);
- setenv("DaqDACMClockDivide", str_buf);
-
- /*
- * Initializing the I2C address in the Crystal A/Ds:
- *
- * 1) Wait for VREF cap to settle (10uSec per uF)
- * 2) Release pullup on SDATA
- * 3) Write the I2C address to register 6
- * 4) Enable address matching by setting the MSB in register 7
- */
-
- if (!quiet) {
- printf("Initializing the ADC...\n");
- }
- udelay(ADC_INITIAL_DELAY); /* 10uSec per uF of VREF cap */
-
- iopa->pdat &= ~ADC_SDATA1_MASK; /* release SDATA1 */
- udelay(ADC_SDATA_DELAY); /* arbitrary settling time */
-
- i2c_reg_write(0x00, 0x06, I2C_ADC_1_ADDR); /* set address */
- i2c_reg_write(I2C_ADC_1_ADDR, 0x07, /* turn on ADDREN */
- ADC_REG7_ADDR_ENABLE);
-
- i2c_reg_write(I2C_ADC_1_ADDR, 0x02, /* 128x, slave mode, !HPEN */
- (sample_64x ? 0 : ADC_REG2_128x) |
- ADC_REG2_HIGH_PASS_DIS |
- ADC_REG2_SLAVE_MODE);
-
- reg = i2c_reg_read(I2C_ADC_1_ADDR, 0x06) & 0x7F;
- if(reg != I2C_ADC_1_ADDR)
- printf("Init of ADC U10 failed: address is 0x%02X should be 0x%02X\n",
- reg, I2C_ADC_1_ADDR);
-
- iopa->pdat &= ~ADC_SDATA2_MASK; /* release SDATA2 */
- udelay(ADC_SDATA_DELAY); /* arbitrary settling time */
-
- i2c_reg_write(0x00, 0x06, I2C_ADC_2_ADDR); /* set address (do not set ADDREN yet) */
-
- i2c_reg_write(I2C_ADC_2_ADDR, 0x02, /* 64x, slave mode, !HPEN */
- (sample_64x ? 0 : ADC_REG2_128x) |
- ADC_REG2_HIGH_PASS_DIS |
- ADC_REG2_SLAVE_MODE);
-
- reg = i2c_reg_read(I2C_ADC_2_ADDR, 0x06) & 0x7F;
- if(reg != I2C_ADC_2_ADDR)
- printf("Init of ADC U15 failed: address is 0x%02X should be 0x%02X\n",
- reg, I2C_ADC_2_ADDR);
-
- i2c_reg_write(I2C_ADC_1_ADDR, 0x01, /* set FSTART and GNDCAL */
- ADC_REG1_FRAME_START |
- ADC_REG1_GROUND_CAL);
-
- i2c_reg_write(I2C_ADC_1_ADDR, 0x02, /* Start calibration */
- (sample_64x ? 0 : ADC_REG2_128x) |
- ADC_REG2_CAL |
- ADC_REG2_HIGH_PASS_DIS |
- ADC_REG2_SLAVE_MODE);
-
- udelay(ADC_CAL_DELAY); /* a minimum of 4100 LRCLKs */
- i2c_reg_write(I2C_ADC_1_ADDR, 0x01, 0x00); /* remove GNDCAL */
-
- /*
- * Now that we have synchronized the ADC's, enable address
- * selection on the second ADC as well as the first.
- */
- i2c_reg_write(I2C_ADC_2_ADDR, 0x07, ADC_REG7_ADDR_ENABLE);
-
- /*
- * Initialize the Crystal DAC
- *
- * Two of the config lines are used for I2C so we have to set them
- * to the proper initialization state without inadvertantly
- * sending an I2C "start" sequence. When we bring the I2C back to
- * the normal state, we send an I2C "stop" sequence.
- */
- if (!quiet) {
- printf("Initializing the DAC...\n");
- }
-
- /*
- * Bring the I2C clock and data lines low for initialization
- */
- I2C_SCL(0);
- I2C_DELAY;
- I2C_SDA(0);
- I2C_ACTIVE;
- I2C_DELAY;
-
- /* Reset the DAC */
- iopa->pdat &= ~DAC_RST_MASK;
- udelay(DAC_RESET_DELAY);
-
- /* Release the DAC reset */
- iopa->pdat |= DAC_RST_MASK;
- udelay(DAC_INITIAL_DELAY);
-
- /*
- * Cause the DAC to:
- * Enable control port (I2C mode)
- * Going into power down
- */
- i2c_reg_write(I2C_DAC_ADDR, 0x05,
- DAC_REG5_I2C_MODE |
- DAC_REG5_POWER_DOWN);
-
- /*
- * Cause the DAC to:
- * Enable control port (I2C mode)
- * Going into power down
- * . MCLK divide by 1
- * . MCLK divide by 2
- */
- i2c_reg_write(I2C_DAC_ADDR, 0x05,
- DAC_REG5_I2C_MODE |
- DAC_REG5_POWER_DOWN |
- (mclk_divide ? DAC_REG5_MCLK_DIV : 0));
-
- /*
- * Cause the DAC to:
- * Auto-mute disabled
- * . Format 0, left justified 24 bits
- * . Format 3, right justified 24 bits
- * No de-emphasis
- * . Single speed mode
- * . Double speed mode
- */
- i2c_reg_write(I2C_DAC_ADDR, 0x01,
- (right_just ? DAC_REG1_RIGHT_JUST_24BIT :
- DAC_REG1_LEFT_JUST_24_BIT) |
- DAC_REG1_DEM_NO |
- (sample_rate >= 50000 ? DAC_REG1_DOUBLE : DAC_REG1_SINGLE));
-
- sprintf(str_buf, "%d",
- sample_rate >= 50000 ? DAC_REG1_DOUBLE : DAC_REG1_SINGLE);
- setenv("DaqDACFunctionalMode", str_buf);
-
- /*
- * Cause the DAC to:
- * Enable control port (I2C mode)
- * Remove power down
- * . MCLK divide by 1
- * . MCLK divide by 2
- */
- i2c_reg_write(I2C_DAC_ADDR, 0x05,
- DAC_REG5_I2C_MODE |
- (mclk_divide ? DAC_REG5_MCLK_DIV : 0));
-
- /*
- * Create a I2C stop condition:
- * low->high on data while clock is high.
- */
- I2C_SCL(1);
- I2C_DELAY;
- I2C_SDA(1);
- I2C_DELAY;
- I2C_TRISTATE;
-
- if (!quiet) {
- printf("\n");
- }
+ i2c_reg_write(I2C_ADC_1_ADDR, 0x01, /* set FSTART and GNDCAL */
+ ADC_REG1_FRAME_START | ADC_REG1_GROUND_CAL);
+
+ i2c_reg_write(I2C_ADC_1_ADDR, 0x02, /* Start calibration */
+ (sample_64x ? 0 : ADC_REG2_128x) |
+ ADC_REG2_CAL |
+ ADC_REG2_HIGH_PASS_DIS | ADC_REG2_SLAVE_MODE);
+
+ udelay(ADC_CAL_DELAY); /* a minimum of 4100 LRCLKs */
+ i2c_reg_write(I2C_ADC_1_ADDR, 0x01, 0x00); /* remove GNDCAL */
+
+ /*
+ * Now that we have synchronized the ADC's, enable address
+ * selection on the second ADC as well as the first.
+ */
+ i2c_reg_write(I2C_ADC_2_ADDR, 0x07, ADC_REG7_ADDR_ENABLE);
+
+ /*
+ * Initialize the Crystal DAC
+ *
+ * Two of the config lines are used for I2C so we have to set them
+ * to the proper initialization state without inadvertantly
+ * sending an I2C "start" sequence. When we bring the I2C back to
+ * the normal state, we send an I2C "stop" sequence.
+ */
+ if (!quiet)
+ printf("Initializing the DAC...\n");
+
+ /*
+ * Bring the I2C clock and data lines low for initialization
+ */
+ I2C_SCL(0);
+ I2C_DELAY;
+ I2C_SDA(0);
+ I2C_ACTIVE;
+ I2C_DELAY;
+
+ /* Reset the DAC */
+ iopa->pdat &= ~DAC_RST_MASK;
+ udelay(DAC_RESET_DELAY);
+
+ /* Release the DAC reset */
+ iopa->pdat |= DAC_RST_MASK;
+ udelay(DAC_INITIAL_DELAY);
+
+ /*
+ * Cause the DAC to:
+ * Enable control port (I2C mode)
+ * Going into power down
+ */
+ i2c_reg_write(I2C_DAC_ADDR, 0x05,
+ DAC_REG5_I2C_MODE | DAC_REG5_POWER_DOWN);
+
+ /*
+ * Cause the DAC to:
+ * Enable control port (I2C mode)
+ * Going into power down
+ * . MCLK divide by 1
+ * . MCLK divide by 2
+ */
+ i2c_reg_write(I2C_DAC_ADDR, 0x05,
+ DAC_REG5_I2C_MODE |
+ DAC_REG5_POWER_DOWN |
+ (mclk_divide ? DAC_REG5_MCLK_DIV : 0));
+
+ /*
+ * Cause the DAC to:
+ * Auto-mute disabled
+ * . Format 0, left justified 24 bits
+ * . Format 3, right justified 24 bits
+ * No de-emphasis
+ * . Single speed mode
+ * . Double speed mode
+ */
+ i2c_reg_write(I2C_DAC_ADDR, 0x01,
+ (right_just ? DAC_REG1_RIGHT_JUST_24BIT :
+ DAC_REG1_LEFT_JUST_24_BIT) |
+ DAC_REG1_DEM_NO |
+ (sample_rate >=
+ 50000 ? DAC_REG1_DOUBLE : DAC_REG1_SINGLE));
+
+ sprintf(str_buf, "%d",
+ sample_rate >= 50000 ? DAC_REG1_DOUBLE : DAC_REG1_SINGLE);
+ setenv("DaqDACFunctionalMode", str_buf);
+
+ /*
+ * Cause the DAC to:
+ * Enable control port (I2C mode)
+ * Remove power down
+ * . MCLK divide by 1
+ * . MCLK divide by 2
+ */
+ i2c_reg_write(I2C_DAC_ADDR, 0x05,
+ DAC_REG5_I2C_MODE |
+ (mclk_divide ? DAC_REG5_MCLK_DIV : 0));
+
+ /*
+ * Create a I2C stop condition:
+ * low->high on data while clock is high.
+ */
+ I2C_SCL(1);
+ I2C_DELAY;
+ I2C_SDA(1);
+ I2C_DELAY;
+ I2C_TRISTATE;
+
+ if (!quiet)
+ printf("\n");
#ifdef CONFIG_ETHER_LOOPBACK_TEST
- /*
- * Run the Ethernet loopback test
- */
- eth_loopback_test ();
+ /*
+ * Run the Ethernet loopback test
+ */
+ eth_loopback_test();
#endif /* CONFIG_ETHER_LOOPBACK_TEST */
#ifdef CONFIG_SHOW_BOOT_PROGRESS
- /*
- * Turn off the RED fail LED now that we are up and running.
- */
- status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
+ /*
+ * Turn off the RED fail LED now that we are up and running.
+ */
+ status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
#endif
- return 0;
+ return 0;
}
#ifdef CONFIG_SHOW_BOOT_PROGRESS
@@ -749,85 +741,86 @@ int misc_init_r(void)
*/
static void flash_code(uchar number, uchar modulo, uchar digits)
{
- int j;
-
- /*
- * Recursively do upper digits.
- */
- if(digits > 1) {
- flash_code(number / modulo, modulo, digits - 1);
- }
-
- number = number % modulo;
-
- /*
- * Zero is indicated by one long flash (dash).
- */
- if(number == 0) {
- status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
- udelay(1000000);
- status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
- udelay(200000);
- } else {
- /*
- * Non-zero is indicated by short flashes, one per count.
- */
- for(j = 0; j < number; j++) {
- status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
- udelay(100000);
- status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
- udelay(200000);
- }
- }
- /*
- * Inter-digit pause: we've already waited 200 mSec, wait 1 sec total
- */
- udelay(700000);
-}
-
-static int last_boot_progress;
+ int j;
-void show_boot_progress (int status)
-{
- int i,j;
- if(status > 0) {
- last_boot_progress = status;
- } else {
/*
- * If a specific failure code is given, flash this code
- * else just use the last success code we've seen
+ * Recursively do upper digits.
*/
- if(status < -1)
- last_boot_progress = -status;
+ if (digits > 1)
+ flash_code(number / modulo, modulo, digits - 1);
+
+ number = number % modulo;
/*
- * Flash this code 5 times
+ * Zero is indicated by one long flash (dash).
*/
- for(j=0; j<5; j++) {
- /*
- * Houston, we have a problem.
- * Blink the last OK status which indicates where things failed.
- */
- status_led_set(STATUS_LED_RED, STATUS_LED_ON);
- flash_code(last_boot_progress, 5, 3);
-
- /*
- * Delay 5 seconds between repetitions,
- * with the fault LED blinking
- */
- for(i=0; i<5; i++) {
- status_led_set(STATUS_LED_RED, STATUS_LED_OFF);
- udelay(500000);
- status_led_set(STATUS_LED_RED, STATUS_LED_ON);
- udelay(500000);
- }
+ if (number == 0) {
+ status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
+ udelay(1000000);
+ status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
+ udelay(200000);
+ } else {
+ /*
+ * Non-zero is indicated by short flashes, one per count.
+ */
+ for (j = 0; j < number; j++) {
+ status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
+ udelay(100000);
+ status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
+ udelay(200000);
+ }
}
-
/*
- * Reset the board to retry initialization.
+ * Inter-digit pause: we've already waited 200 mSec, wait 1 sec total
*/
- do_reset (NULL, 0, 0, NULL);
- }
+ udelay(700000);
+}
+
+static int last_boot_progress;
+
+void show_boot_progress(int status)
+{
+ int i, j;
+
+ if (status > 0) {
+ last_boot_progress = status;
+ } else {
+ /*
+ * If a specific failure code is given, flash this code
+ * else just use the last success code we've seen
+ */
+ if (status < -1)
+ last_boot_progress = -status;
+
+ /*
+ * Flash this code 5 times
+ */
+ for (j = 0; j < 5; j++) {
+ /*
+ * Houston, we have a problem.
+ * Blink the last OK status which indicates where things failed.
+ */
+ status_led_set(STATUS_LED_RED, STATUS_LED_ON);
+ flash_code(last_boot_progress, 5, 3);
+
+ /*
+ * Delay 5 seconds between repetitions,
+ * with the fault LED blinking
+ */
+ for (i = 0; i < 5; i++) {
+ status_led_set(STATUS_LED_RED,
+ STATUS_LED_OFF);
+ udelay(500000);
+ status_led_set(STATUS_LED_RED, STATUS_LED_ON);
+ udelay(500000);
+ }
+ }
+
+ /*
+ * Reset the board to retry initialization.
+ */
+ do_reset(NULL, 0, 0, NULL);
+ }
}
#endif /* CONFIG_SHOW_BOOT_PROGRESS */
@@ -841,27 +834,29 @@ void show_boot_progress (int status)
#define SPI_DAC_CS_MASK 0x00001000
static const u32 cs_mask[] = {
- SPI_ADC_CS_MASK,
- SPI_DAC_CS_MASK,
+ SPI_ADC_CS_MASK,
+ SPI_DAC_CS_MASK,
};
int spi_cs_is_valid(unsigned int bus, unsigned int cs)
{
- return bus == 0 && cs < sizeof(cs_mask) / sizeof(cs_mask[0]);
+ return bus == 0 && cs < sizeof(cs_mask) / sizeof(cs_mask[0]);
}
void spi_cs_activate(struct spi_slave *slave)
{
- volatile ioport_t *iopd = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3 /* port D */);
+ volatile ioport_t *iopd =
+ ioport_addr((immap_t *) CONFIG_SYS_IMMR, 3 /* port D */ );
- iopd->pdat &= ~cs_mask[slave->cs];
+ iopd->pdat &= ~cs_mask[slave->cs];
}
void spi_cs_deactivate(struct spi_slave *slave)
{
- volatile ioport_t *iopd = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3 /* port D */);
+ volatile ioport_t *iopd =
+ ioport_addr((immap_t *) CONFIG_SYS_IMMR, 3 /* port D */ );
- iopd->pdat |= cs_mask[slave->cs];
+ iopd->pdat |= cs_mask[slave->cs];
}
#endif
diff --git a/board/siemens/SCM/scm.c b/board/siemens/SCM/scm.c
index 926e491271b..461b56e3ff8 100644
--- a/board/siemens/SCM/scm.c
+++ b/board/siemens/SCM/scm.c
@@ -24,6 +24,7 @@
#include <common.h>
#include <ioports.h>
#include <mpc8260.h>
+#include <linux/compiler.h>
#include "scm.h"
@@ -397,7 +398,7 @@ static void config_scoh_cs (void)
volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
volatile memctl8260_t *memctl = &immr->im_memctl;
volatile can_reg_t *can = (volatile can_reg_t *) CONFIG_SYS_CAN0_BASE;
- volatile uint tmp, i;
+ __maybe_unused volatile uint tmp, i;
/* Initialize OR3 / BR3 for CAN Bus Controller 0 */
memctl->memc_or3 = CONFIG_SYS_CAN0_OR3;
diff --git a/board/svm_sc8xx/flash.c b/board/svm_sc8xx/flash.c
index db1f21a581d..af329b9f55d 100644
--- a/board/svm_sc8xx/flash.c
+++ b/board/svm_sc8xx/flash.c
@@ -27,155 +27,163 @@
#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET)
#endif
-flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
+flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
/*-----------------------------------------------------------------------
* Functions
*/
-static int write_word (flash_info_t *info, ulong dest, ulong data);
-#if 0
-static ulong flash_get_size (vu_long *addr, flash_info_t *info);
-static void flash_get_offsets (ulong base, flash_info_t *info);
-#endif
-#ifdef CONFIG_BOOT_8B
-static int my_in_8( unsigned char *addr);
-static void my_out_8( unsigned char *addr, int val);
+static int write_word(flash_info_t *info, ulong dest, ulong data);
+
+#ifdef CONFIG_BOOT_8B
+static int my_in_8(unsigned char *addr);
+static void my_out_8(unsigned char *addr, int val);
#endif
-#ifdef CONFIG_BOOT_16B
-static int my_in_be16( unsigned short *addr);
-static void my_out_be16( unsigned short *addr, int val);
+#ifdef CONFIG_BOOT_16B
+static int my_in_be16(unsigned short *addr);
+static void my_out_be16(unsigned short *addr, int val);
#endif
-#ifdef CONFIG_BOOT_32B
-static unsigned my_in_be32( unsigned *addr);
-static void my_out_be32( unsigned *addr, int val);
+#ifdef CONFIG_BOOT_32B
+static unsigned my_in_be32(unsigned *addr);
+static void my_out_be32(unsigned *addr, int val);
#endif
/*-----------------------------------------------------------------------
*/
-unsigned long flash_init (void)
+unsigned long flash_init(void)
{
- volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
+ volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
volatile memctl8xx_t *memctl = &immap->im_memctl;
unsigned long size_b0, size_b1;
int i;
- size_b0=0;
- size_b1=0;
+ size_b0 = 0;
+ size_b1 = 0;
/* Init: no FLASHes known */
- for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
+ for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i)
flash_info[i].flash_id = FLASH_UNKNOWN;
- }
+
#ifdef CONFIG_SYS_DOC_BASE
#ifndef CONFIG_FEL8xx_AT
- memctl->memc_or5 = (0xffff8000 | CONFIG_SYS_OR_TIMING_DOC ); /* 32k bytes */
+ /* 32k bytes */
+ memctl->memc_or5 = (0xffff8000 | CONFIG_SYS_OR_TIMING_DOC);
memctl->memc_br5 = CONFIG_SYS_DOC_BASE | 0x401;
#else
- memctl->memc_or3 = (0xffff8000 | CONFIG_SYS_OR_TIMING_DOC ); /* 32k bytes */
+ /* 32k bytes */
+ memctl->memc_or3 = (0xffff8000 | CONFIG_SYS_OR_TIMING_DOC);
memctl->memc_br3 = CONFIG_SYS_DOC_BASE | 0x401;
#endif
#endif
-#if defined( CONFIG_BOOT_8B)
-/* memctl->memc_or0 = 0xfff80ff4; /###* 4MB bytes */
-/* memctl->memc_br0 = 0x40000401; */
- size_b0 = 0x80000; /* 512 K */
+#if defined(CONFIG_BOOT_8B)
+ size_b0 = 0x80000; /* 512 K */
+
flash_info[0].flash_id = FLASH_MAN_AMD | FLASH_AM040;
flash_info[0].sector_count = 8;
flash_info[0].size = 0x00080000;
+
/* set up sector start address table */
for (i = 0; i < flash_info[0].sector_count; i++)
- flash_info[0].start[i] = 0x40000000 + (i * 0x10000);
+ flash_info[0].start[i] = 0x40000000 + (i * 0x10000);
+
/* protect all sectors */
for (i = 0; i < flash_info[0].sector_count; i++)
- flash_info[0].protect[i] = 0x1;
-#elif defined (CONFIG_BOOT_16B)
-/* memctl->memc_or0 = 0xfff80ff4; /###* 4MB bytes */
-/* memctl->memc_br0 = 0x40000401; */
- size_b0 = 0x400000; /* 4MB , assume AMD29LV320B */
+ flash_info[0].protect[i] = 0x1;
+
+#elif defined(CONFIG_BOOT_16B)
+ size_b0 = 0x400000; /* 4MB , assume AMD29LV320B */
+
flash_info[0].flash_id = FLASH_MAN_AMD | FLASH_AM320B;
flash_info[0].sector_count = 67;
flash_info[0].size = 0x00400000;
+
/* set up sector start address table */
- flash_info[0].start[0] = 0x40000000 ;
+ flash_info[0].start[0] = 0x40000000;
flash_info[0].start[1] = 0x40000000 + 0x4000;
flash_info[0].start[2] = 0x40000000 + 0x6000;
flash_info[0].start[3] = 0x40000000 + 0x8000;
- for (i = 4; i < flash_info[0].sector_count; i++)
- flash_info[0].start[i] = 0x40000000 + 0x10000 + ((i-4) * 0x10000);
+
+ for (i = 4; i < flash_info[0].sector_count; i++) {
+ flash_info[0].start[i] =
+ 0x40000000 + 0x10000 + ((i - 4) * 0x10000);
+ }
+
/* protect all sectors */
for (i = 0; i < flash_info[0].sector_count; i++)
- flash_info[0].protect[i] = 0x1;
+ flash_info[0].protect[i] = 0x1;
#endif
-
#ifdef CONFIG_BOOT_32B
/* Static FLASH Bank configuration here - FIXME XXX */
-
- size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
+ size_b0 = flash_get_size((vu_long *) FLASH_BASE0_PRELIM,
+ &flash_info[0]);
if (flash_info[0].flash_id == FLASH_UNKNOWN) {
- printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
- size_b0, size_b0<<20);
+ printf("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
+ size_b0, size_b0 << 20);
}
- size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
+ size_b1 = flash_get_size((vu_long *) FLASH_BASE1_PRELIM,
+ &flash_info[1]);
if (size_b1 > size_b0) {
- printf ("## ERROR: "
+ printf("## ERROR: "
"Bank 1 (0x%08lx = %ld MB) > Bank 0 (0x%08lx = %ld MB)\n",
- size_b1, size_b1<<20,
- size_b0, size_b0<<20
- );
- flash_info[0].flash_id = FLASH_UNKNOWN;
- flash_info[1].flash_id = FLASH_UNKNOWN;
- flash_info[0].sector_count = -1;
- flash_info[1].sector_count = -1;
- flash_info[0].size = 0;
- flash_info[1].size = 0;
- return (0);
+ size_b1, size_b1 << 20, size_b0, size_b0 << 20);
+ flash_info[0].flash_id = FLASH_UNKNOWN;
+ flash_info[1].flash_id = FLASH_UNKNOWN;
+ flash_info[0].sector_count = -1;
+ flash_info[1].sector_count = -1;
+ flash_info[0].size = 0;
+ flash_info[1].size = 0;
+
+ return 0;
}
/* Remap FLASH according to real size */
- memctl->memc_or0 = CONFIG_SYS_OR_TIMING_FLASH | (-size_b0 & OR_AM_MSK);
- memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V;
+ memctl->memc_or0 = CONFIG_SYS_OR_TIMING_FLASH |
+ (-size_b0 & OR_AM_MSK);
+ memctl->memc_br0 = (CONFIG_SYS_FLASH_BASE & BR_BA_MSK) |
+ BR_MS_GPCM | BR_V;
/* Re-do sizing to get full correct info */
- size_b0 = flash_get_size((vu_long *)CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+ size_b0 = flash_get_size((vu_long *) CONFIG_SYS_FLASH_BASE,
+ &flash_info[0]);
- flash_get_offsets (CONFIG_SYS_FLASH_BASE, &flash_info[0]);
+ flash_get_offsets(CONFIG_SYS_FLASH_BASE, &flash_info[0]);
#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
/* monitor protection ON by default */
flash_protect(FLAG_PROTECT_SET,
- CONFIG_SYS_MONITOR_BASE,
- CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
- &flash_info[0]);
+ CONFIG_SYS_MONITOR_BASE,
+ CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
+ &flash_info[0]);
#endif
#ifdef CONFIG_ENV_IS_IN_FLASH
/* ENV protection ON by default */
flash_protect(FLAG_PROTECT_SET,
- CONFIG_ENV_ADDR,
- CONFIG_ENV_ADDR+CONFIG_ENV_SIZE-1,
- &flash_info[0]);
+ CONFIG_ENV_ADDR,
+ CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
#endif
if (size_b1) {
- memctl->memc_or1 = CONFIG_SYS_OR_TIMING_FLASH | (-size_b1 & 0xFFFF8000);
- memctl->memc_br1 = ((CONFIG_SYS_FLASH_BASE + size_b0) & BR_BA_MSK) |
- BR_MS_GPCM | BR_V;
+ memctl->memc_or1 = CONFIG_SYS_OR_TIMING_FLASH |
+ (-size_b1 & 0xFFFF8000);
+ memctl->memc_br1 = ((CONFIG_SYS_FLASH_BASE +
+ size_b0) & BR_BA_MSK) | BR_MS_GPCM | BR_V;
/* Re-do sizing to get full correct info */
- size_b1 = flash_get_size((vu_long *)(CONFIG_SYS_FLASH_BASE + size_b0),
- &flash_info[1]);
+ size_b1 = flash_get_size((vu_long *)(CONFIG_SYS_FLASH_BASE +
+ size_b0), &flash_info[1]);
- flash_get_offsets (CONFIG_SYS_FLASH_BASE + size_b0, &flash_info[1]);
+ flash_get_offsets(CONFIG_SYS_FLASH_BASE + size_b0,
+ &flash_info[1]);
#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
/* monitor protection ON by default */
flash_protect(FLAG_PROTECT_SET,
CONFIG_SYS_MONITOR_BASE,
- CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
+ CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
&flash_info[1]);
#endif
@@ -183,11 +191,11 @@ unsigned long flash_init (void)
/* ENV protection ON by default */
flash_protect(FLAG_PROTECT_SET,
CONFIG_ENV_ADDR,
- CONFIG_ENV_ADDR+CONFIG_ENV_SIZE-1,
+ CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1,
&flash_info[1]);
#endif
} else {
- memctl->memc_br1 = 0; /* invalidate bank */
+ memctl->memc_br1 = 0; /* invalidate bank */
flash_info[1].flash_id = FLASH_UNKNOWN;
flash_info[1].sector_count = -1;
@@ -197,350 +205,209 @@ unsigned long flash_init (void)
flash_info[1].size = size_b1;
-#endif /* CONFIG_BOOT_32B */
+#endif /* CONFIG_BOOT_32B */
- return (size_b0 + size_b1);
+ return size_b0 + size_b1;
}
-#if 0
-/*-----------------------------------------------------------------------
- */
-static void flash_get_offsets (ulong base, flash_info_t *info)
-{
- int i;
- /* set up sector start address table */
- if (info->flash_id & FLASH_BTYPE) {
- /* set sector offsets for bottom boot block type */
- info->start[0] = base + 0x00000000;
- info->start[1] = base + 0x00008000;
- info->start[2] = base + 0x0000C000;
- info->start[3] = base + 0x00010000;
- for (i = 4; i < info->sector_count; i++) {
- info->start[i] = base + (i * 0x00020000) - 0x00060000;
- }
- } else {
- /* set sector offsets for top boot block type */
- i = info->sector_count - 1;
- info->start[i--] = base + info->size - 0x00008000;
- info->start[i--] = base + info->size - 0x0000C000;
- info->start[i--] = base + info->size - 0x00010000;
- for (; i >= 0; i--) {
- info->start[i] = base + i * 0x00020000;
- }
- }
-}
-#endif
-/*-----------------------------------------------------------------------
- */
-void flash_print_info (flash_info_t *info)
+
+void flash_print_info(flash_info_t *info)
{
int i;
if (info->flash_id == FLASH_UNKNOWN) {
- printf ("missing or unknown FLASH type\n");
+ printf("missing or unknown FLASH type\n");
return;
}
switch (info->flash_id & FLASH_VENDMASK) {
- case FLASH_MAN_AMD: printf ("AMD "); break;
- case FLASH_MAN_FUJ: printf ("FUJITSU "); break;
- default: printf ("Unknown Vendor "); break;
+ case FLASH_MAN_AMD:
+ printf("AMD ");
+ break;
+ case FLASH_MAN_FUJ:
+ printf("FUJITSU ");
+ break;
+ default:
+ printf("Unknown Vendor ");
+ break;
}
switch (info->flash_id & FLASH_TYPEMASK) {
- case FLASH_AM400B: printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM400T: printf ("AM29LV400T (4 Mbit, top boot sector)\n");
- break;
- case FLASH_AM800B: printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM800T: printf ("AM29LV800T (8 Mbit, top boot sector)\n");
- break;
- case FLASH_AM160B: printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM160T: printf ("AM29LV160T (16 Mbit, top boot sector)\n");
- break;
- case FLASH_AM320B: printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
- break;
- case FLASH_AM320T: printf ("AM29LV320T (32 Mbit, top boot sector)\n");
- break;
- default: printf ("Unknown Chip Type\n");
- break;
+ case FLASH_AM400B:
+ printf("AM29LV400B (4 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM400T:
+ printf("AM29LV400T (4 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM800B:
+ printf("AM29LV800B (8 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM800T:
+ printf("AM29LV800T (8 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM160B:
+ printf("AM29LV160B (16 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM160T:
+ printf("AM29LV160T (16 Mbit, top boot sector)\n");
+ break;
+ case FLASH_AM320B:
+ printf("AM29LV320B (32 Mbit, bottom boot sect)\n");
+ break;
+ case FLASH_AM320T:
+ printf("AM29LV320T (32 Mbit, top boot sector)\n");
+ break;
+ default:
+ printf("Unknown Chip Type\n");
+ break;
}
- printf (" Size: %ld MB in %d Sectors\n",
+ 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) {
+ printf(" Sector Start Addresses:");
+ 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 ");
+ printf(" %08lX%s",
+ info->start[i], info->protect[i] ? " (RO)" : " ");
}
- printf ("\n");
+ printf("\n");
return;
}
-/*-----------------------------------------------------------------------
- */
-
-
-/*-----------------------------------------------------------------------
- */
-
/*
* The following code cannot be run from FLASH!
*/
-#if 0
-static ulong flash_get_size (vu_long *addr, flash_info_t *info)
-{
- short i;
- ulong value;
- ulong base = (ulong)addr;
-
- /* Write auto select command: read Manufacturer ID */
- addr[0x0555] = 0x00AA00AA;
- addr[0x02AA] = 0x00550055;
- addr[0x0555] = 0x00900090;
- value = addr[0];
-
- switch (value) {
- case AMD_MANUFACT:
- info->flash_id = FLASH_MAN_AMD;
- break;
- case FUJ_MANUFACT:
- info->flash_id = FLASH_MAN_FUJ;
- break;
- default:
- info->flash_id = FLASH_UNKNOWN;
- info->sector_count = 0;
- info->size = 0;
- return (0); /* no or unknown flash */
- }
-
- value = addr[1]; /* device ID */
-
- switch (value) {
- case AMD_ID_LV400T:
- info->flash_id += FLASH_AM400T;
- info->sector_count = 11;
- info->size = 0x00100000;
- break; /* => 1 MB */
-
- case AMD_ID_LV400B:
- info->flash_id += FLASH_AM400B;
- info->sector_count = 11;
- info->size = 0x00100000;
- break; /* => 1 MB */
-
- case AMD_ID_LV800T:
- info->flash_id += FLASH_AM800T;
- info->sector_count = 19;
- info->size = 0x00200000;
- break; /* => 2 MB */
-
- case AMD_ID_LV800B:
- info->flash_id += FLASH_AM800B;
- info->sector_count = 19;
- info->size = 0x00200000;
- break; /* => 2 MB */
-
- case AMD_ID_LV160T:
- info->flash_id += FLASH_AM160T;
- info->sector_count = 35;
- info->size = 0x00400000;
- break; /* => 4 MB */
-
- case AMD_ID_LV160B:
- info->flash_id += FLASH_AM160B;
- info->sector_count = 35;
- info->size = 0x00400000;
- break; /* => 4 MB */
-#if 0 /* enable when device IDs are available */
- case AMD_ID_LV320T:
- info->flash_id += FLASH_AM320T;
- info->sector_count = 67;
- info->size = 0x00800000;
- break; /* => 8 MB */
-
- case AMD_ID_LV320B:
- info->flash_id += FLASH_AM320B;
- info->sector_count = 67;
- info->size = 0x00800000;
- break; /* => 8 MB */
-#endif
- default:
- info->flash_id = FLASH_UNKNOWN;
- return (0); /* => no or unknown flash */
- }
-
- /* set up sector start address table */
- if (info->flash_id & FLASH_BTYPE) {
- /* set sector offsets for bottom boot block type */
- info->start[0] = base + 0x00000000;
- info->start[1] = base + 0x00008000;
- info->start[2] = base + 0x0000C000;
- info->start[3] = base + 0x00010000;
- for (i = 4; i < info->sector_count; i++) {
- info->start[i] = base + (i * 0x00020000) - 0x00060000;
- }
- } else {
- /* set sector offsets for top boot block type */
- i = info->sector_count - 1;
- info->start[i--] = base + info->size - 0x00008000;
- info->start[i--] = base + info->size - 0x0000C000;
- info->start[i--] = base + info->size - 0x00010000;
- for (; i >= 0; i--) {
- info->start[i] = base + i * 0x00020000;
- }
- }
-
- /* check for protected sectors */
- for (i = 0; i < info->sector_count; i++) {
- /* read sector protection at sector address, (A7 .. A0) = 0x02 */
- /* D0 = 1 if protected */
- addr = (volatile unsigned long *)(info->start[i]);
- info->protect[i] = addr[2] & 1;
- }
-
- /*
- * Prevent writes to uninitialized FLASH.
- */
- if (info->flash_id != FLASH_UNKNOWN) {
- addr = (volatile unsigned long *)info->start[0];
-
- *addr = 0x00F000F0; /* reset bank */
- }
-
- return (info->size);
-}
-#endif
-
-/*-----------------------------------------------------------------------
- */
-
-int flash_erase (flash_info_t *info, int s_first, int s_last)
+int flash_erase(flash_info_t *info, int s_first, int s_last)
{
- vu_long *addr = (vu_long*)(info->start[0]);
- int flag, prot, sect, l_sect,in_mid,in_did;
+ vu_long *addr = (vu_long *) (info->start[0]);
+ int flag, prot, sect, l_sect, in_mid, in_did;
ulong start, now, last;
if ((s_first < 0) || (s_first > s_last)) {
- if (info->flash_id == FLASH_UNKNOWN) {
- printf ("- missing\n");
- } else {
- printf ("- no sectors to erase\n");
- }
+ if (info->flash_id == FLASH_UNKNOWN)
+ printf("- missing\n");
+ else
+ printf("- no sectors to erase\n");
+
return 1;
}
if ((info->flash_id == FLASH_UNKNOWN) ||
(info->flash_id > FLASH_AMD_COMP)) {
- printf ("Can't erase unknown flash type %08lx - aborted\n",
- info->flash_id);
+ printf("Can't erase unknown flash type %08lx - aborted\n",
+ info->flash_id);
return 1;
}
prot = 0;
- for (sect=s_first; sect<=s_last; ++sect) {
- if (info->protect[sect]) {
+ for (sect = s_first; sect <= s_last; ++sect) {
+ if (info->protect[sect])
prot++;
- }
}
if (prot) {
- printf ("- Warning: %d protected sectors will not be erased!\n",
+ printf("- Warning: %d protected sectors will not be erased!\n",
prot);
} else {
- printf ("\n");
+ printf("\n");
}
l_sect = -1;
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();
-#if defined (CONFIG_BOOT_8B )
- my_out_8( (unsigned char * ) ((ulong)addr+0x555) , 0xaa );
- my_out_8( (unsigned char * ) ((ulong)addr+0x2aa) , 0x55 );
- my_out_8( (unsigned char * ) ((ulong)addr+0x555) , 0x90 );
- in_mid=my_in_8( (unsigned char * ) addr );
- in_did=my_in_8( (unsigned char * ) ((ulong)addr+1) );
- printf(" man ID=0x%x, dev ID=0x%x.\n",in_mid,in_did );
- my_out_8( (unsigned char *)addr, 0xf0);
+
+#if defined(CONFIG_BOOT_8B)
+ my_out_8((unsigned char *)((ulong)addr + 0x555), 0xaa);
+ my_out_8((unsigned char *)((ulong)addr + 0x2aa), 0x55);
+ my_out_8((unsigned char *)((ulong)addr + 0x555), 0x90);
+
+ in_mid = my_in_8((unsigned char *)addr);
+ in_did = my_in_8((unsigned char *)((ulong)addr + 1));
+
+ printf(" man ID=0x%x, dev ID=0x%x.\n", in_mid, in_did);
+
+ my_out_8((unsigned char *)addr, 0xf0);
udelay(1);
- my_out_8( (unsigned char *) ((ulong)addr+0x555),0xaa );
- my_out_8( (unsigned char *) ((ulong)addr+0x2aa),0x55 );
- my_out_8( (unsigned char *) ((ulong)addr+0x555),0x80 );
- my_out_8( (unsigned char *) ((ulong)addr+0x555),0xaa );
- my_out_8( (unsigned char *) ((ulong)addr+0x2aa),0x55 );
+
+ my_out_8((unsigned char *)((ulong)addr + 0x555), 0xaa);
+ my_out_8((unsigned char *)((ulong)addr + 0x2aa), 0x55);
+ my_out_8((unsigned char *)((ulong)addr + 0x555), 0x80);
+ my_out_8((unsigned char *)((ulong)addr + 0x555), 0xaa);
+ my_out_8((unsigned char *)((ulong)addr + 0x2aa), 0x55);
+
/* Start erase on unprotected sectors */
- for (sect = s_first; sect<=s_last; sect++) {
+ for (sect = s_first; sect <= s_last; sect++) {
if (info->protect[sect] == 0) { /* not protected */
- addr = (vu_long*)(info->start[sect]);
+ addr = (vu_long *) (info->start[sect]);
/*addr[0] = 0x00300030; */
- my_out_8( (unsigned char *) ((ulong)addr),0x30 );
+ my_out_8((unsigned char *)((ulong)addr), 0x30);
l_sect = sect;
}
}
-#elif defined(CONFIG_BOOT_16B )
- my_out_be16( (unsigned short * ) ((ulong)addr+ (0xaaa)) , 0xaa );
- my_out_be16( (unsigned short * ) ((ulong)addr+ (0x554)) , 0x55 );
- my_out_be16( (unsigned short * ) ((ulong)addr+ (0xaaa)) , 0x90 );
- in_mid=my_in_be16( (unsigned short * ) addr );
- in_did=my_in_be16 ( (unsigned short * ) ((ulong)addr+2) );
- printf(" man ID=0x%x, dev ID=0x%x.\n",in_mid,in_did );
- my_out_be16( (unsigned short *)addr, 0xf0);
+#elif defined(CONFIG_BOOT_16B)
+ my_out_be16((unsigned short *)((ulong)addr + (0xaaa)), 0xaa);
+ my_out_be16((unsigned short *)((ulong)addr + (0x554)), 0x55);
+ my_out_be16((unsigned short *)((ulong)addr + (0xaaa)), 0x90);
+ in_mid = my_in_be16((unsigned short *)addr);
+ in_did = my_in_be16((unsigned short *)((ulong)addr + 2));
+ printf(" man ID=0x%x, dev ID=0x%x.\n", in_mid, in_did);
+ my_out_be16((unsigned short *)addr, 0xf0);
udelay(1);
- my_out_be16( (unsigned short *) ((ulong)addr+ 0xaaa),0xaa );
- my_out_be16( (unsigned short *) ((ulong)addr+0x554),0x55 );
- my_out_be16( (unsigned short *) ((ulong)addr+0xaaa),0x80 );
- my_out_be16( (unsigned short *) ((ulong)addr+0xaaa),0xaa );
- my_out_be16( (unsigned short *) ((ulong)addr+0x554),0x55 );
+ my_out_be16((unsigned short *)((ulong)addr + 0xaaa), 0xaa);
+ my_out_be16((unsigned short *)((ulong)addr + 0x554), 0x55);
+ my_out_be16((unsigned short *)((ulong)addr + 0xaaa), 0x80);
+ my_out_be16((unsigned short *)((ulong)addr + 0xaaa), 0xaa);
+ my_out_be16((unsigned short *)((ulong)addr + 0x554), 0x55);
/* Start erase on unprotected sectors */
- for (sect = s_first; sect<=s_last; sect++) {
+ for (sect = s_first; sect <= s_last; sect++) {
if (info->protect[sect] == 0) { /* not protected */
- addr = (vu_long*)(info->start[sect]);
- my_out_be16( (unsigned short *) ((ulong)addr),0x30 );
+ addr = (vu_long *) (info->start[sect]);
+ my_out_be16((unsigned short *)((ulong)addr), 0x30);
l_sect = sect;
}
}
#elif defined(CONFIG_BOOT_32B)
- my_out_be32( (unsigned * ) ((ulong)addr+0x1554) , 0xaa );
- my_out_be32( (unsigned * ) ((ulong)addr+0xaa8) , 0x55 );
- my_out_be32( (unsigned *) ((ulong)addr+0x1554) , 0x90 );
- in_mid=my_in_be32( (unsigned * ) addr );
- in_did=my_in_be32( (unsigned * ) ((ulong)addr+4) );
- printf(" man ID=0x%x, dev ID=0x%x.\n",in_mid,in_did );
- my_out_be32( (unsigned *)addr, 0xf0);
+ my_out_be32((unsigned *)((ulong)addr + 0x1554), 0xaa);
+ my_out_be32((unsigned *)((ulong)addr + 0xaa8), 0x55);
+ my_out_be32((unsigned *)((ulong)addr + 0x1554), 0x90);
+
+ in_mid = my_in_be32((unsigned *)addr);
+ in_did = my_in_be32((unsigned *)((ulong)addr + 4));
+
+ printf(" man ID=0x%x, dev ID=0x%x.\n", in_mid, in_did);
+
+ my_out_be32((unsigned *) addr, 0xf0);
udelay(1);
- my_out_be32( (unsigned *) ((ulong)addr+0x1554),0xaa );
- my_out_be32( (unsigned *) ((ulong)addr+0xaa8),0x55 );
- my_out_be32( (unsigned *) ((ulong)addr+0x1554),0x80 );
- my_out_be32( (unsigned *) ((ulong)addr+0x1554),0xaa );
- my_out_be32( (unsigned *) ((ulong)addr+0xaa8),0x55 );
+
+ my_out_be32((unsigned *)((ulong)addr + 0x1554), 0xaa);
+ my_out_be32((unsigned *)((ulong)addr + 0xaa8), 0x55);
+ my_out_be32((unsigned *)((ulong)addr + 0x1554), 0x80);
+ my_out_be32((unsigned *)((ulong)addr + 0x1554), 0xaa);
+ my_out_be32((unsigned *)((ulong)addr + 0xaa8), 0x55);
+
/* Start erase on unprotected sectors */
- for (sect = s_first; sect<=s_last; sect++) {
+ for (sect = s_first; sect <= s_last; sect++) {
if (info->protect[sect] == 0) { /* not protected */
- addr = (vu_long*)(info->start[sect]);
- my_out_be32( (unsigned *) ((ulong)addr),0x00300030 );
+ addr = (vu_long *) (info->start[sect]);
+ my_out_be32((unsigned *)((ulong)addr), 0x00300030);
l_sect = sect;
}
}
#else
-# error CONFIG_BOOT_(size)B missing.
+#error CONFIG_BOOT_(size)B missing.
#endif
/* re-enable interrupts if necessary */
if (flag)
enable_interrupts();
/* wait at least 80us - let's wait 1 ms */
- udelay (1000);
+ udelay(1000);
/*
* We wait for the last triggered sector
@@ -548,53 +415,55 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
if (l_sect < 0)
goto DONE;
- start = get_timer (0);
- last = start;
- addr = (vu_long*)(info->start[l_sect]);
-#if defined (CONFIG_BOOT_8B)
- while ( (my_in_8((unsigned char *)addr) & 0x80) != 0x80 )
-#elif defined(CONFIG_BOOT_16B )
- while ( (my_in_be16((unsigned short *)addr) & 0x0080) != 0x0080 )
+ start = get_timer(0);
+ last = start;
+ addr = (vu_long *) (info->start[l_sect]);
+#if defined(CONFIG_BOOT_8B)
+ while ((my_in_8((unsigned char *) addr) & 0x80) != 0x80)
+#elif defined(CONFIG_BOOT_16B)
+ while ((my_in_be16((unsigned short *) addr) & 0x0080) != 0x0080)
#elif defined(CONFIG_BOOT_32B)
- while ( (my_in_be32((unsigned *)addr) & 0x00800080) != 0x00800080 )
+ while ((my_in_be32((unsigned *) addr) & 0x00800080) != 0x00800080)
#else
-# error CONFIG_BOOT_(size)B missing.
+#error CONFIG_BOOT_(size)B missing.
#endif
{
- if ((now = get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
- printf ("Timeout\n");
+ now = get_timer(start);
+ if (now > CONFIG_SYS_FLASH_ERASE_TOUT) {
+ printf("Timeout\n");
return 1;
}
/* show that we're waiting */
if ((now - last) > 1000) { /* every second */
- putc ('.');
+ putc('.');
last = now;
}
}
DONE:
/* reset to read mode */
- addr = (volatile unsigned long *)info->start[0];
-#if defined (CONFIG_BOOT_8B)
- my_out_8( (unsigned char *)addr, 0xf0);
-#elif defined(CONFIG_BOOT_16B )
- my_out_be16( (unsigned short * ) addr , 0x00f0 );
+ addr = (volatile unsigned long *) info->start[0];
+
+#if defined(CONFIG_BOOT_8B)
+ my_out_8((unsigned char *) addr, 0xf0);
+#elif defined(CONFIG_BOOT_16B)
+ my_out_be16((unsigned short *) addr, 0x00f0);
#elif defined(CONFIG_BOOT_32B)
- my_out_be32 ( (unsigned *)addr, 0x00F000F0 ); /* reset bank */
+ my_out_be32((unsigned *) addr, 0x00F000F0); /* reset bank */
#else
-# error CONFIG_BOOT_(size)B missing.
+#error CONFIG_BOOT_(size)B missing.
#endif
- printf (" done\n");
+ printf(" done\n");
return 0;
}
-/*-----------------------------------------------------------------------
+/*
* Copy memory to flash, returns:
* 0 - OK
* 1 - write timeout
* 2 - Flash not erased
*/
-int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
+int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
{
ulong cp, wp, data;
int i, l, rc;
@@ -604,23 +473,26 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
/*
* handle unaligned start bytes
*/
- if ((l = addr - wp) != 0) {
+ l = addr - wp;
+
+ if (l != 0) {
data = 0;
- for (i=0, cp=wp; i<l; ++i, ++cp) {
- data = (data << 8) | (*(uchar *)cp);
- }
- for (; i<4 && cnt>0; ++i) {
+ for (i = 0, cp = wp; i < l; ++i, ++cp)
+ data = (data << 8) | (*(uchar *) cp);
+
+ for (; i < 4 && cnt > 0; ++i) {
data = (data << 8) | *src++;
--cnt;
++cp;
}
- for (; cnt==0 && i<4; ++i, ++cp) {
- data = (data << 8) | (*(uchar *)cp);
- }
+ for (; cnt == 0 && i < 4; ++i, ++cp)
+ data = (data << 8) | (*(uchar *) cp);
+
+ rc = write_word(info, wp, data);
+
+ if (rc != 0)
+ return rc;
- if ((rc = write_word(info, wp, data)) != 0) {
- return (rc);
- }
wp += 4;
}
@@ -629,113 +501,123 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
*/
while (cnt >= 4) {
data = 0;
- for (i=0; i<4; ++i) {
+ for (i = 0; i < 4; ++i)
data = (data << 8) | *src++;
- }
- if ((rc = write_word(info, wp, data)) != 0) {
- return (rc);
- }
- wp += 4;
+
+ rc = write_word(info, wp, data);
+
+ if (rc != 0)
+ return rc;
+
+ wp += 4;
cnt -= 4;
}
- if (cnt == 0) {
- return (0);
- }
+ if (cnt == 0)
+ return 0;
/*
* handle unaligned tail bytes
*/
data = 0;
- for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
+ for (i = 0, cp = wp; i < 4 && cnt > 0; ++i, ++cp) {
data = (data << 8) | *src++;
--cnt;
}
- for (; i<4; ++i, ++cp) {
- data = (data << 8) | (*(uchar *)cp);
- }
+ for (; i < 4; ++i, ++cp)
+ data = (data << 8) | (*(uchar *) cp);
- return (write_word(info, wp, data));
+ return write_word(info, wp, data);
}
-/*-----------------------------------------------------------------------
+/*
* Write a word to Flash, returns:
* 0 - OK
* 1 - write timeout
* 2 - Flash not erased
*/
-static int write_word (flash_info_t *info, ulong dest, ulong data)
+static int write_word(flash_info_t *info, ulong dest, ulong data)
{
- ulong addr = (ulong)(info->start[0]);
- ulong start,last;
+ ulong addr = (ulong) (info->start[0]);
+ ulong start;
int flag;
ulong i;
- int data_short[2];
+ int data_short[2];
/* Check if Flash is (sufficiently) erased */
- if ( ((ulong) *(ulong *)dest & data) != data ) {
- return (2);
- }
+ if (((ulong)*(ulong *)dest & data) != data)
+ return 2;
+
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();
#if defined(CONFIG_BOOT_8B)
#ifdef DEBUG
{
- int in_mid,in_did;
- my_out_8( (unsigned char * ) (addr+0x555) , 0xaa );
- my_out_8( (unsigned char * ) (addr+0x2aa) , 0x55 );
- my_out_8( (unsigned char * ) (addr+0x555) , 0x90 );
- in_mid=my_in_8( (unsigned char * ) addr );
- in_did=my_in_8( (unsigned char * ) (addr+1) );
- printf(" man ID=0x%x, dev ID=0x%x.\n",in_mid,in_did );
- my_out_8( (unsigned char *)addr, 0xf0);
- udelay(1);
+ int in_mid, in_did;
+
+ my_out_8((unsigned char *) (addr + 0x555), 0xaa);
+ my_out_8((unsigned char *) (addr + 0x2aa), 0x55);
+ my_out_8((unsigned char *) (addr + 0x555), 0x90);
+
+ in_mid = my_in_8((unsigned char *) addr);
+ in_did = my_in_8((unsigned char *) (addr + 1));
+
+ printf(" man ID=0x%x, dev ID=0x%x.\n", in_mid, in_did);
+
+ my_out_8((unsigned char *) addr, 0xf0);
+ udelay(1);
}
#endif
- {
- int data_ch[4];
- data_ch[0]=(int ) ((data>>24) & 0xff);
- data_ch[1]=(int ) ((data>>16) &0xff );
- data_ch[2]=(int ) ((data >>8) & 0xff);
- data_ch[3]=(int ) (data & 0xff);
- for (i=0;i<4;i++ ){
- my_out_8( (unsigned char *) (addr+0x555),0xaa);
- my_out_8((unsigned char *) (addr+0x2aa),0x55);
- my_out_8( (unsigned char *) (addr+0x555),0xa0);
- my_out_8((unsigned char *) (dest+i) ,data_ch[i]);
- /* re-enable interrupts if necessary */
- if (flag)
- enable_interrupts();
-
- start = get_timer (0);
- last = start;
- while( ( my_in_8((unsigned char *) (dest+i)) ) != ( data_ch[i] ) ) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) {
- return 1;
- }
- }
- }/* for */
- }
-#elif defined( CONFIG_BOOT_16B)
- data_short[0]=(int) (data>>16) & 0xffff;
- data_short[1]=(int ) data & 0xffff ;
- for (i=0;i<2;i++ ){
- my_out_be16( (unsigned short *) ((ulong)addr+ 0xaaa),0xaa );
- my_out_be16( (unsigned short *) ((ulong)addr+ 0x554),0x55 );
- my_out_be16( (unsigned short *) ((ulong)addr+ 0xaaa),0xa0 );
- my_out_be16( (unsigned short *) (dest+(i*2)) ,data_short[i]);
- /* re-enable interrupts if necessary */
- if (flag)
- enable_interrupts();
- start = get_timer (0);
- last = start;
- while( ( my_in_be16((unsigned short *) (dest+(i*2))) ) != ( data_short[i] ) ) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT ) {
- return 1;
- }
- }
+ {
+ int data_ch[4];
+
+ data_ch[0] = (int) ((data >> 24) & 0xff);
+ data_ch[1] = (int) ((data >> 16) & 0xff);
+ data_ch[2] = (int) ((data >> 8) & 0xff);
+ data_ch[3] = (int) (data & 0xff);
+
+ for (i = 0; i < 4; i++) {
+ my_out_8((unsigned char *) (addr + 0x555), 0xaa);
+ my_out_8((unsigned char *) (addr + 0x2aa), 0x55);
+ my_out_8((unsigned char *) (addr + 0x555), 0xa0);
+ my_out_8((unsigned char *) (dest + i), data_ch[i]);
+
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+
+ start = get_timer(0);
+ while ((my_in_8((unsigned char *)(dest + i))) !=
+ (data_ch[i])) {
+ if (get_timer(start) >
+ CONFIG_SYS_FLASH_WRITE_TOUT) {
+ return 1;
+ }
+ }
+ } /* for */
+ }
+#elif defined(CONFIG_BOOT_16B)
+ data_short[0] = (int) (data >> 16) & 0xffff;
+ data_short[1] = (int) data & 0xffff;
+ for (i = 0; i < 2; i++) {
+ my_out_be16((unsigned short *)((ulong)addr + 0xaaa), 0xaa);
+ my_out_be16((unsigned short *)((ulong)addr + 0x554), 0x55);
+ my_out_be16((unsigned short *)((ulong)addr + 0xaaa), 0xa0);
+ my_out_be16((unsigned short *)(dest + (i * 2)),
+ data_short[i]);
+
+ /* re-enable interrupts if necessary */
+ if (flag)
+ enable_interrupts();
+
+ start = get_timer(0);
+ while ((my_in_be16((unsigned short *)(dest + (i * 2)))) !=
+ (data_short[i])) {
+ if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT)
+ return 1;
+ }
}
-#elif defined( CONFIG_BOOT_32B)
+#elif defined(CONFIG_BOOT_32B)
addr[0x0555] = 0x00AA00AA;
addr[0x02AA] = 0x00550055;
addr[0x0555] = 0x00A000A0;
@@ -747,51 +629,54 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
enable_interrupts();
/* data polling for D7 */
- start = get_timer (0);
+ start = get_timer(0);
while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) {
- if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
- return (1);
- }
+ if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT)
+ return 1;
}
#endif
-
-
- return (0);
+ return 0;
}
-#ifdef CONFIG_BOOT_8B
-static int my_in_8 ( unsigned char *addr)
+
+#ifdef CONFIG_BOOT_8B
+static int my_in_8(unsigned char *addr)
{
- int ret;
- __asm__ __volatile__("lbz%U1%X1 %0,%1; eieio" : "=r" (ret) : "m" (*addr));
- return ret;
+ int ret;
+ __asm__ __volatile__("lbz%U1%X1 %0,%1; eieio":"=r"(ret):"m"(*addr));
+
+ return ret;
}
-static void my_out_8 ( unsigned char *addr, int val)
+static void my_out_8(unsigned char *addr, int val)
{
- __asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+ __asm__ __volatile__("stb%U0%X0 %1,%0; eieio":"=m"(*addr):"r"(val));
}
#endif
-#ifdef CONFIG_BOOT_16B
-static int my_in_be16( unsigned short *addr)
+#ifdef CONFIG_BOOT_16B
+static int my_in_be16(unsigned short *addr)
{
- int ret;
- __asm__ __volatile__("lhz%U1%X1 %0,%1; eieio" : "=r" (ret) : "m" (*addr));
- return ret;
+ int ret;
+ __asm__ __volatile__("lhz%U1%X1 %0,%1; eieio":"=r"(ret):"m"(*addr));
+
+ return ret;
}
-static void my_out_be16( unsigned short *addr, int val)
+
+static void my_out_be16(unsigned short *addr, int val)
{
- __asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+ __asm__ __volatile__("sth%U0%X0 %1,%0; eieio":"=m"(*addr):"r"(val));
}
#endif
-#ifdef CONFIG_BOOT_32B
-static unsigned my_in_be32( unsigned *addr)
+#ifdef CONFIG_BOOT_32B
+static unsigned my_in_be32(unsigned *addr)
{
unsigned ret;
- __asm__ __volatile__("lwz%U1%X1 %0,%1; eieio" : "=r" (ret) : "m" (*addr));
- return ret;
+ __asm__ __volatile__("lwz%U1%X1 %0,%1; eieio":"=r"(ret):"m"(*addr));
+
+ return ret;
}
-static void my_out_be32( unsigned *addr, int val)
+
+static void my_out_be32(unsigned *addr, int val)
{
- __asm__ __volatile__("stw%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+ __asm__ __volatile__("stw%U0%X0 %1,%0; eieio":"=m"(*addr):"r"(val));
}
#endif
diff --git a/board/svm_sc8xx/svm_sc8xx.c b/board/svm_sc8xx/svm_sc8xx.c
index f34b83515e8..771bb4a5fea 100644
--- a/board/svm_sc8xx/svm_sc8xx.c
+++ b/board/svm_sc8xx/svm_sc8xx.c
@@ -80,15 +80,12 @@ int checkboard(void)
char buf[64];
int i;
int l = getenv_f("serial#", buf, sizeof(buf));
- int board_type;
if (l < 0 || strncmp(buf, "SVM8", 4)) {
printf("### No HW ID - assuming SVM SC8xx\n");
return (0);
}
- board_type = 1;
-
for (i = 0; i < l; ++i) {
if (buf[i] == ' ')
break;
@@ -97,7 +94,7 @@ int checkboard(void)
putc('\n');
- return (0);
+ return 0;
}
/* ------------------------------------------------------------------------- */
diff --git a/board/tqc/tqm5200/cam5200_flash.c b/board/tqc/tqm5200/cam5200_flash.c
index 4c8922f35f5..5329c2a4106 100644
--- a/board/tqc/tqm5200/cam5200_flash.c
+++ b/board/tqc/tqm5200/cam5200_flash.c
@@ -279,7 +279,7 @@ int flash_erase(flash_info_t * info, int s_first, int s_last)
{
volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[0]);
volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2;
- int flag, prot, sect, l_sect;
+ int flag, prot, sect;
if ((s_first < 0) || (s_first > s_last)) {
if (info->flash_id == FLASH_UNKNOWN)
@@ -305,8 +305,6 @@ int flash_erase(flash_info_t * info, int s_first, int s_last)
printf("\n");
- l_sect = -1;
-
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();
@@ -322,7 +320,6 @@ int flash_erase(flash_info_t * info, int s_first, int s_last)
addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00550055;
addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x00300030; /* sector erase */
- l_sect = sect;
/*
* Wait for each sector to complete, it's more
* reliable. According to AMD Spec, you must
@@ -609,7 +606,7 @@ static int flash_erase_16(flash_info_t * info, int s_first, int s_last)
{
volatile CONFIG_SYS_FLASH_WORD_SIZE *addr = (CONFIG_SYS_FLASH_WORD_SIZE *) (info->start[0]);
volatile CONFIG_SYS_FLASH_WORD_SIZE *addr2;
- int flag, prot, sect, l_sect;
+ int flag, prot, sect;
if ((s_first < 0) || (s_first > s_last)) {
if (info->flash_id == FLASH_UNKNOWN)
@@ -635,8 +632,6 @@ static int flash_erase_16(flash_info_t * info, int s_first, int s_last)
printf("\n");
- l_sect = -1;
-
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts();
@@ -652,7 +647,6 @@ static int flash_erase_16(flash_info_t * info, int s_first, int s_last)
addr[CONFIG_SYS_FLASH_ADDR1] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x55005500;
addr2[0] = (CONFIG_SYS_FLASH_WORD_SIZE) 0x30003000; /* sector erase */
- l_sect = sect;
/*
* Wait for each sector to complete, it's more
* reliable. According to AMD Spec, you must
diff --git a/board/tqc/tqm5200/cmd_stk52xx.c b/board/tqc/tqm5200/cmd_stk52xx.c
index 0789c5848eb..c40f7f0428c 100644
--- a/board/tqc/tqm5200/cmd_stk52xx.c
+++ b/board/tqc/tqm5200/cmd_stk52xx.c
@@ -82,18 +82,17 @@ static void spi_init(void)
static int spi_transmit(unsigned char data)
{
- int dummy;
struct mpc5xxx_spi *spi = (struct mpc5xxx_spi*)MPC5XXX_SPI;
spi->dr = data;
/* wait for SPI transmission completed */
- while(!(spi->sr & 0x80))
- {
- if (spi->sr & 0x40) /* if write collision occured */
- {
+ while (!(spi->sr & 0x80)) {
+ if (spi->sr & 0x40) { /* if write collision occured */
+ int dummy;
+
/* do dummy read to clear status register */
dummy = spi->dr;
- printf ("SPI write collision\n");
+ printf("SPI write collision: dr=0x%x\n", dummy);
return -1;
}
}
@@ -172,10 +171,8 @@ static void i2s_init(void)
psc->ccr = 0x1F03; /* 16 bit data width; 5.617MHz MCLK */
psc->ctur = 0x0F; /* 16 bit frame width */
- for(i=0;i<128;i++)
- {
+ for (i = 0; i < 128; i++)
psc->psc_buffer_32 = 0; /* clear tx fifo */
- }
}
static int i2s_play_wave(unsigned long addr, unsigned long len)
@@ -183,7 +180,6 @@ static int i2s_play_wave(unsigned long addr, unsigned long len)
unsigned long i;
unsigned char *wave_file = (uchar *)addr + 44; /* quick'n dirty: skip
* wav header*/
- unsigned char swapped[4];
struct mpc5xxx_psc *psc = (struct mpc5xxx_psc*)MPC5XXX_PSC2;
/*
@@ -192,11 +188,16 @@ static int i2s_play_wave(unsigned long addr, unsigned long len)
psc->command = (PSC_RX_ENABLE | PSC_TX_ENABLE);
for(i = 0;i < (len / 4); i++) {
+ unsigned char swapped[4];
+ unsigned long *p = (unsigned long*)swapped;
+
swapped[3] = *wave_file++;
swapped[2] = *wave_file++;
swapped[1] = *wave_file++;
swapped[0] = *wave_file++;
- psc->psc_buffer_32 = *((unsigned long*)swapped);
+
+ psc->psc_buffer_32 = *p;
+
while (psc->tfnum > 400) {
if(ctrlc())
return 0;
diff --git a/board/tqc/tqm8272/tqm8272.c b/board/tqc/tqm8272/tqm8272.c
index 9efb54125ec..5aca227789b 100644
--- a/board/tqc/tqm8272/tqm8272.c
+++ b/board/tqc/tqm8272/tqm8272.c
@@ -459,10 +459,9 @@ phys_size_t initdram (int board_type)
#ifndef CONFIG_SYS_RAMBOOT
long size8, size9;
#endif
- long psize, lsize;
+ long psize;
psize = 16 * 1024 * 1024;
- lsize = 0;
memctl->memc_psrt = CONFIG_SYS_PSRT;
memctl->memc_mptpr = CONFIG_SYS_MPTPR;