Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3ed3996cd | ||
|
|
73a8b27c57 | ||
|
|
08eaea9c9f | ||
|
|
53cf9435cc | ||
|
|
c602883592 | ||
|
|
3720878599 | ||
|
|
f3e0de60a6 | ||
|
|
682011ff69 | ||
|
|
7a8e9bed17 |
No files matched your search
@@ -2,6 +2,78 @@
|
||||
Changes since U-Boot 0.3.1:
|
||||
======================================================================
|
||||
|
||||
* Patch by Vladimir Gurevich, 04 Jun 2003:
|
||||
make ppc405 ethernet driver compatible with CONFIG_NET_MULTI option
|
||||
|
||||
* Patch by Stefan Roese, 05 Jun 2003:
|
||||
- PPC4xx: Fix bug for initial stack in data cache as pointed out by
|
||||
Thomas Schaefer (tschaefer@giga-stream.de). Now inital stack in
|
||||
data cache can be used even if the chip select is in use.
|
||||
- CFG_RX_ETH_BUFFER added to set the ethernet receive buffer count
|
||||
(see README for further description).
|
||||
- Changed config files of CONFIG_EEPRO100 boards to use the
|
||||
CFG_RX_ETH_BUFFER define.
|
||||
|
||||
* Add support for RMU board
|
||||
|
||||
* Add support for TQM862L at 100/50 MHz
|
||||
|
||||
* Patch by Pantelis Antoniou, 02 Jun 2003:
|
||||
major reconstruction of networking code;
|
||||
add "ping" support (outgoing only!)
|
||||
|
||||
* Patch by Denis Peter, 04 June 2003:
|
||||
add support for the MIP405T board
|
||||
|
||||
* Patches by Udi Finkelstein, 2 June 2003:
|
||||
- Added support for custom keyboards, initialized by defining a
|
||||
board-specific drv_keyboard_init as well as defining CONFIG_KEYBOARD .
|
||||
- Added support for the RBC823 board.
|
||||
- cpu/mpc8xx/lcd.c now automatically calculates the
|
||||
Horizontal Pixel Count field.
|
||||
|
||||
* Fix alignment problem in BOOTP (dhcp_leasetime option)
|
||||
[pointed out by Nicolas Lacressonnière, 2 Jun 2003]
|
||||
|
||||
* Patch by Mark Rakes, 14 May 2003:
|
||||
add support for Intel e1000 gig cards.
|
||||
|
||||
* Patch by Nye Liu, 3 Jun 2003:
|
||||
fix critical typo in MAMR definition (include/mpc8xx.h)
|
||||
|
||||
* Fix requirement to align U-Boot image on 16 kB boundaries on PPC.
|
||||
|
||||
* Patch by Klaus Heydeck, 2 Jun 2003
|
||||
Minor changes for KUP4K configuration
|
||||
|
||||
* Patch by Marc Singer, 29 May 2003:
|
||||
Fixed rarp boot method for IA32 and other little-endian CPUs.
|
||||
|
||||
* Patch by Marc Singer, 28 May 2003:
|
||||
Added port I/O commands.
|
||||
|
||||
* Patch by Matthew McClintock, 28 May 2003
|
||||
- cpu/mpc824x/start.S: fix relocation code when booting from RAM
|
||||
- minor patches for utx8245
|
||||
|
||||
* Patch by Daniel Engström, 28 May 2003:
|
||||
x86 update
|
||||
|
||||
* Patch by Dave Ellis, 9 May 2003 + 27 May 2003:
|
||||
add nand flash support to SXNI855T configuration
|
||||
fix/extend nand flash support:
|
||||
- fix 'nand erase' command so does not erase bad blocks
|
||||
- fix 'nand write' command so does not write to bad blocks
|
||||
- fix nand_probe() so handles no flash detected properly
|
||||
- add doc/README.nand
|
||||
- add .jffs2 and .oob options to nand read/write
|
||||
- add 'nand bad' command to list bad blocks
|
||||
- add 'clean' option to 'nand erase' to write JFFS2 clean markers
|
||||
- make NAND read/write faster
|
||||
|
||||
* Patch by Rune Torgersen, 23 May 2003:
|
||||
Update for MPC8266ADS board
|
||||
|
||||
* Get (mostly) rid of CFG_MONITOR_LEN definition; compute real length
|
||||
instead CFG_MONITOR_LEN is now only used to determine _at_compile_
|
||||
_time_ (!) if the environment is embedded within the U-Boot image,
|
||||
|
||||
@@ -63,6 +63,9 @@ Wolfgang Denk <wd@denx.de>
|
||||
IVMS8_128 MPC860
|
||||
IVMS8_256 MPC860
|
||||
LANTEC MPC850
|
||||
LWMON MPC823
|
||||
R360MPI MPC823
|
||||
RMU MPC850
|
||||
RRvision MPC823
|
||||
SM850 MPC850
|
||||
SPD823TS MPC823
|
||||
@@ -72,6 +75,7 @@ Wolfgang Denk <wd@denx.de>
|
||||
TQM855L MPC855
|
||||
TQM860L MPC860
|
||||
TQM860L_FEC MPC860
|
||||
TTTech MPC823
|
||||
c2mon MPC855
|
||||
hermes MPC860
|
||||
lwmon MPC823
|
||||
|
||||
@@ -32,11 +32,11 @@ LIST_8xx=" \
|
||||
IVMS8 IVMS8_128 IVMS8_256 KUP4K \
|
||||
LANTEC lwmon MBX MBX860T \
|
||||
MHPC MVS1 NETVIA NX823 \
|
||||
pcu_e R360MPI RPXClassic RPXlite \
|
||||
RRvision SM850 SPD823TS svm_sc8xx \
|
||||
SXNI855T TOP860 TQM823L TQM823L_LCD \
|
||||
TQM850L TQM855L TQM860L TTTech \
|
||||
v37 \
|
||||
pcu_e R360MPI RBC823 rmu \
|
||||
RPXClassic RPXlite RRvision SM850 \
|
||||
SPD823TS svm_sc8xx SXNI855T TOP860 \
|
||||
TQM823L TQM823L_LCD TQM850L TQM855L \
|
||||
TQM860L TTTech v37 \
|
||||
"
|
||||
|
||||
#########################################################################
|
||||
@@ -48,9 +48,9 @@ LIST_4xx=" \
|
||||
CANBT CPCI405 CPCI4052 CPCI405AB \
|
||||
CPCI440 CPCIISER4 CRAYL1 DASA_SIM \
|
||||
DU405 EBONY ERIC MIP405 \
|
||||
ML2 OCRTC ORSG PCI405 \
|
||||
PIP405 PMC405 W7OLMC W7OLMG \
|
||||
WALNUT405 \
|
||||
MIP405T ML2 OCRTC ORSG \
|
||||
PCI405 PIP405 PMC405 W7OLMC \
|
||||
W7OLMG WALNUT405 \
|
||||
"
|
||||
|
||||
#########################################################################
|
||||
@@ -129,6 +129,15 @@ LIST_mips5kc="purple"
|
||||
|
||||
LIST_mips="${LIST_mips4kc} ${LIST_mips5kc}"
|
||||
|
||||
#########################################################################
|
||||
## i386 Systems
|
||||
#########################################################################
|
||||
|
||||
LIST_I486="sc520_cdp sc520_spunk sc520_spunk_rel"
|
||||
|
||||
LIST_x86="${LIST_I486}"
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#----- for now, just run PPC by default -----
|
||||
[ $# = 0 ] && set $LIST_ppc
|
||||
@@ -150,7 +159,7 @@ build_target() {
|
||||
for arg in $@
|
||||
do
|
||||
case "$arg" in
|
||||
5xx|8xx|824x|8260|4xx|7xx|74xx|SA|ARM7|ARM9|ppc|arm|pxa|mips)
|
||||
5xx|8xx|824x|8260|4xx|7xx|74xx|SA|ARM7|ARM9|ppc|arm|pxa|mips|I486|x86)
|
||||
for target in `eval echo '$LIST_'${arg}`
|
||||
do
|
||||
build_target ${target}
|
||||
|
||||
@@ -60,7 +60,11 @@ ifeq ($(ARCH),arm)
|
||||
CROSS_COMPILE = arm-linux-
|
||||
endif
|
||||
ifeq ($(ARCH),i386)
|
||||
#CROSS_COMPILE = i386-elf-
|
||||
ifeq ($(HOSTARCH),i386)
|
||||
CROSS_COMPILE =
|
||||
else
|
||||
CROSS_COMPILE = i386-linux-
|
||||
endif
|
||||
endif
|
||||
ifeq ($(ARCH),mips)
|
||||
CROSS_COMPILE = mips_4KC-
|
||||
@@ -310,12 +314,18 @@ pcu_e_config: unconfig
|
||||
R360MPI_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc mpc8xx r360mpi
|
||||
|
||||
RBC823_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc mpc8xx rbc823
|
||||
|
||||
RPXClassic_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc mpc8xx RPXClassic
|
||||
|
||||
RPXlite_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc mpc8xx RPXlite
|
||||
|
||||
rmu_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc mpc8xx rmu
|
||||
|
||||
RRvision_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc mpc8xx RRvision
|
||||
|
||||
@@ -342,10 +352,10 @@ TOP860_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc mpc8xx top860 emk
|
||||
|
||||
# Play some tricks for configuration selection
|
||||
# All boards can come with 50 MHz (default), 66MHz or 80MHz clock,
|
||||
# All boards can come with 50 MHz (default), 66MHz, 80MHz or 100 MHz clock,
|
||||
# but only 855 and 860 boards may come with FEC
|
||||
# and 823 boards may have LCD support
|
||||
xtract_8xx = $(subst _66MHz,,$(subst _80MHz,,$(subst _LCD,,$(subst _config,,$1))))
|
||||
xtract_8xx = $(subst _66MHz,,$(subst _80MHz,,$(subst _100MHz,,$(subst _LCD,,$(subst _config,,$1)))))
|
||||
|
||||
FPS850L_config \
|
||||
FPS860L_config \
|
||||
@@ -366,7 +376,8 @@ TQM860L_66MHz_config \
|
||||
TQM860L_80MHz_config \
|
||||
TQM862L_config \
|
||||
TQM862L_66MHz_config \
|
||||
TQM862L_80MHz_config: unconfig
|
||||
TQM862L_80MHz_config \
|
||||
TQM862L_100MHz_config: unconfig
|
||||
@ >include/config.h
|
||||
@[ -z "$(findstring _66MHz,$@)" ] || \
|
||||
{ echo "#define CONFIG_66MHz" >>include/config.h ; \
|
||||
@@ -376,6 +387,10 @@ TQM862L_80MHz_config: unconfig
|
||||
{ echo "#define CONFIG_80MHz" >>include/config.h ; \
|
||||
echo "... with 80MHz system clock" ; \
|
||||
}
|
||||
@[ -z "$(findstring _100MHz,$@)" ] || \
|
||||
{ echo "#define CONFIG_100MHz" >>include/config.h ; \
|
||||
echo "... with 100MHz system clock" ; \
|
||||
}
|
||||
@[ -z "$(findstring _LCD,$@)" ] || \
|
||||
{ echo "#define CONFIG_LCD" >>include/config.h ; \
|
||||
echo "#define CONFIG_NEC_NL6648BC20" >>include/config.h ; \
|
||||
@@ -442,6 +457,11 @@ ERIC_config:unconfig
|
||||
MIP405_config:unconfig
|
||||
@./mkconfig $(@:_config=) ppc ppc4xx mip405 mpl
|
||||
|
||||
MIP405T_config:unconfig
|
||||
@echo "#define CONFIG_MIP405T" >include/config.h
|
||||
@echo "Enable subset config for MIP405T"
|
||||
@./mkconfig -a MIP405 ppc ppc4xx mip405 mpl
|
||||
|
||||
ML2_config:unconfig
|
||||
@./mkconfig $(@:_config=) ppc ppc4xx ml2
|
||||
|
||||
@@ -729,6 +749,12 @@ wepep250_config : unconfig
|
||||
sc520_cdp_config : unconfig
|
||||
@./mkconfig $(@:_config=) i386 i386 sc520_cdp
|
||||
|
||||
sc520_spunk_config : unconfig
|
||||
@./mkconfig $(@:_config=) i386 i386 sc520_spunk
|
||||
|
||||
sc520_spunk_rel_config : unconfig
|
||||
@./mkconfig $(@:_config=) i386 i386 sc520_spunk
|
||||
|
||||
#========================================================================
|
||||
# MIPS
|
||||
#========================================================================
|
||||
@@ -752,7 +778,8 @@ clean:
|
||||
| xargs rm -f
|
||||
rm -f examples/hello_world examples/timer \
|
||||
examples/eepro100_eeprom examples/sched \
|
||||
examples/mem_to_mem_idma2intr
|
||||
examples/mem_to_mem_idma2intr examples/82559_eeprom
|
||||
|
||||
rm -f tools/img2srec tools/mkimage tools/envcrc tools/gen_eth_addr
|
||||
rm -f tools/easylogo/easylogo tools/bmp_logo
|
||||
rm -f tools/gdb/astest tools/gdb/gdbcont tools/gdb/gdbsend
|
||||
|
||||
@@ -344,7 +344,7 @@ The following options need to be configured:
|
||||
CONFIG_IAD210, CONFIG_RPXlite, CONFIG_sbc8260,
|
||||
CONFIG_EBONY, CONFIG_sacsng, CONFIG_FPS860L,
|
||||
CONFIG_V37, CONFIG_ELPT860, CONFIG_CMI,
|
||||
CONFIG_NETVIA
|
||||
CONFIG_NETVIA, CONFIG_RBC823
|
||||
|
||||
ARM based boards:
|
||||
-----------------
|
||||
@@ -688,6 +688,9 @@ The following options need to be configured:
|
||||
CFG_SCSI_SYM53C8XX_CCF to fix clock timing (80Mhz)
|
||||
|
||||
- NETWORK Support (PCI):
|
||||
CONFIG_E1000
|
||||
Support for Intel 8254x gigabit chips.
|
||||
|
||||
CONFIG_EEPRO100
|
||||
Support for Intel 82557/82559/82559ER chips.
|
||||
Optional CONFIG_EEPRO100_SROM_WRITE enables eeprom
|
||||
@@ -766,6 +769,13 @@ The following options need to be configured:
|
||||
and 16bpp modes defined by CONFIG_VIDEO_SED13806_8BPP
|
||||
or CONFIG_VIDEO_SED13806_16BPP
|
||||
|
||||
- Keyboard Support:
|
||||
CONFIG_KEYBOARD
|
||||
|
||||
Define this to enable a custom keyboard support.
|
||||
This simply calls drv_keyboard_init() which must be
|
||||
defined in your board-specific files.
|
||||
The only board using this so far is RBC823.
|
||||
|
||||
- LCD Support: CONFIG_LCD
|
||||
|
||||
@@ -1432,6 +1442,14 @@ Configuration Settings:
|
||||
Define if the flash driver uses extra elements in the
|
||||
common flash structure for storing flash geometry
|
||||
|
||||
- CFG_RX_ETH_BUFFER:
|
||||
Defines the number of ethernet receive buffers. On some
|
||||
ethernet controllers it is recommended to set this value
|
||||
to 8 or even higher (EEPRO100 or 405 EMAC), since all
|
||||
buffers can be full shortly after enabling the interface
|
||||
on high ethernet traffic.
|
||||
Defaults to 4 if not defined.
|
||||
|
||||
The following definitions that deal with the placement and management
|
||||
of environment data (variable area); in general, we support the
|
||||
following configurations:
|
||||
|
||||
@@ -36,6 +36,3 @@ getline(char *buf,int *num,int max_num)
|
||||
line_pointer = line_pointer + *num;
|
||||
len = len - *num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -172,6 +172,9 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
value = value|(value<<16);
|
||||
|
||||
switch (value) {
|
||||
case AMD_MANUFACT:
|
||||
info->flash_id = FLASH_MAN_AMD;
|
||||
break;
|
||||
case FUJ_MANUFACT:
|
||||
info->flash_id = FLASH_MAN_FUJ;
|
||||
break;
|
||||
@@ -191,6 +194,16 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
info->sector_count = 19;
|
||||
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 */
|
||||
default:
|
||||
info->flash_id = FLASH_UNKNOWN;
|
||||
return (0); /* => no or unknown flash */
|
||||
|
||||
+233
-228
@@ -54,10 +54,7 @@ const uint sdram_table[] =
|
||||
/*
|
||||
* Single Read. (Offset 0 in UPMA RAM)
|
||||
*/
|
||||
0x1F07FC04,
|
||||
0xEEAEFC04,
|
||||
0x11ADFC04,
|
||||
0xEFBBBC00,
|
||||
0x1F07FC04, 0xEEAEFC04, 0x11ADFC04, 0xEFBBBC00,
|
||||
0x1FF77C47, /* last */
|
||||
|
||||
/*
|
||||
@@ -68,57 +65,37 @@ const uint sdram_table[] =
|
||||
* sequence, which is executed by a RUN command.
|
||||
*
|
||||
*/
|
||||
0x1FF77C35,
|
||||
0xEFEABC34,
|
||||
0x1FB57C35, /* last */
|
||||
0x1FF77C35, 0xEFEABC34, 0x1FB57C35, /* last */
|
||||
|
||||
/*
|
||||
* Burst Read. (Offset 8 in UPMA RAM)
|
||||
*/
|
||||
0x1F07FC04,
|
||||
0xEEAEFC04,
|
||||
0x10ADFC04,
|
||||
0xF0AFFC00,
|
||||
0xF0AFFC00,
|
||||
0xF1AFFC00,
|
||||
0xEFBBBC00,
|
||||
0x1FF77C47, /* last */
|
||||
0x1F07FC04, 0xEEAEFC04, 0x10ADFC04, 0xF0AFFC00,
|
||||
0xF0AFFC00, 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C47, /* last */
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
|
||||
/*
|
||||
* Single Write. (Offset 18 in UPMA RAM)
|
||||
*/
|
||||
0x1F27FC04,
|
||||
0xEEAEBC00,
|
||||
0x01B93C04,
|
||||
0x1FF77C47, /* last */
|
||||
0x1F27FC04, 0xEEAEBC00, 0x01B93C04, 0x1FF77C47, /* last */
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
|
||||
/*
|
||||
* Burst Write. (Offset 20 in UPMA RAM)
|
||||
*/
|
||||
0x1F07FC04,
|
||||
0xEEAEBC00,
|
||||
0x10AD7C00,
|
||||
0xF0AFFC00,
|
||||
0xF0AFFC00,
|
||||
0xE1BBBC04,
|
||||
0x1FF77C47, /* last */
|
||||
_NOT_USED_,
|
||||
0x1F07FC04, 0xEEAEBC00, 0x10AD7C00, 0xF0AFFC00,
|
||||
0xF0AFFC00, 0xE1BBBC04, 0x1FF77C47, /* last */
|
||||
_NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
|
||||
/*
|
||||
* Refresh (Offset 30 in UPMA RAM)
|
||||
*/
|
||||
0x1FF5FC84,
|
||||
0xFFFFFC04,
|
||||
0xFFFFFC04,
|
||||
0xFFFFFC04,
|
||||
0xFFFFFC84,
|
||||
0xFFFFFC07, /* last */
|
||||
_NOT_USED_, _NOT_USED_,
|
||||
0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
|
||||
0xFFFFFC84, 0xFFFFFC07, /* last */
|
||||
_NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
|
||||
/*
|
||||
@@ -146,89 +123,96 @@ int checkboard (void)
|
||||
|
||||
long int initdram (int board_type)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
long int size_b0 = 0;
|
||||
long int size_b1 = 0;
|
||||
long int size_b2 = 0;
|
||||
volatile immap_t *immap = (immap_t *) CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
long int size_b0 = 0;
|
||||
long int size_b1 = 0;
|
||||
long int size_b2 = 0;
|
||||
|
||||
upmconfig(UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
|
||||
upmconfig (UPMA, (uint *) sdram_table,
|
||||
sizeof (sdram_table) / sizeof (uint));
|
||||
|
||||
/*
|
||||
* Preliminary prescaler for refresh (depends on number of
|
||||
* banks): This value is selected for four cycles every 62.4 us
|
||||
* with two SDRAM banks or four cycles every 31.2 us with one
|
||||
* bank. It will be adjusted after memory sizing.
|
||||
*/
|
||||
memctl->memc_mptpr = CFG_MPTPR;
|
||||
/*
|
||||
* Preliminary prescaler for refresh (depends on number of
|
||||
* banks): This value is selected for four cycles every 62.4 us
|
||||
* with two SDRAM banks or four cycles every 31.2 us with one
|
||||
* bank. It will be adjusted after memory sizing.
|
||||
*/
|
||||
memctl->memc_mptpr = CFG_MPTPR;
|
||||
|
||||
memctl->memc_mar = 0x00000088;
|
||||
memctl->memc_mar = 0x00000088;
|
||||
|
||||
/*
|
||||
* Map controller banks 1 and 2 to the SDRAM banks 2 and 3 at
|
||||
* preliminary addresses - these have to be modified after the
|
||||
* SDRAM size has been determined.
|
||||
*/
|
||||
/* memctl->memc_or1 = CFG_OR1_PRELIM; */
|
||||
/* memctl->memc_br1 = CFG_BR1_PRELIM; */
|
||||
|
||||
/*
|
||||
* Map controller banks 1 and 2 to the SDRAM banks 2 and 3 at
|
||||
* preliminary addresses - these have to be modified after the
|
||||
* SDRAM size has been determined.
|
||||
*/
|
||||
/* memctl->memc_or1 = CFG_OR1_PRELIM; */
|
||||
/* memctl->memc_br1 = CFG_BR1_PRELIM; */
|
||||
|
||||
/* memctl->memc_or2 = CFG_OR2_PRELIM; */
|
||||
/* memctl->memc_br2 = CFG_BR2_PRELIM; */
|
||||
|
||||
|
||||
memctl->memc_mamr = CFG_MAMR & (~(MAMR_PTAE)); /* no refresh yet */
|
||||
memctl->memc_mamr = CFG_MAMR & (~(MAMR_PTAE)); /* no refresh yet */
|
||||
|
||||
udelay(200);
|
||||
udelay (200);
|
||||
|
||||
/* perform SDRAM initializsation sequence */
|
||||
/* perform SDRAM initializsation sequence */
|
||||
|
||||
memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */
|
||||
udelay(1);
|
||||
memctl->memc_mcr = 0x80002830; /* SDRAM bank 0 - execute twice */
|
||||
udelay(1);
|
||||
memctl->memc_mcr = 0x80002106; /* SDRAM bank 0 - RUN MRS Pattern from loc 6 */
|
||||
udelay(1);
|
||||
memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */
|
||||
udelay (1);
|
||||
memctl->memc_mcr = 0x80002830; /* SDRAM bank 0 - execute twice */
|
||||
udelay (1);
|
||||
memctl->memc_mcr = 0x80002106; /* SDRAM bank 0 - RUN MRS Pattern from loc 6 */
|
||||
udelay (1);
|
||||
|
||||
memctl->memc_mcr = 0x80004105; /* SDRAM bank 1 */
|
||||
udelay(1);
|
||||
memctl->memc_mcr = 0x80004830; /* SDRAM bank 1 - execute twice */
|
||||
udelay(1);
|
||||
memctl->memc_mcr = 0x80004106; /* SDRAM bank 1 - RUN MRS Pattern from loc 6 */
|
||||
udelay(1);
|
||||
memctl->memc_mcr = 0x80004105; /* SDRAM bank 1 */
|
||||
udelay (1);
|
||||
memctl->memc_mcr = 0x80004830; /* SDRAM bank 1 - execute twice */
|
||||
udelay (1);
|
||||
memctl->memc_mcr = 0x80004106; /* SDRAM bank 1 - RUN MRS Pattern from loc 6 */
|
||||
udelay (1);
|
||||
|
||||
memctl->memc_mcr = 0x80006105; /* SDRAM bank 2 */
|
||||
udelay(1);
|
||||
memctl->memc_mcr = 0x80006830; /* SDRAM bank 2 - execute twice */
|
||||
udelay(1);
|
||||
memctl->memc_mcr = 0x80006106; /* SDRAM bank 2 - RUN MRS Pattern from loc 6 */
|
||||
udelay(1);
|
||||
|
||||
|
||||
memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */
|
||||
|
||||
udelay (1000);
|
||||
|
||||
size_b0 = 0x00800000;
|
||||
size_b1 = 0x00800000;
|
||||
size_b2 = 0x00800000;
|
||||
memctl->memc_mcr = 0x80006105; /* SDRAM bank 2 */
|
||||
udelay (1);
|
||||
memctl->memc_mcr = 0x80006830; /* SDRAM bank 2 - execute twice */
|
||||
udelay (1);
|
||||
memctl->memc_mcr = 0x80006106; /* SDRAM bank 2 - RUN MRS Pattern from loc 6 */
|
||||
udelay (1);
|
||||
|
||||
memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */
|
||||
udelay (1000);
|
||||
|
||||
#if 0 /* 3 x 8MB */
|
||||
size_b0 = 0x00800000;
|
||||
size_b1 = 0x00800000;
|
||||
size_b2 = 0x00800000;
|
||||
memctl->memc_mptpr = CFG_MPTPR;
|
||||
udelay(1000);
|
||||
|
||||
udelay (1000);
|
||||
memctl->memc_or1 = 0xFF800A00;
|
||||
memctl->memc_br1 = 0x00000081;
|
||||
|
||||
memctl->memc_or2 = 0xFF000A00;
|
||||
memctl->memc_br2 = 0x00800081;
|
||||
|
||||
memctl->memc_or2 = 0xFF000A00;
|
||||
memctl->memc_br2 = 0x00800081;
|
||||
memctl->memc_or3 = 0xFE000A00;
|
||||
memctl->memc_br3 = 0x01000081;
|
||||
#else /* 3 x 16 MB */
|
||||
size_b0 = 0x01000000;
|
||||
size_b1 = 0x01000000;
|
||||
size_b2 = 0x01000000;
|
||||
memctl->memc_mptpr = CFG_MPTPR;
|
||||
udelay (1000);
|
||||
memctl->memc_or1 = 0xFF000A00;
|
||||
memctl->memc_br1 = 0x00000081;
|
||||
memctl->memc_or2 = 0xFE000A00;
|
||||
memctl->memc_br2 = 0x01000081;
|
||||
memctl->memc_or3 = 0xFC000A00;
|
||||
memctl->memc_br3 = 0x02000081;
|
||||
#endif
|
||||
|
||||
udelay(10000);
|
||||
udelay (10000);
|
||||
|
||||
|
||||
return (size_b0 + size_b1 + size_b2);
|
||||
return (size_b0 + size_b1 + size_b2);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
@@ -241,46 +225,47 @@ long int initdram (int board_type)
|
||||
* - short between data lines
|
||||
*/
|
||||
#if 0
|
||||
static long int dram_size (long int mamr_value, long int *base, long int maxsize)
|
||||
static long int dram_size (long int mamr_value, long int *base,
|
||||
long int maxsize)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
volatile long int *addr;
|
||||
ulong cnt, val;
|
||||
ulong save[32]; /* to make test non-destructive */
|
||||
unsigned char i = 0;
|
||||
volatile immap_t *immap = (immap_t *) CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
volatile long int *addr;
|
||||
ulong cnt, val;
|
||||
ulong save[32]; /* to make test non-destructive */
|
||||
unsigned char i = 0;
|
||||
|
||||
memctl->memc_mamr = mamr_value;
|
||||
memctl->memc_mamr = mamr_value;
|
||||
|
||||
for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
for (cnt = maxsize / sizeof (long); cnt > 0; cnt >>= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
|
||||
save[i++] = *addr;
|
||||
*addr = ~cnt;
|
||||
}
|
||||
|
||||
/* write 0 to base address */
|
||||
addr = base;
|
||||
save[i] = *addr;
|
||||
*addr = 0;
|
||||
|
||||
/* check at base address */
|
||||
if ((val = *addr) != 0) {
|
||||
*addr = save[i];
|
||||
return (0);
|
||||
}
|
||||
|
||||
for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
|
||||
val = *addr;
|
||||
*addr = save[--i];
|
||||
|
||||
if (val != (~cnt)) {
|
||||
return (cnt * sizeof(long));
|
||||
save[i++] = *addr;
|
||||
*addr = ~cnt;
|
||||
}
|
||||
}
|
||||
return (maxsize);
|
||||
|
||||
/* write 0 to base address */
|
||||
addr = base;
|
||||
save[i] = *addr;
|
||||
*addr = 0;
|
||||
|
||||
/* check at base address */
|
||||
if ((val = *addr) != 0) {
|
||||
*addr = save[i];
|
||||
return (0);
|
||||
}
|
||||
|
||||
for (cnt = 1; cnt <= maxsize / sizeof (long); cnt <<= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
|
||||
val = *addr;
|
||||
*addr = save[--i];
|
||||
|
||||
if (val != (~cnt)) {
|
||||
return (cnt * sizeof (long));
|
||||
}
|
||||
}
|
||||
return (maxsize);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -289,155 +274,175 @@ int misc_init_r (void)
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#ifdef CONFIG_STATUS_LED
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile immap_t *immap = (immap_t *) CFG_IMMR;
|
||||
#endif
|
||||
#ifdef CONFIG_KUP4K_LOGO
|
||||
bd_t *bd = gd->bd;
|
||||
|
||||
|
||||
lcd_logo(bd);
|
||||
#endif /* CONFIG_KUP4K_LOGO */
|
||||
lcd_logo (bd);
|
||||
#endif /* CONFIG_KUP4K_LOGO */
|
||||
#ifdef CONFIG_IDE_LED
|
||||
/* Configure PA8 as output port */
|
||||
immap->im_ioport.iop_padir |= 0x80;
|
||||
immap->im_ioport.iop_paodr |= 0x80;
|
||||
immap->im_ioport.iop_papar &= ~0x80;
|
||||
immap->im_ioport.iop_padat |= 0x80; /* turn it off */
|
||||
immap->im_ioport.iop_padat |= 0x80; /* turn it off */
|
||||
#endif
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KUP4K_LOGO
|
||||
void lcd_logo(bd_t *bd){
|
||||
|
||||
FB_INFO_S1D13xxx fb_info;
|
||||
S1D_INDEX s1dReg;
|
||||
S1D_VALUE s1dValue;
|
||||
volatile immap_t *immr = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl;
|
||||
|
||||
#define PB_LCD_PWM ((uint)0x00004000) /* PB 17 */
|
||||
|
||||
void lcd_logo (bd_t * bd)
|
||||
{
|
||||
|
||||
|
||||
volatile immap_t *immap = (immap_t *) CFG_IMMR;
|
||||
|
||||
|
||||
|
||||
FB_INFO_S1D13xxx fb_info;
|
||||
S1D_INDEX s1dReg;
|
||||
S1D_VALUE s1dValue;
|
||||
volatile immap_t *immr = (immap_t *) CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl;
|
||||
ushort i;
|
||||
uchar *fb;
|
||||
int rs, gs, bs;
|
||||
int r = 8, g = 8, b = 4;
|
||||
int r1,g1,b1;
|
||||
int rs, gs, bs;
|
||||
int r = 8, g = 8, b = 4;
|
||||
int r1, g1, b1;
|
||||
|
||||
immr->im_cpm.cp_pbpar &= ~PB_LCD_PWM;
|
||||
immr->im_cpm.cp_pbodr &= ~PB_LCD_PWM;
|
||||
immr->im_cpm.cp_pbdat &= ~PB_LCD_PWM; /* set to 0 = enabled */
|
||||
immr->im_cpm.cp_pbdir |= PB_LCD_PWM;
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------- */
|
||||
/**/
|
||||
/**/
|
||||
/* Initialize the chip and the frame buffer driver. */
|
||||
/**/
|
||||
/**/
|
||||
/*----------------------------------------------------------------------------- */
|
||||
memctl = &immr->im_memctl;
|
||||
memctl = &immr->im_memctl;
|
||||
/* memctl->memc_or5 = 0xFFC007F0; / * 4 MB 17 WS or externel TA */
|
||||
/* memctl->memc_br5 = 0x80000801; / * Start at 0x80000000 */
|
||||
|
||||
memctl->memc_or5 = 0xFFC00708; /* 4 MB 17 WS or externel TA */
|
||||
memctl->memc_br5 = 0x80080801; /* Start at 0x80080000 */
|
||||
memctl->memc_or5 = 0xFFC00708; /* 4 MB 17 WS or externel TA */
|
||||
memctl->memc_br5 = 0x80080801; /* Start at 0x80080000 */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fb_info.VmemAddr = (unsigned char*)(S1D_PHYSICAL_VMEM_ADDR);
|
||||
fb_info.RegAddr = (unsigned char*)(S1D_PHYSICAL_REG_ADDR);
|
||||
fb_info.VmemAddr = (unsigned char *) (S1D_PHYSICAL_VMEM_ADDR);
|
||||
fb_info.RegAddr = (unsigned char *) (S1D_PHYSICAL_REG_ADDR);
|
||||
|
||||
if ((((S1D_VALUE*)fb_info.RegAddr)[0] != 0x28) || (((S1D_VALUE*)fb_info.RegAddr)[1] != 0x14))
|
||||
{
|
||||
printf("Warning:LCD Controller S1D13706 not found\n");
|
||||
return;
|
||||
}
|
||||
if ((((S1D_VALUE *) fb_info.RegAddr)[0] != 0x28)
|
||||
|| (((S1D_VALUE *) fb_info.RegAddr)[1] != 0x14)) {
|
||||
printf ("Warning:LCD Controller S1D13706 not found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* init controller */
|
||||
for (i = 0; i < sizeof(aS1DRegs)/sizeof(aS1DRegs[0]); i++)
|
||||
{
|
||||
s1dReg = aS1DRegs[i].Index;
|
||||
s1dValue = aS1DRegs[i].Value;
|
||||
/* init controller */
|
||||
for (i = 0; i < sizeof (aS1DRegs) / sizeof (aS1DRegs[0]); i++) {
|
||||
s1dReg = aS1DRegs[i].Index;
|
||||
s1dValue = aS1DRegs[i].Value;
|
||||
/* printf("sid1 Index: %02x Register: %02x Wert: %02x\n",i, aS1DRegs[i].Index, aS1DRegs[i].Value); */
|
||||
((S1D_VALUE*)fb_info.RegAddr)[s1dReg/sizeof(S1D_VALUE)] = s1dValue;
|
||||
}
|
||||
((S1D_VALUE *) fb_info.RegAddr)[s1dReg / sizeof (S1D_VALUE)] =
|
||||
s1dValue;
|
||||
}
|
||||
|
||||
#undef MONOCHROME
|
||||
#ifdef MONOCHROME
|
||||
switch(bd->bi_busfreq){
|
||||
switch (bd->bi_busfreq) {
|
||||
#if 0
|
||||
case 24000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x28;
|
||||
break;
|
||||
case 32000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x33;
|
||||
break;
|
||||
case 24000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x28;
|
||||
break;
|
||||
case 32000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x33;
|
||||
break;
|
||||
#endif
|
||||
case 40000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x40;
|
||||
break;
|
||||
case 48000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x4C;
|
||||
break;
|
||||
default:
|
||||
printf("KUP4K S1D1: unknown busfrequency: %ld assuming 64 MHz\n",bd->bi_busfreq);
|
||||
case 64000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x69;
|
||||
break;
|
||||
case 40000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x40;
|
||||
break;
|
||||
case 48000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x4C;
|
||||
break;
|
||||
default:
|
||||
printf ("KUP4K S1D1: unknown busfrequency: %ld assuming 64 MHz\n",
|
||||
bd->bi_busfreq);
|
||||
case 64000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x69;
|
||||
break;
|
||||
}
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x10] = 0x00;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x10] = 0x00;
|
||||
#else
|
||||
switch(bd->bi_busfreq){
|
||||
switch (bd->bi_busfreq) {
|
||||
#if 0
|
||||
case 24000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x22;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x34;
|
||||
break;
|
||||
case 32000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x34;
|
||||
break;
|
||||
case 24000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x22;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x34;
|
||||
break;
|
||||
case 32000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x34;
|
||||
break;
|
||||
#endif
|
||||
case 40000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x41;
|
||||
break;
|
||||
case 48000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x22;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x34;
|
||||
break;
|
||||
default:
|
||||
printf("KUP4K S1D1: unknown busfrequency: %ld assuming 64 MHz\n",bd->bi_busfreq);
|
||||
case 64000000:
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE*)fb_info.RegAddr)[0x12] = 0x66;
|
||||
break;
|
||||
case 40000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x41;
|
||||
break;
|
||||
case 48000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x22;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x34;
|
||||
break;
|
||||
default:
|
||||
printf ("KUP4K S1D1: unknown busfrequency: %ld assuming 64 MHz\n",
|
||||
bd->bi_busfreq);
|
||||
case 64000000:
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x05] = 0x32;
|
||||
((S1D_VALUE *) fb_info.RegAddr)[0x12] = 0x66;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* create and set colormap */
|
||||
rs = 256 / (r - 1);
|
||||
gs = 256 / (g - 1);
|
||||
bs = 256 / (b - 1);
|
||||
for(i=0;i<256;i++){
|
||||
r1=(rs * ((i / (g * b)) % r)) * 255;
|
||||
g1=(gs * ((i / b) % g)) * 255;
|
||||
b1=(bs * ((i) % b)) * 255;
|
||||
/* printf("%d %04x %04x %04x\n",i,r1>>4,g1>>4,b1>>4); */
|
||||
S1D_WRITE_PALETTE(fb_info.RegAddr,i,(r1>>4),(g1>>4),(b1>>4));
|
||||
}
|
||||
|
||||
/* copy bitmap */
|
||||
fb = (char *) (fb_info.VmemAddr);
|
||||
memcpy (fb, (uchar *)CONFIG_KUP4K_LOGO, 320 * 240);
|
||||
/* create and set colormap */
|
||||
rs = 256 / (r - 1);
|
||||
gs = 256 / (g - 1);
|
||||
bs = 256 / (b - 1);
|
||||
for (i = 0; i < 256; i++) {
|
||||
r1 = (rs * ((i / (g * b)) % r)) * 255;
|
||||
g1 = (gs * ((i / b) % g)) * 255;
|
||||
b1 = (bs * ((i) % b)) * 255;
|
||||
/* printf("%d %04x %04x %04x\n",i,r1>>4,g1>>4,b1>>4); */
|
||||
S1D_WRITE_PALETTE (fb_info.RegAddr, i, (r1 >> 4), (g1 >> 4),
|
||||
(b1 >> 4));
|
||||
}
|
||||
|
||||
/* copy bitmap */
|
||||
fb = (char *) (fb_info.VmemAddr);
|
||||
memcpy (fb, (uchar *) CONFIG_KUP4K_LOGO, 320 * 240);
|
||||
}
|
||||
#endif /* CONFIG_KUP4K_LOGO */
|
||||
#endif /* CONFIG_KUP4K_LOGO */
|
||||
|
||||
#ifdef CONFIG_IDE_LED
|
||||
void ide_led (uchar led, uchar status)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile immap_t *immap = (immap_t *) CFG_IMMR;
|
||||
|
||||
/* We have one led for both pcmcia slots */
|
||||
if (status) { /* led on */
|
||||
if (status) { /* led on */
|
||||
immap->im_ioport.iop_padat &= ~0x80;
|
||||
} else {
|
||||
immap->im_ioport.iop_padat |= 0x80;
|
||||
|
||||
+56
-58
@@ -50,66 +50,64 @@ typedef struct
|
||||
|
||||
static S1D_REGS aS1DRegs[] =
|
||||
{
|
||||
|
||||
|
||||
{0x04,0x10}, /* BUSCLK MEMCLK Config Register */
|
||||
{0x04,0x10}, /* BUSCLK MEMCLK Config Register */
|
||||
#if 0
|
||||
{0x05,0x32}, /* PCLK Config Register */
|
||||
{0x05,0x32}, /* PCLK Config Register */
|
||||
#endif
|
||||
{0x10,0xD0}, /* PANEL Type Register */
|
||||
{0x11,0x00}, /* MOD Rate Register */
|
||||
{0x10,0xD0}, /* PANEL Type Register */
|
||||
{0x11,0x00}, /* MOD Rate Register */
|
||||
#if 0
|
||||
{0x12,0x34}, /* Horizontal Total Register */
|
||||
{0x12,0x34}, /* Horizontal Total Register */
|
||||
#endif
|
||||
{0x14,0x27}, /* Horizontal Display Period Register */
|
||||
{0x16,0x00}, /* Horizontal Display Period Start Pos Register 0 */
|
||||
{0x17,0x00}, /* Horizontal Display Period Start Pos Register 1 */
|
||||
{0x18,0xF0}, /* Vertical Total Register 0 */
|
||||
{0x19,0x00}, /* Vertical Total Register 1 */
|
||||
{0x1C,0xEF}, /* Vertical Display Period Register 0 */
|
||||
{0x1D,0x00}, /* Vertical Display Period Register 1 */
|
||||
{0x1E,0x00}, /* Vertical Display Period Start Pos Register 0 */
|
||||
{0x1F,0x00}, /* Vertical Display Period Start Pos Register 1 */
|
||||
{0x20,0x87}, /* Horizontal Sync Pulse Width Register */
|
||||
{0x22,0x00}, /* Horizontal Sync Pulse Start Pos Register 0 */
|
||||
{0x23,0x00}, /* Horizontal Sync Pulse Start Pos Register 1 */
|
||||
{0x24,0x80}, /* Vertical Sync Pulse Width Register */
|
||||
{0x26,0x01}, /* Vertical Sync Pulse Start Pos Register 0 */
|
||||
{0x27,0x00}, /* Vertical Sync Pulse Start Pos Register 1 */
|
||||
{0x70,0x83}, /* Display Mode Register */
|
||||
{0x71,0x00}, /* Special Effects Register */
|
||||
{0x74,0x00}, /* Main Window Display Start Address Register 0 */
|
||||
{0x75,0x00}, /* Main Window Display Start Address Register 1 */
|
||||
{0x76,0x00}, /* Main Window Display Start Address Register 2 */
|
||||
{0x78,0x50}, /* Main Window Address Offset Register 0 */
|
||||
{0x79,0x00}, /* Main Window Address Offset Register 1 */
|
||||
{0x7C,0x00}, /* Sub Window Display Start Address Register 0 */
|
||||
{0x7D,0x00}, /* Sub Window Display Start Address Register 1 */
|
||||
{0x7E,0x00}, /* Sub Window Display Start Address Register 2 */
|
||||
{0x80,0x50}, /* Sub Window Address Offset Register 0 */
|
||||
{0x81,0x00}, /* Sub Window Address Offset Register 1 */
|
||||
{0x84,0x00}, /* Sub Window X Start Pos Register 0 */
|
||||
{0x85,0x00}, /* Sub Window X Start Pos Register 1 */
|
||||
{0x88,0x00}, /* Sub Window Y Start Pos Register 0 */
|
||||
{0x89,0x00}, /* Sub Window Y Start Pos Register 1 */
|
||||
{0x8C,0x4F}, /* Sub Window X End Pos Register 0 */
|
||||
{0x8D,0x00}, /* Sub Window X End Pos Register 1 */
|
||||
{0x90,0xEF}, /* Sub Window Y End Pos Register 0 */
|
||||
{0x91,0x00}, /* Sub Window Y End Pos Register 1 */
|
||||
{0xA0,0x00}, /* Power Save Config Register */
|
||||
{0xA1,0x00}, /* CPU Access Control Register */
|
||||
{0xA2,0x00}, /* Software Reset Register */
|
||||
{0xA3,0x00}, /* BIG Endian Support Register */
|
||||
{0xA4,0x00}, /* Scratch Pad Register 0 */
|
||||
{0xA5,0x00}, /* Scratch Pad Register 1 */
|
||||
{0xA8,0x01}, /* GPIO Config Register 0 */
|
||||
{0xA9,0x80}, /* GPIO Config Register 1 */
|
||||
{0xAC,0x01}, /* GPIO Status Control Register 0 */
|
||||
{0xAD,0x00}, /* GPIO Status Control Register 1 */
|
||||
{0xB0,0x00}, /* PWM CV Clock Control Register */
|
||||
{0xB1,0x00}, /* PWM CV Clock Config Register */
|
||||
{0xB2,0x00}, /* CV Clock Burst Length Register */
|
||||
{0xB3,0x00}, /* PWM Clock Duty Cycle Register */
|
||||
{0xAD,0x80}, /* reset seq */
|
||||
{0x70,0x03}, /* */
|
||||
{0x14,0x27}, /* Horizontal Display Period Register */
|
||||
{0x16,0x00}, /* Horizontal Display Period Start Pos Register 0 */
|
||||
{0x17,0x00}, /* Horizontal Display Period Start Pos Register 1 */
|
||||
{0x18,0xF0}, /* Vertical Total Register 0 */
|
||||
{0x19,0x00}, /* Vertical Total Register 1 */
|
||||
{0x1C,0xEF}, /* Vertical Display Period Register 0 */
|
||||
{0x1D,0x00}, /* Vertical Display Period Register 1 */
|
||||
{0x1E,0x00}, /* Vertical Display Period Start Pos Register 0 */
|
||||
{0x1F,0x00}, /* Vertical Display Period Start Pos Register 1 */
|
||||
{0x20,0x87}, /* Horizontal Sync Pulse Width Register */
|
||||
{0x22,0x00}, /* Horizontal Sync Pulse Start Pos Register 0 */
|
||||
{0x23,0x00}, /* Horizontal Sync Pulse Start Pos Register 1 */
|
||||
{0x24,0x80}, /* Vertical Sync Pulse Width Register */
|
||||
{0x26,0x01}, /* Vertical Sync Pulse Start Pos Register 0 */
|
||||
{0x27,0x00}, /* Vertical Sync Pulse Start Pos Register 1 */
|
||||
{0x70,0x83}, /* Display Mode Register */
|
||||
{0x71,0x00}, /* Special Effects Register */
|
||||
{0x74,0x00}, /* Main Window Display Start Address Register 0 */
|
||||
{0x75,0x00}, /* Main Window Display Start Address Register 1 */
|
||||
{0x76,0x00}, /* Main Window Display Start Address Register 2 */
|
||||
{0x78,0x50}, /* Main Window Address Offset Register 0 */
|
||||
{0x79,0x00}, /* Main Window Address Offset Register 1 */
|
||||
{0x7C,0x00}, /* Sub Window Display Start Address Register 0 */
|
||||
{0x7D,0x00}, /* Sub Window Display Start Address Register 1 */
|
||||
{0x7E,0x00}, /* Sub Window Display Start Address Register 2 */
|
||||
{0x80,0x50}, /* Sub Window Address Offset Register 0 */
|
||||
{0x81,0x00}, /* Sub Window Address Offset Register 1 */
|
||||
{0x84,0x00}, /* Sub Window X Start Pos Register 0 */
|
||||
{0x85,0x00}, /* Sub Window X Start Pos Register 1 */
|
||||
{0x88,0x00}, /* Sub Window Y Start Pos Register 0 */
|
||||
{0x89,0x00}, /* Sub Window Y Start Pos Register 1 */
|
||||
{0x8C,0x4F}, /* Sub Window X End Pos Register 0 */
|
||||
{0x8D,0x00}, /* Sub Window X End Pos Register 1 */
|
||||
{0x90,0xEF}, /* Sub Window Y End Pos Register 0 */
|
||||
{0x91,0x00}, /* Sub Window Y End Pos Register 1 */
|
||||
{0xA0,0x00}, /* Power Save Config Register */
|
||||
{0xA1,0x00}, /* CPU Access Control Register */
|
||||
{0xA2,0x00}, /* Software Reset Register */
|
||||
{0xA3,0x00}, /* BIG Endian Support Register */
|
||||
{0xA4,0x00}, /* Scratch Pad Register 0 */
|
||||
{0xA5,0x00}, /* Scratch Pad Register 1 */
|
||||
{0xA8,0x01}, /* GPIO Config Register 0 */
|
||||
{0xA9,0x80}, /* GPIO Config Register 1 */
|
||||
{0xAC,0x01}, /* GPIO Status Control Register 0 */
|
||||
{0xAD,0x00}, /* GPIO Status Control Register 1 */
|
||||
{0xB0,0x10}, /* PWM CV Clock Control Register */
|
||||
{0xB1,0x80}, /* PWM CV Clock Config Register */
|
||||
{0xB2,0x00}, /* CV Clock Burst Length Register */
|
||||
{0xB3,0xA0}, /* PWM Clock Duty Cycle Register */
|
||||
{0xAD,0x80}, /* reset seq */
|
||||
{0x70,0x03}, /* */
|
||||
};
|
||||
@@ -489,10 +489,13 @@ long int initdram(int board_type)
|
||||
* The appropriate BRx/ORx registers have already been set when we
|
||||
* get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
|
||||
*/
|
||||
#if 1
|
||||
|
||||
memctl->memc_mptpr = CFG_MPTPR;
|
||||
memctl->memc_psrt = psrt;
|
||||
|
||||
memctl->memc_br2 = CFG_BR2_PRELIM;
|
||||
memctl->memc_or2 = or;
|
||||
|
||||
memctl->memc_psdmr = psdmr | PSDMR_OP_PREA;
|
||||
*ramaddr = c;
|
||||
|
||||
@@ -530,41 +533,7 @@ long int initdram(int board_type)
|
||||
memctl->memc_psdmr = psdmr | PSDMR_OP_NORM | PSDMR_RFEN;
|
||||
*ramaddr = c;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
printf("memctl->memc_mptpr = 0x%08x\n", CFG_MPTPR);
|
||||
printf("memctl->memc_psrt = 0x%08x\n", psrt);
|
||||
|
||||
printf("memctl->memc_psdmr = 0x%08x\n", psdmr | PSDMR_OP_PREA);
|
||||
printf("ramaddr = 0x%08x\n", ramaddr);
|
||||
|
||||
printf("memctl->memc_psdmr = 0x%08x\n", psdmr | PSDMR_OP_CBRR);
|
||||
|
||||
printf("memctl->memc_psdmr = 0x%08x\n", psdmr | PSDMR_OP_MRW);
|
||||
|
||||
printf("memctl->memc_psdmr = 0x%08x\n", psdmr | PSDMR_OP_NORM | PSDMR_RFEN);
|
||||
|
||||
immap->im_siu_conf.sc_ppc_acr = 0x00000002;
|
||||
immap->im_siu_conf.sc_ppc_alrh = 0x01267893;
|
||||
immap->im_siu_conf.sc_tescr1 = 0x00004000;
|
||||
*/
|
||||
#if 0
|
||||
/* init sdram dimm */
|
||||
ramaddr = (uchar *)CFG_SDRAM_BASE;
|
||||
memctl->memc_psrt = 0x00000010;
|
||||
immap->im_memctl.memc_or2 = 0xFF000CA0;
|
||||
immap->im_memctl.memc_br2 = 0x00000041;
|
||||
memctl->memc_psdmr = 0x296EB452;
|
||||
*ramaddr = c;
|
||||
memctl->memc_psdmr = 0x096EB452;
|
||||
for (i = 0; i < 8; i++)
|
||||
*ramaddr = c;
|
||||
|
||||
memctl->memc_psdmr = 0x196EB452;
|
||||
*ramaddr = c;
|
||||
memctl->memc_psdmr = 0x416EB452;
|
||||
*ramaddr = c;
|
||||
#endif
|
||||
/* print info */
|
||||
printf("SDRAM configuration read from SPD\n");
|
||||
printf("\tSize per side = %dMB\n", sdram_size >> 20);
|
||||
@@ -576,6 +545,7 @@ long int initdram(int board_type)
|
||||
/*return (16 * 1024 * 1024);*/
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
struct pci_controller hose;
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ int mpl_prg(unsigned long src,unsigned long size)
|
||||
flash_info_t *info;
|
||||
int i,rc;
|
||||
#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
|
||||
char *copystr = (char *)src;
|
||||
unsigned long *magic = (unsigned long *)src;
|
||||
#endif
|
||||
|
||||
@@ -69,8 +70,25 @@ int mpl_prg(unsigned long src,unsigned long size)
|
||||
printf("Bad Magic number\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
start = 0 - size;
|
||||
/* some more checks before we delete the Flash... */
|
||||
/* Checking the ISO_STRING prevents to program a
|
||||
* wrong Firmware Image into the flash.
|
||||
*/
|
||||
i=4; /* skip Magic number */
|
||||
while(1) {
|
||||
if(strncmp(©str[i],"MEV-",4)==0)
|
||||
break;
|
||||
if(i++>=0x100) {
|
||||
printf("Firmware Image for unknown Target\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* we have the ISO STRING, check */
|
||||
if(strncmp(©str[i],CONFIG_ISO_STRING,sizeof(CONFIG_ISO_STRING)-1)!=0) {
|
||||
printf("Wrong Firmware Image: %s\n",©str[i]);
|
||||
return -1;
|
||||
}
|
||||
start = 0 - size;
|
||||
for(i=info->sector_count-1;i>0;i--)
|
||||
{
|
||||
info->protect[i] = 0; /* unprotect this sector */
|
||||
|
||||
@@ -108,17 +108,23 @@ static struct pci_pip405_config_entry piix4_isa_bridge_f0[] = {
|
||||
/* PIIX4 IDE Controller Function 1 */
|
||||
static struct pci_pip405_config_entry piix4_ide_cntrl_f1[] = {
|
||||
{PCI_COMMAND, 0x0001, 2}, /* enable IO access */
|
||||
#if !defined(CONFIG_MIP405T)
|
||||
{PCI_CFG_PIIX4_IDETIM, 0x80008000, 4}, /* enable Both IDE channels */
|
||||
#else
|
||||
{PCI_CFG_PIIX4_IDETIM, 0x80000000, 4}, /* enable IDE channel0 */
|
||||
#endif
|
||||
{ } /* end of device table */
|
||||
};
|
||||
|
||||
/* PIIX4 USB Controller Function 2 */
|
||||
static struct pci_pip405_config_entry piix4_usb_cntrl_f2[] = {
|
||||
#if !defined(CONFIG_MIP405T)
|
||||
{PCI_INTERRUPT_LINE, 31, 1}, /* Int vector = 31 */
|
||||
{PCI_BASE_ADDRESS_4, 0x0000E001, 4}, /* Set IO Address to 0xe000 to 0xe01F */
|
||||
{PCI_LATENCY_TIMER, 0x80, 1}, /* Latency Timer 0x80 */
|
||||
{0xC0, 0x2000, 2}, /* Legacy support */
|
||||
{PCI_COMMAND, 0x0005, 2}, /* enable IO access and Master */
|
||||
#endif
|
||||
{ } /* end of device table */
|
||||
};
|
||||
|
||||
|
||||
+48
-2
@@ -50,9 +50,13 @@
|
||||
#include "mip405.h"
|
||||
|
||||
|
||||
.globl ext_bus_cntlr_init
|
||||
.globl ext_bus_cntlr_init
|
||||
ext_bus_cntlr_init:
|
||||
mflr r4 /* save link register */
|
||||
mflr r4 /* save link register */
|
||||
mfdcr r3,strap /* get strapping reg */
|
||||
andi. r0, r3, PSR_ROM_LOC /* mask out irrelevant bits */
|
||||
bnelr /* jump back if PCI boot */
|
||||
|
||||
bl ..getAddr
|
||||
..getAddr:
|
||||
mflr r3 /* get address of ..getAddr */
|
||||
@@ -200,3 +204,45 @@ sdram_init:
|
||||
|
||||
blr
|
||||
|
||||
|
||||
#if defined(CONFIG_BOOT_PCI)
|
||||
.section .bootpg,"ax"
|
||||
.globl _start_pci
|
||||
/*******************************************
|
||||
*/
|
||||
|
||||
_start_pci:
|
||||
/* first handle errata #68 / PCI_18 */
|
||||
iccci r0, r0 /* invalidate I-cache */
|
||||
lis r31, 0
|
||||
mticcr r31 /* ICCR = 0 (all uncachable) */
|
||||
isync
|
||||
|
||||
mfccr0 r28 /* set CCR0[24] = 1 */
|
||||
ori r28, r28, 0x0080
|
||||
mtccr0 r28
|
||||
|
||||
/* setup PMM0MA (0xEF400004) and PMM0PCIHA (0xEF40000C) */
|
||||
lis r28, 0xEF40
|
||||
addi r28, r28, 0x0004
|
||||
stw r31, 0x0C(r28) /* clear PMM0PCIHA */
|
||||
lis r29, 0xFFF8 /* open 512 kByte */
|
||||
addi r29, r29, 0x0001/* and enable this region */
|
||||
stwbrx r29, r0, r28 /* write PMM0MA */
|
||||
|
||||
lis r28, 0xEEC0 /* address of PCIC0_CFGADDR */
|
||||
addi r29, r28, 4 /* add 4 to r29 -> PCIC0_CFGDATA */
|
||||
|
||||
lis r31, 0x8000 /* set en bit bus 0 */
|
||||
ori r31, r31, 0x304C/* device 6 func 0 reg 4C (XBCS register) */
|
||||
stwbrx r31, r0, r28 /* write it */
|
||||
|
||||
lwbrx r31, r0, r29 /* load XBCS register */
|
||||
oris r31, r31, 0x02C4/* clear BIOSCS WPE, set lower, extended and 1M extended BIOS enable */
|
||||
stwbrx r31, r0, r29 /* write back XBCS register */
|
||||
|
||||
nop
|
||||
nop
|
||||
b _start /* normal start */
|
||||
#endif
|
||||
|
||||
+132
-75
@@ -73,7 +73,7 @@ extern block_dev_desc_t * scsi_get_dev(int dev);
|
||||
extern block_dev_desc_t * ide_get_dev(int dev);
|
||||
|
||||
#undef SDRAM_DEBUG
|
||||
|
||||
#define ENABLE_ECC /* for ecc boards */
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
|
||||
@@ -108,7 +108,27 @@ typedef struct {
|
||||
unsigned char sz; /* log binary => Size = (4MByte<<sz) 5 = 128, 4 = 64, 3 = 32, 2 = 16, 1=8 */
|
||||
unsigned char ecc; /* if true, ecc is enabled */
|
||||
} sdram_t;
|
||||
|
||||
#if defined(CONFIG_MIP405T)
|
||||
const sdram_t sdram_table[] = {
|
||||
{ 0x01, /* MIP405T Rev A, 64MByte -1 Board */
|
||||
3, /* Case Latenty = 3 */
|
||||
3, /* trp 20ns / 7.5 ns datain[27] */
|
||||
3, /* trcd 20ns /7.5 ns (datain[29]) */
|
||||
6, /* tras 44ns /7.5 ns (datain[30]) */
|
||||
4, /* tcpt 44 - 20ns = 24ns */
|
||||
3, /* Address Mode = 3 (13x9x4) */
|
||||
4, /* size value (64MByte) */
|
||||
0}, /* ECC disabled */
|
||||
{ 0xff, /* terminator */
|
||||
0xff,
|
||||
0xff,
|
||||
0xff,
|
||||
0xff,
|
||||
0xff,
|
||||
0xff,
|
||||
0xff }
|
||||
};
|
||||
#else
|
||||
const sdram_t sdram_table[] = {
|
||||
{ 0x0f, /* Rev A, 128MByte -1 Board */
|
||||
3, /* Case Latenty = 3 */
|
||||
@@ -155,7 +175,7 @@ const sdram_t sdram_table[] = {
|
||||
0xff,
|
||||
0xff }
|
||||
};
|
||||
|
||||
#endif /*CONFIG_MIP405T */
|
||||
void SDRAM_err (const char *s)
|
||||
{
|
||||
#ifndef SDRAM_DEBUG
|
||||
@@ -222,17 +242,54 @@ int init_sdram (void)
|
||||
tctp_clocks;
|
||||
unsigned char cal_val;
|
||||
unsigned char bc;
|
||||
unsigned long pbcr, sdram_tim, sdram_bank;
|
||||
unsigned long *p;
|
||||
unsigned long sdram_tim, sdram_bank;
|
||||
|
||||
i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
|
||||
/*i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);*/
|
||||
(void) get_clocks ();
|
||||
gd->baudrate = 9600;
|
||||
serial_init ();
|
||||
/* set up the pld */
|
||||
mtdcr (ebccfga, pb7ap);
|
||||
mtdcr (ebccfgd, PLD_AP);
|
||||
mtdcr (ebccfga, pb7cr);
|
||||
mtdcr (ebccfgd, PLD_CR);
|
||||
/* THIS IS OBSOLETE */
|
||||
/* set up the board rev reg*/
|
||||
mtdcr (ebccfga, pb5ap);
|
||||
mtdcr (ebccfgd, BOARD_AP);
|
||||
mtdcr (ebccfga, pb5cr);
|
||||
mtdcr (ebccfgd, BOARD_CR);
|
||||
#ifdef SDRAM_DEBUG
|
||||
/* get all informations from PLD */
|
||||
serial_puts ("\nPLD Part 0x");
|
||||
bc = in8 (PLD_PART_REG);
|
||||
write_hex (bc);
|
||||
serial_puts ("\nPLD Vers 0x");
|
||||
bc = in8 (PLD_VERS_REG);
|
||||
write_hex (bc);
|
||||
serial_puts ("\nBoard Rev 0x");
|
||||
bc = in8 (PLD_BOARD_CFG_REG);
|
||||
write_hex (bc);
|
||||
serial_puts ("\n");
|
||||
#endif
|
||||
/* check board */
|
||||
bc = in8 (PLD_PART_REG);
|
||||
#if defined(CONFIG_MIP405T)
|
||||
if((bc & 0x80)==0)
|
||||
SDRAM_err ("U-Boot configured for a MIP405T not for a MIP405!!!\n");
|
||||
#else
|
||||
if((bc & 0x80)==0x80)
|
||||
SDRAM_err ("U-Boot configured for a MIP405 not for a MIP405T!!!\n");
|
||||
#endif
|
||||
#if !defined(CONFIG_MIP405T)
|
||||
/* since the ECC initialisation needs some time,
|
||||
* we show that we're alive
|
||||
*/
|
||||
serial_puts ("\nInitializing SDRAM, Please stand by");
|
||||
/* set-up the chipselect machine */
|
||||
mtdcr (ebccfga, pb0cr); /* get cs0 config reg */
|
||||
pbcr = mfdcr (ebccfgd);
|
||||
if ((pbcr & 0x00002000) == 0) {
|
||||
tmp = mfdcr (ebccfgd);
|
||||
if ((tmp & 0x00002000) == 0) {
|
||||
/* MPS Boot, set up the flash */
|
||||
mtdcr (ebccfga, pb1ap);
|
||||
mtdcr (ebccfgd, FLASH_AP);
|
||||
@@ -254,30 +311,8 @@ int init_sdram (void)
|
||||
mtdcr (ebccfgd, UART1_AP);
|
||||
mtdcr (ebccfga, pb3cr);
|
||||
mtdcr (ebccfgd, UART1_CR);
|
||||
|
||||
/* set up the pld */
|
||||
mtdcr (ebccfga, pb7ap);
|
||||
mtdcr (ebccfgd, PLD_AP);
|
||||
mtdcr (ebccfga, pb7cr);
|
||||
mtdcr (ebccfgd, PLD_CR);
|
||||
/* set up the board rev reg */
|
||||
mtdcr (ebccfga, pb5ap);
|
||||
mtdcr (ebccfgd, BOARD_AP);
|
||||
mtdcr (ebccfga, pb5cr);
|
||||
mtdcr (ebccfgd, BOARD_CR);
|
||||
|
||||
|
||||
#ifdef SDRAM_DEBUG
|
||||
out8 (PER_BOARD_ADDR, 0);
|
||||
bc = in8 (PER_BOARD_ADDR);
|
||||
serial_puts ("\nBoard Rev: ");
|
||||
write_hex (bc);
|
||||
serial_puts (" (PLD=");
|
||||
bc = in8 (PLD_BOARD_CFG_REG);
|
||||
write_hex (bc);
|
||||
serial_puts (")\n");
|
||||
#endif
|
||||
bc = get_board_revcfg ();
|
||||
bc = in8 (PLD_BOARD_CFG_REG);
|
||||
#ifdef SDRAM_DEBUG
|
||||
serial_puts ("\nstart SDRAM Setup\n");
|
||||
serial_puts ("\nBoard Rev: ");
|
||||
@@ -367,9 +402,10 @@ int init_sdram (void)
|
||||
mtdcr (memcfga, mem_rtr);
|
||||
mtdcr (memcfgd, tmp);
|
||||
/* enable ECC if used */
|
||||
#if 1
|
||||
#if defined(ENABLE_ECC) && !defined(CONFIG_BOOT_PCI)
|
||||
if (sdram_table[i].ecc) {
|
||||
/* disable checking for all banks */
|
||||
unsigned long *p;
|
||||
#ifdef SDRAM_DEBUG
|
||||
serial_puts ("disable ECC.. ");
|
||||
#endif
|
||||
@@ -398,8 +434,6 @@ int init_sdram (void)
|
||||
*p++ = 0L;
|
||||
if (!((unsigned long) p % 0x00800000)) /* every 8MByte */
|
||||
serial_puts (".");
|
||||
|
||||
|
||||
}
|
||||
/* enable bank 0 */
|
||||
serial_puts (".");
|
||||
@@ -501,47 +535,69 @@ void ide_set_reset (int idereset)
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Check Board Identity:
|
||||
*/
|
||||
|
||||
int checkboard (void)
|
||||
void get_pcbrev_var(unsigned char *pcbrev, unsigned char *var)
|
||||
{
|
||||
unsigned char s[50];
|
||||
unsigned char bc, var, rc;
|
||||
#if !defined(CONFIG_MIP405T)
|
||||
unsigned char bc,rc,tmp;
|
||||
int i;
|
||||
backup_t *b = (backup_t *) s;
|
||||
|
||||
puts ("Board: ");
|
||||
|
||||
bc = get_board_revcfg ();
|
||||
var = ~bc;
|
||||
var &= 0xf;
|
||||
bc = in8 (PLD_BOARD_CFG_REG);
|
||||
tmp = ~bc;
|
||||
tmp &= 0xf;
|
||||
rc = 0;
|
||||
for (i = 0; i < 4; i++) {
|
||||
rc <<= 1;
|
||||
rc += (var & 0x1);
|
||||
var >>= 1;
|
||||
rc += (tmp & 0x1);
|
||||
tmp >>= 1;
|
||||
}
|
||||
rc++;
|
||||
if((((bc>>4) & 0xf)==0x1) /* Rev B PCB with */
|
||||
&& (rc==0x1)) /* Population Option 1 is a -3 */
|
||||
rc=3;
|
||||
*pcbrev=(bc >> 4) & 0xf;
|
||||
*var=rc;
|
||||
#else
|
||||
unsigned char bc;
|
||||
bc = in8 (PLD_BOARD_CFG_REG);
|
||||
*pcbrev=(bc >> 4) & 0xf;
|
||||
*var=bc & 0xf ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Check Board Identity:
|
||||
*/
|
||||
/* serial String: "MIP405_1000" OR "MIP405T_1000" */
|
||||
#if !defined(CONFIG_MIP405T)
|
||||
#define BOARD_NAME "MIP405"
|
||||
#else
|
||||
#define BOARD_NAME "MIP405T"
|
||||
#endif
|
||||
|
||||
int checkboard (void)
|
||||
{
|
||||
unsigned char s[50];
|
||||
unsigned char bc, var;
|
||||
int i;
|
||||
backup_t *b = (backup_t *) s;
|
||||
|
||||
puts ("Board: ");
|
||||
get_pcbrev_var(&bc,&var);
|
||||
i = getenv_r ("serial#", s, 32);
|
||||
if ((i == 0) || strncmp (s, "MIP405", 6)) {
|
||||
if ((i == 0) || strncmp (s, BOARD_NAME,sizeof(BOARD_NAME))) {
|
||||
get_backup_values (b);
|
||||
if (strncmp (b->signature, "MPL\0", 4) != 0) {
|
||||
puts ("### No HW ID - assuming MIP405");
|
||||
printf ("-%d Rev %c", rc, 'A' + ((bc >> 4) & 0xf));
|
||||
puts ("### No HW ID - assuming " BOARD_NAME);
|
||||
printf ("-%d Rev %c", var, 'A' + bc);
|
||||
} else {
|
||||
b->serial_name[6] = 0;
|
||||
printf ("%s-%d Rev %c SN: %s", b->serial_name, rc,
|
||||
'A' + ((bc >> 4) & 0xf), &b->serial_name[7]);
|
||||
b->serial_name[sizeof(BOARD_NAME)-1] = 0;
|
||||
printf ("%s-%d Rev %c SN: %s", b->serial_name, var,
|
||||
'A' + bc, &b->serial_name[sizeof(BOARD_NAME)]);
|
||||
}
|
||||
} else {
|
||||
s[6] = 0;
|
||||
printf ("%s-%d Rev %c SN: %s", s, rc, 'A' + ((bc >> 4) & 0xf),
|
||||
&s[7]);
|
||||
s[sizeof(BOARD_NAME)-1] = 0;
|
||||
printf ("%s-%d Rev %c SN: %s", s, var,'A' + bc,
|
||||
&s[sizeof(BOARD_NAME)]);
|
||||
}
|
||||
bc = in8 (PLD_EXT_CONF_REG);
|
||||
printf (" Boot Config: 0x%x\n", bc);
|
||||
@@ -613,30 +669,23 @@ static int test_dram (unsigned long ramsize)
|
||||
|
||||
int misc_init_r (void)
|
||||
{
|
||||
/* if MIP405 has booted from PCI, reset CCR0[24] as described in errata PCI_18 */
|
||||
if (mfdcr(strap) & PSR_ROM_LOC)
|
||||
mtspr(ccr0, (mfspr(ccr0) & ~0x80));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
void print_mip405_rev (void)
|
||||
{
|
||||
unsigned char part, vers, cfg, rev;
|
||||
unsigned char part, vers, pcbrev, var;
|
||||
|
||||
cfg = get_board_revcfg ();
|
||||
vers = cfg;
|
||||
vers &= 0xf;
|
||||
rev = (((vers & 0x1) ? 0x8 : 0) |
|
||||
((vers & 0x2) ? 0x4 : 0) |
|
||||
((vers & 0x4) ? 0x2 : 0) |
|
||||
((vers & 0x8) ? 0x1 : 0));
|
||||
|
||||
vers=16-rev;
|
||||
rev=vers;
|
||||
if((rev==1) && ((cfg >> 4)==1)) /* Rev B PCB and -1 is a -3 */
|
||||
rev=3;
|
||||
get_pcbrev_var(&pcbrev,&var);
|
||||
part = in8 (PLD_PART_REG);
|
||||
vers = in8 (PLD_VERS_REG);
|
||||
printf ("Rev: MIP405-%d Rev %c PLD%d Vers %d\n",
|
||||
rev, ((cfg >> 4) & 0xf) + 'A', part, vers);
|
||||
printf ("Rev: " BOARD_NAME "-%d Rev %c PLD %d Vers %d\n",
|
||||
var, pcbrev + 'A', part & 0x7F, vers);
|
||||
}
|
||||
|
||||
extern void mem_test_reloc(void);
|
||||
@@ -683,24 +732,32 @@ void print_mip405_info (void)
|
||||
com_mode = in8 (PLD_COM_MODE_REG);
|
||||
ext = in8 (PLD_EXT_CONF_REG);
|
||||
|
||||
printf ("PLD Part %d version %d\n", part, vers);
|
||||
printf ("PLD Part %d version %d\n", part & 0x7F, vers);
|
||||
printf ("Board Revision %c\n", ((cfg >> 4) & 0xf) + 'A');
|
||||
printf ("Population Options %d %d %d %d\n", (cfg) & 0x1,
|
||||
(cfg >> 1) & 0x1, (cfg >> 2) & 0x1, (cfg >> 3) & 0x1);
|
||||
printf ("User LED %s\n", (com_mode & 0x4) ? "on" : "off");
|
||||
printf ("UART Clocks %d\n", (com_mode >> 4) & 0x3);
|
||||
printf ("Test ist %x\n", com_mode);
|
||||
#if !defined(CONFIG_MIP405T)
|
||||
printf ("User Config Switch %d %d %d %d %d %d %d %d\n",
|
||||
(ext) & 0x1, (ext >> 1) & 0x1, (ext >> 2) & 0x1,
|
||||
(ext >> 3) & 0x1, (ext >> 4) & 0x1, (ext >> 5) & 0x1,
|
||||
(ext >> 6) & 0x1, (ext >> 7) & 0x1);
|
||||
printf ("SER1 uses handshakes %s\n",
|
||||
(ext & 0x80) ? "DTR/DSR" : "RTS/CTS");
|
||||
#else
|
||||
printf ("User Config Switch %d %d %d %d %d %d %d %d %d\n",
|
||||
(ext) & 0x1, (ext >> 1) & 0x1, (ext >> 2) & 0x1,
|
||||
(ext >> 3) & 0x1, (ext >> 4) & 0x1, (ext >> 5) & 0x1,
|
||||
(ext >> 6) & 0x1,(ext >> 7) & 0x1,(ext >> 8) & 0x1);
|
||||
#endif
|
||||
printf ("IDE Reset %s\n", (ext & 0x01) ? "asserted" : "not asserted");
|
||||
printf ("IRQs:\n");
|
||||
printf (" PIIX INTR: %s\n", (irq_reg & 0x80) ? "inactive" : "active");
|
||||
#if !defined(CONFIG_MIP405T)
|
||||
printf (" UART0 IRQ: %s\n", (irq_reg & 0x40) ? "inactive" : "active");
|
||||
printf (" UART1 IRQ: %s\n", (irq_reg & 0x20) ? "inactive" : "active");
|
||||
#endif
|
||||
printf (" PIIX SMI: %s\n", (irq_reg & 0x10) ? "inactive" : "active");
|
||||
printf (" PIIX INIT: %s\n", (irq_reg & 0x8) ? "inactive" : "active");
|
||||
printf (" PIIX NMI: %s\n", (irq_reg & 0x4) ? "inactive" : "active");
|
||||
|
||||
@@ -31,6 +31,10 @@ SECTIONS
|
||||
{
|
||||
*(.resetvec)
|
||||
} = 0xffff
|
||||
.bootpg 0xFFFFF000 :
|
||||
{
|
||||
board/mpl/mip405/init.o (.bootpg)
|
||||
} = 0xffff
|
||||
|
||||
/* Read-only sections, merged into text segment: */
|
||||
. = + SIZEOF_HEADERS;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# (C) Copyright 2000
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
#
|
||||
# See file CREDITS for list of people who contributed to this
|
||||
# project.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
# MA 02111-1307 USA
|
||||
#
|
||||
|
||||
include $(TOPDIR)/config.mk
|
||||
|
||||
LIB = lib$(BOARD).a
|
||||
|
||||
OBJS = $(BOARD).o flash.o kbd.o
|
||||
|
||||
$(LIB): .depend $(OBJS)
|
||||
$(AR) crv $@ $^
|
||||
|
||||
#########################################################################
|
||||
|
||||
.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
|
||||
$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
|
||||
|
||||
sinclude .depend
|
||||
|
||||
#########################################################################
|
||||
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# (C) Copyright 2000
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
#
|
||||
# See file CREDITS for list of people who contributed to this
|
||||
# project.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
# MA 02111-1307 USA
|
||||
#
|
||||
|
||||
#
|
||||
# RBC823 boards
|
||||
#
|
||||
|
||||
TEXT_BASE = 0xFFF00000
|
||||
@@ -0,0 +1,470 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc8xx.h>
|
||||
|
||||
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* 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);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
unsigned long flash_init (void)
|
||||
{
|
||||
unsigned long size_b0, size_b1;
|
||||
int i;
|
||||
|
||||
/* Init: no FLASHes known */
|
||||
for (i=0; i < CFG_MAX_FLASH_BANKS; ++i)
|
||||
flash_info[i].flash_id = FLASH_UNKNOWN;
|
||||
|
||||
/* Detect size */
|
||||
size_b0 = flash_get_size((vu_long *)CFG_FLASH_BASE, &flash_info[0]);
|
||||
|
||||
/* Setup offsets */
|
||||
flash_get_offsets (CFG_FLASH_BASE, &flash_info[0]);
|
||||
|
||||
#if CFG_MONITOR_BASE >= CFG_FLASH_BASE
|
||||
/* Monitor protection ON by default */
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
CFG_MONITOR_BASE,
|
||||
CFG_MONITOR_BASE+monitor_flash_len-1,
|
||||
&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);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Fix this to support variable sector sizes
|
||||
*/
|
||||
static void flash_get_offsets (ulong base, flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* set up sector start address table */
|
||||
if ((info->flash_id & FLASH_TYPEMASK) == FLASH_AM040) {
|
||||
/* set sector offsets for bottom boot block type */
|
||||
for (i = 0; i < info->sector_count; i++)
|
||||
info->start[i] = base + (i * 0x00010000);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
void flash_print_info (flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
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_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);
|
||||
} else {
|
||||
printf (" Size: %ld KB in %d Sectors\n",
|
||||
info->size >> 10,
|
||||
info->sector_count);
|
||||
}
|
||||
|
||||
puts (" Sector Start Addresses:");
|
||||
|
||||
for (i=0; i<info->sector_count; ++i)
|
||||
{
|
||||
if ((i % 5) == 0)
|
||||
{
|
||||
puts ("\n ");
|
||||
}
|
||||
|
||||
printf (" %08lX%s",
|
||||
info->start[i],
|
||||
info->protect[i] ? " (RO)" : " ");
|
||||
}
|
||||
|
||||
putc ('\n');
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following code cannot be run from FLASH!
|
||||
*/
|
||||
|
||||
static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
{
|
||||
short i;
|
||||
volatile unsigned char *caddr;
|
||||
char value;
|
||||
|
||||
caddr = (volatile unsigned char *)addr ;
|
||||
|
||||
/* Write auto select command: read Manufacturer ID */
|
||||
|
||||
#if 0
|
||||
printf("Base address is: %08x\n", caddr);
|
||||
#endif
|
||||
|
||||
caddr[0x0555] = 0xAA;
|
||||
caddr[0x02AA] = 0x55;
|
||||
caddr[0x0555] = 0x90;
|
||||
|
||||
value = caddr[0];
|
||||
|
||||
#if 0
|
||||
printf("Manufact ID: %02x\n", value);
|
||||
#endif
|
||||
switch (value)
|
||||
{
|
||||
case 0x01:
|
||||
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;
|
||||
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 */
|
||||
|
||||
}
|
||||
|
||||
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 */
|
||||
caddr = (volatile unsigned char *)(info->start[i]);
|
||||
info->protect[i] = caddr[2] & 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent writes to uninitialized FLASH.
|
||||
*/
|
||||
if (info->flash_id != FLASH_UNKNOWN)
|
||||
{
|
||||
caddr = (volatile unsigned char *)info->start[0];
|
||||
*caddr = 0xF0; /* reset bank */
|
||||
}
|
||||
|
||||
return (info->size);
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int flash_erase (flash_info_t *info, int s_first, int s_last)
|
||||
{
|
||||
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");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((info->flash_id == FLASH_UNKNOWN) ||
|
||||
(info->flash_id > FLASH_AMD_COMP)) {
|
||||
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]) {
|
||||
prot++;
|
||||
}
|
||||
}
|
||||
|
||||
if (prot) {
|
||||
printf ("- Warning: %d protected sectors will not be erased!\n",
|
||||
prot);
|
||||
} else {
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
l_sect = -1;
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
addr[0x0555] = 0xAA;
|
||||
addr[0x02AA] = 0x55;
|
||||
addr[0x0555] = 0x80;
|
||||
addr[0x0555] = 0xAA;
|
||||
addr[0x02AA] = 0x55;
|
||||
|
||||
/* Start erase on unprotected sectors */
|
||||
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;
|
||||
l_sect = sect;
|
||||
}
|
||||
}
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag)
|
||||
enable_interrupts();
|
||||
|
||||
/* wait at least 80us - let's wait 1 ms */
|
||||
udelay (1000);
|
||||
|
||||
/*
|
||||
* We wait for the last triggered sector
|
||||
*/
|
||||
if (l_sect < 0)
|
||||
goto DONE;
|
||||
|
||||
start = get_timer (0);
|
||||
last = start;
|
||||
addr = (volatile unsigned char *)(info->start[l_sect]);
|
||||
|
||||
while ((addr[0] & 0xFF) != 0xFF)
|
||||
{
|
||||
if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
|
||||
printf ("Timeout\n");
|
||||
return 1;
|
||||
}
|
||||
/* show that we're waiting */
|
||||
if ((now - last) > 1000) { /* every second */
|
||||
putc ('.');
|
||||
last = now;
|
||||
}
|
||||
}
|
||||
|
||||
DONE:
|
||||
/* reset to read mode */
|
||||
addr = (volatile unsigned char *)info->start[0];
|
||||
|
||||
addr[0] = 0xF0; /* reset bank */
|
||||
|
||||
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)
|
||||
{
|
||||
ulong cp, wp, data;
|
||||
int i, l, rc;
|
||||
|
||||
wp = (addr & ~3); /* get lower word aligned address */
|
||||
|
||||
/*
|
||||
* handle unaligned start bytes
|
||||
*/
|
||||
if ((l = addr - wp) != 0) {
|
||||
data = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
}
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle word aligned part
|
||||
*/
|
||||
while (cnt >= 4) {
|
||||
data = 0;
|
||||
for (i=0; i<4; ++i) {
|
||||
data = (data << 8) | *src++;
|
||||
}
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
}
|
||||
wp += 4;
|
||||
cnt -= 4;
|
||||
}
|
||||
|
||||
if (cnt == 0) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* handle unaligned tail bytes
|
||||
*/
|
||||
data = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
volatile unsigned char *addr = (volatile unsigned char*)(info->start[0]),
|
||||
*cdest,*cdata;
|
||||
ulong start;
|
||||
int flag, count = 4 ;
|
||||
|
||||
cdest = (volatile unsigned char *)dest ;
|
||||
cdata = (volatile unsigned char *)&data ;
|
||||
|
||||
/* Check if Flash is (sufficiently) erased */
|
||||
if ((*((vu_long *)dest) & data) != data) {
|
||||
return (2);
|
||||
}
|
||||
|
||||
while(count--)
|
||||
{
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
addr[0x0555] = 0xAA;
|
||||
addr[0x02AA] = 0x55;
|
||||
addr[0x0555] = 0xA0;
|
||||
|
||||
*cdest = *cdata;
|
||||
|
||||
/* 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) > CFG_FLASH_WRITE_TOUT) {
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
cdata++ ;
|
||||
cdest++ ;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Modified by Udi Finkelstein
|
||||
*
|
||||
* This file includes communication routines for SMC1 that can run even if
|
||||
* SMC2 have already been initialized.
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <watchdog.h>
|
||||
#include <commproc.h>
|
||||
#include <devices.h>
|
||||
#include <lcd.h>
|
||||
|
||||
#define SMC_INDEX 0
|
||||
#define PROFF_SMC PROFF_SMC1
|
||||
#define CPM_CR_CH_SMC CPM_CR_CH_SMC1
|
||||
|
||||
#define RBC823_KBD_BAUDRATE 38400
|
||||
#define CPM_KEYBOARD_BASE 0x1000
|
||||
/*
|
||||
* Minimal serial functions needed to use one of the SMC ports
|
||||
* as serial console interface.
|
||||
*/
|
||||
|
||||
void smc1_setbrg (void)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
volatile immap_t *im = (immap_t *)CFG_IMMR;
|
||||
volatile cpm8xx_t *cp = &(im->im_cpm);
|
||||
|
||||
/* Set up the baud rate generator.
|
||||
* See 8xx_io/commproc.c for details.
|
||||
*
|
||||
* Wire BRG2 to SMC1, BRG1 to SMC2
|
||||
*/
|
||||
|
||||
cp->cp_simode = 0x00001000;
|
||||
|
||||
cp->cp_brgc2 =
|
||||
(((gd->cpu_clk / 16 / RBC823_KBD_BAUDRATE)-1) << 1) | CPM_BRG_EN;
|
||||
}
|
||||
|
||||
int smc1_init (void)
|
||||
{
|
||||
volatile immap_t *im = (immap_t *)CFG_IMMR;
|
||||
volatile smc_t *sp;
|
||||
volatile smc_uart_t *up;
|
||||
volatile cbd_t *tbdf, *rbdf;
|
||||
volatile cpm8xx_t *cp = &(im->im_cpm);
|
||||
uint dpaddr;
|
||||
|
||||
/* initialize pointers to SMC */
|
||||
|
||||
sp = (smc_t *) &(cp->cp_smc[SMC_INDEX]);
|
||||
up = (smc_uart_t *) &cp->cp_dparam[PROFF_SMC];
|
||||
|
||||
/* Disable transmitter/receiver.
|
||||
*/
|
||||
sp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
|
||||
|
||||
/* Enable SDMA.
|
||||
*/
|
||||
im->im_siu_conf.sc_sdcr = 1;
|
||||
|
||||
/* clear error conditions */
|
||||
#ifdef CFG_SDSR
|
||||
im->im_sdma.sdma_sdsr = CFG_SDSR;
|
||||
#else
|
||||
im->im_sdma.sdma_sdsr = 0x83;
|
||||
#endif
|
||||
|
||||
/* clear SDMA interrupt mask */
|
||||
#ifdef CFG_SDMR
|
||||
im->im_sdma.sdma_sdmr = CFG_SDMR;
|
||||
#else
|
||||
im->im_sdma.sdma_sdmr = 0x00;
|
||||
#endif
|
||||
|
||||
/* Use Port B for SMC1 instead of other functions.
|
||||
*/
|
||||
cp->cp_pbpar |= 0x000000c0;
|
||||
cp->cp_pbdir &= ~0x000000c0;
|
||||
cp->cp_pbodr &= ~0x000000c0;
|
||||
|
||||
/* Set the physical address of the host memory buffers in
|
||||
* the buffer descriptors.
|
||||
*/
|
||||
|
||||
#ifdef CFG_ALLOC_DPRAM
|
||||
dpaddr = dpram_alloc_align (sizeof(cbd_t)*2 + 2, 8) ;
|
||||
#else
|
||||
dpaddr = CPM_KEYBOARD_BASE ;
|
||||
#endif
|
||||
|
||||
/* Allocate space for two buffer descriptors in the DP ram.
|
||||
* For now, this address seems OK, but it may have to
|
||||
* change with newer versions of the firmware.
|
||||
* damm: allocating space after the two buffers for rx/tx data
|
||||
*/
|
||||
|
||||
rbdf = (cbd_t *)&cp->cp_dpmem[dpaddr];
|
||||
rbdf->cbd_bufaddr = (uint) (rbdf+2);
|
||||
rbdf->cbd_sc = 0;
|
||||
tbdf = rbdf + 1;
|
||||
tbdf->cbd_bufaddr = ((uint) (rbdf+2)) + 1;
|
||||
tbdf->cbd_sc = 0;
|
||||
|
||||
/* Set up the uart parameters in the parameter ram.
|
||||
*/
|
||||
up->smc_rbase = dpaddr;
|
||||
up->smc_tbase = dpaddr+sizeof(cbd_t);
|
||||
up->smc_rfcr = SMC_EB;
|
||||
up->smc_tfcr = SMC_EB;
|
||||
|
||||
/* Set UART mode, 8 bit, no parity, one stop.
|
||||
* Enable receive and transmit.
|
||||
*/
|
||||
sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
|
||||
|
||||
/* Mask all interrupts and remove anything pending.
|
||||
*/
|
||||
sp->smc_smcm = 0;
|
||||
sp->smc_smce = 0xff;
|
||||
|
||||
/* Set up the baud rate generator.
|
||||
*/
|
||||
smc1_setbrg ();
|
||||
|
||||
/* Make the first buffer the only buffer.
|
||||
*/
|
||||
tbdf->cbd_sc |= BD_SC_WRAP;
|
||||
rbdf->cbd_sc |= BD_SC_EMPTY | BD_SC_WRAP;
|
||||
|
||||
/* Single character receive.
|
||||
*/
|
||||
up->smc_mrblr = 1;
|
||||
up->smc_maxidl = 0;
|
||||
|
||||
/* Initialize Tx/Rx parameters.
|
||||
*/
|
||||
|
||||
while (cp->cp_cpcr & CPM_CR_FLG) /* wait if cp is busy */
|
||||
;
|
||||
|
||||
cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SMC, CPM_CR_INIT_TRX) | CPM_CR_FLG;
|
||||
|
||||
while (cp->cp_cpcr & CPM_CR_FLG) /* wait if cp is busy */
|
||||
;
|
||||
|
||||
/* Enable transmitter/receiver.
|
||||
*/
|
||||
sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void smc1_putc(const char c)
|
||||
{
|
||||
volatile cbd_t *tbdf;
|
||||
volatile char *buf;
|
||||
volatile smc_uart_t *up;
|
||||
volatile immap_t *im = (immap_t *)CFG_IMMR;
|
||||
volatile cpm8xx_t *cpmp = &(im->im_cpm);
|
||||
|
||||
up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC];
|
||||
|
||||
tbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_tbase];
|
||||
|
||||
/* Wait for last character to go.
|
||||
*/
|
||||
|
||||
buf = (char *)tbdf->cbd_bufaddr;
|
||||
|
||||
*buf = c;
|
||||
tbdf->cbd_datlen = 1;
|
||||
tbdf->cbd_sc |= BD_SC_READY;
|
||||
__asm__("eieio");
|
||||
|
||||
while (tbdf->cbd_sc & BD_SC_READY) {
|
||||
WATCHDOG_RESET ();
|
||||
__asm__("eieio");
|
||||
}
|
||||
}
|
||||
|
||||
int smc1_getc(void)
|
||||
{
|
||||
volatile cbd_t *rbdf;
|
||||
volatile unsigned char *buf;
|
||||
volatile smc_uart_t *up;
|
||||
volatile immap_t *im = (immap_t *)CFG_IMMR;
|
||||
volatile cpm8xx_t *cpmp = &(im->im_cpm);
|
||||
unsigned char c;
|
||||
|
||||
up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC];
|
||||
|
||||
rbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];
|
||||
|
||||
/* Wait for character to show up.
|
||||
*/
|
||||
buf = (unsigned char *)rbdf->cbd_bufaddr;
|
||||
|
||||
while (rbdf->cbd_sc & BD_SC_EMPTY)
|
||||
WATCHDOG_RESET ();
|
||||
|
||||
c = *buf;
|
||||
rbdf->cbd_sc |= BD_SC_EMPTY;
|
||||
|
||||
return(c);
|
||||
}
|
||||
|
||||
int smc1_tstc(void)
|
||||
{
|
||||
volatile cbd_t *rbdf;
|
||||
volatile smc_uart_t *up;
|
||||
volatile immap_t *im = (immap_t *)CFG_IMMR;
|
||||
volatile cpm8xx_t *cpmp = &(im->im_cpm);
|
||||
|
||||
up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC];
|
||||
|
||||
rbdf = (cbd_t *)&cpmp->cp_dpmem[up->smc_rbase];
|
||||
|
||||
return(!(rbdf->cbd_sc & BD_SC_EMPTY));
|
||||
}
|
||||
|
||||
/* search for keyboard and register it if found */
|
||||
int drv_keyboard_init(void)
|
||||
{
|
||||
int error = 0;
|
||||
device_t kbd_dev;
|
||||
|
||||
if (0) {
|
||||
/* register the keyboard */
|
||||
memset (&kbd_dev, 0, sizeof(device_t));
|
||||
strcpy(kbd_dev.name, "kbd");
|
||||
kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
|
||||
kbd_dev.putc = NULL;
|
||||
kbd_dev.puts = NULL;
|
||||
kbd_dev.getc = smc1_getc;
|
||||
kbd_dev.tstc = smc1_tstc;
|
||||
error = device_register (&kbd_dev);
|
||||
} else {
|
||||
lcd_is_enabled = 0;
|
||||
lcd_disable();
|
||||
}
|
||||
return error;
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include "mpc8xx.h"
|
||||
#include <linux/mtd/doc2000.h>
|
||||
|
||||
extern int kbd_init(void);
|
||||
extern int drv_kbd_init(void);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static long int dram_size (long int, long int *, long int);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define _NOT_USED_ 0xFFFFFFFF
|
||||
|
||||
const uint sdram_table[] =
|
||||
{
|
||||
/*
|
||||
* Single Read. (Offset 0 in UPMA RAM)
|
||||
*/
|
||||
0x1F07FC04, 0xEEAEFC04, 0x11ADFC04, 0xEFBBBC00,
|
||||
0x1FF77C47, /* last */
|
||||
/*
|
||||
* SDRAM Initialization (offset 5 in UPMA RAM)
|
||||
*
|
||||
* This is no UPM entry point. The following definition uses
|
||||
* the remaining space to establish an initialization
|
||||
* sequence, which is executed by a RUN command.
|
||||
*
|
||||
*/
|
||||
0x1FF77C34, 0xEFEABC34, 0x1FB57C35, /* last */
|
||||
/*
|
||||
* Burst Read. (Offset 8 in UPMA RAM)
|
||||
*/
|
||||
0x1F07FC04, 0xEEAEFC04, 0x10ADFC04, 0xF0AFFC00,
|
||||
0xF0AFFC00, 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C47, /* last */
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
/*
|
||||
* Single Write. (Offset 18 in UPMA RAM)
|
||||
*/
|
||||
0x1F27FC04, 0xEEAEBC00, 0x01B93C04, 0x1FF77C47, /* last */
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
/*
|
||||
* Burst Write. (Offset 20 in UPMA RAM)
|
||||
*/
|
||||
0x1F07FC04, 0xEEAEBC00, 0x10AD7C00, 0xF0AFFC00,
|
||||
0xF0AFFC00, 0xE1BBBC04, 0x1FF77C47, /* last */
|
||||
_NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
/*
|
||||
* Refresh (Offset 30 in UPMA RAM)
|
||||
*/
|
||||
0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
|
||||
0xFFFFFC84, 0xFFFFFC07, /* last */
|
||||
_NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
/*
|
||||
* Exception. (Offset 3c in UPMA RAM)
|
||||
*/
|
||||
0x1FF7FC07, /* last */
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
};
|
||||
|
||||
const uint static_table[] =
|
||||
{
|
||||
/*
|
||||
* Single Read. (Offset 0 in UPMA RAM)
|
||||
*/
|
||||
0x0FFFFC04, 0x0FF3FC04, 0x0FF3CC04, 0x0FF3CC04,
|
||||
0x0FF3EC04, 0x0FF3CC00, 0x0FF7FC04, 0x3FFFFC04,
|
||||
0xFFFFFC04, 0xFFFFFC05, /* last */
|
||||
_NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
/*
|
||||
* Single Write. (Offset 18 in UPMA RAM)
|
||||
*/
|
||||
0x0FFFFC04, 0x00FFFC04, 0x00FFFC04, 0x00FFFC04,
|
||||
0x01FFFC00, 0x3FFFFC04, 0xFFFFFC04, 0xFFFFFC05, /* last */
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Check Board Identity:
|
||||
*
|
||||
* Test TQ ID string (TQM8xx...)
|
||||
* If present, check for "L" type (no second DRAM bank),
|
||||
* otherwise "L" type is assumed as default.
|
||||
*
|
||||
* Return 1 for "L" type, 0 else.
|
||||
*/
|
||||
|
||||
int checkboard (void)
|
||||
{
|
||||
unsigned char *s = getenv("serial#");
|
||||
|
||||
if (!s || strncmp(s, "TQM8", 4)) {
|
||||
printf ("### No HW ID - assuming RBC823\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
puts(s);
|
||||
putc ('\n');
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
long int initdram (int board_type)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
long int size_b0, size8, size9;
|
||||
|
||||
upmconfig(UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
|
||||
|
||||
/*
|
||||
* 1 Bank of 64Mbit x 2 devices
|
||||
*/
|
||||
memctl->memc_mptpr = CFG_MPTPR_1BK_4K;
|
||||
memctl->memc_mar = 0x00000088;
|
||||
|
||||
/*
|
||||
* Map controller SDRAM bank 0
|
||||
*/
|
||||
memctl->memc_or4 = CFG_OR4_PRELIM;
|
||||
memctl->memc_br4 = CFG_BR4_PRELIM;
|
||||
memctl->memc_mamr = CFG_MAMR_8COL & (~(MAMR_PTAE)); /* no refresh yet */
|
||||
udelay(200);
|
||||
|
||||
/*
|
||||
* Perform SDRAM initializsation sequence
|
||||
*/
|
||||
memctl->memc_mcr = 0x80008105; /* SDRAM bank 0 */
|
||||
udelay(1);
|
||||
memctl->memc_mamr = (CFG_MAMR_8COL & ~(MAMR_TLFA_MSK)) | MAMR_TLFA_8X;
|
||||
udelay(200);
|
||||
memctl->memc_mcr = 0x80008130; /* SDRAM bank 0 - execute twice */
|
||||
udelay(1);
|
||||
memctl->memc_mamr = (CFG_MAMR_8COL & ~(MAMR_TLFA_MSK)) | MAMR_TLFA_4X;
|
||||
udelay(200);
|
||||
|
||||
memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */
|
||||
udelay (1000);
|
||||
|
||||
/*
|
||||
* Preliminary prescaler for refresh (depends on number of
|
||||
* banks): This value is selected for four cycles every 62.4 us
|
||||
* with two SDRAM banks or four cycles every 31.2 us with one
|
||||
* bank. It will be adjusted after memory sizing.
|
||||
*/
|
||||
memctl->memc_mptpr = CFG_MPTPR_2BK_4K; // 16: but should be: CFG_MPTPR_1BK_4K
|
||||
|
||||
/*
|
||||
* Check Bank 0 Memory Size for re-configuration
|
||||
*
|
||||
* try 8 column mode
|
||||
*/
|
||||
size8 = dram_size (CFG_MAMR_8COL, (ulong *)SDRAM_BASE4_PRELIM, SDRAM_MAX_SIZE);
|
||||
udelay (1000);
|
||||
|
||||
/*
|
||||
* try 9 column mode
|
||||
*/
|
||||
size9 = dram_size (CFG_MAMR_9COL, (ulong *)SDRAM_BASE4_PRELIM, SDRAM_MAX_SIZE);
|
||||
|
||||
if (size8 < size9) { /* leave configuration at 9 columns */
|
||||
size_b0 = size9;
|
||||
/* debug ("SDRAM Bank 0 in 9 column mode: %ld MB\n", size >> 20); */
|
||||
} else { /* back to 8 columns */
|
||||
size_b0 = size8;
|
||||
memctl->memc_mamr = CFG_MAMR_8COL;
|
||||
udelay(500);
|
||||
/* debug ("SDRAM Bank 0 in 8 column mode: %ld MB\n", size >> 20); */
|
||||
}
|
||||
|
||||
udelay (1000);
|
||||
|
||||
/*
|
||||
* Adjust refresh rate depending on SDRAM type, both banks
|
||||
* For types > 128 MBit leave it at the current (fast) rate
|
||||
*/
|
||||
if ((size_b0 < 0x02000000) ) {
|
||||
/* reduce to 15.6 us (62.4 us / quad) */
|
||||
memctl->memc_mptpr = CFG_MPTPR_2BK_4K;
|
||||
udelay(1000);
|
||||
}
|
||||
|
||||
/* SDRAM Bank 0 is bigger - map first */
|
||||
|
||||
memctl->memc_or4 = ((-size_b0) & 0xFFFF0000) | CFG_OR_TIMING_SDRAM;
|
||||
memctl->memc_br4 = (CFG_SDRAM_BASE & BR_BA_MSK) | BR_MS_UPMA | BR_V;
|
||||
|
||||
udelay(10000);
|
||||
|
||||
return (size_b0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Check memory range for valid RAM. A simple memory test determines
|
||||
* the actually available RAM size between addresses `base' and
|
||||
* `base + maxsize'. Some (not all) hardware errors are detected:
|
||||
* - short between address lines
|
||||
* - short between data lines
|
||||
*/
|
||||
|
||||
static long int dram_size (long int mamr_value, long int *base, long int maxsize)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
volatile long int *addr;
|
||||
long int cnt, val;
|
||||
|
||||
memctl->memc_mamr = mamr_value;
|
||||
|
||||
for (cnt = maxsize/sizeof(long)/2; cnt > 0; cnt >>= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
|
||||
*addr = ~cnt;
|
||||
}
|
||||
|
||||
/* write 0 to base address */
|
||||
addr = base;
|
||||
*addr = 0;
|
||||
|
||||
/* check at base address */
|
||||
if ((val = *addr) != 0) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
for (cnt = 1; cnt < maxsize/sizeof(long) ; cnt <<= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
|
||||
val = *addr;
|
||||
|
||||
if (val != (~cnt)) {
|
||||
return (cnt * sizeof(long));
|
||||
}
|
||||
}
|
||||
return cnt * sizeof(long);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void doc_init(void)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
|
||||
upmconfig(UPMB, (uint *)static_table, sizeof(static_table)/sizeof(uint));
|
||||
memctl->memc_mbmr = MAMR_DSA_1_CYCL;
|
||||
|
||||
doc_probe(FLASH_BASE1_PRELIM);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
OUTPUT_ARCH(powerpc)
|
||||
SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
. = + SIZEOF_HEADERS;
|
||||
.interp : { *(.interp) }
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.rel.text : { *(.rel.text) }
|
||||
.rela.text : { *(.rela.text) }
|
||||
.rel.data : { *(.rel.data) }
|
||||
.rela.data : { *(.rela.data) }
|
||||
.rel.rodata : { *(.rel.rodata) }
|
||||
.rela.rodata : { *(.rela.rodata) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
.init : { *(.init) }
|
||||
.plt : { *(.plt) }
|
||||
.text :
|
||||
{
|
||||
/* WARNING - the following is hand-optimized to fit within */
|
||||
/* the sector layout of our flash chips! XXX FIXME XXX */
|
||||
|
||||
cpu/mpc8xx/start.o (.text)
|
||||
common/dlmalloc.o (.text)
|
||||
lib_ppc/ppcstring.o (.text)
|
||||
lib_generic/vsprintf.o (.text)
|
||||
lib_generic/crc32.o (.text)
|
||||
lib_generic/zlib.o (.text)
|
||||
|
||||
. = env_offset;
|
||||
common/environment.o(.text)
|
||||
|
||||
*(.text)
|
||||
*(.fixup)
|
||||
*(.got1)
|
||||
}
|
||||
_etext = .;
|
||||
PROVIDE (etext = .);
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
}
|
||||
.fini : { *(.fini) } =0
|
||||
.ctors : { *(.ctors) }
|
||||
.dtors : { *(.dtors) }
|
||||
|
||||
/* Read-write section, merged into data segment: */
|
||||
. = (. + 0x00FF) & 0xFFFFFF00;
|
||||
_erotext = .;
|
||||
PROVIDE (erotext = .);
|
||||
.reloc :
|
||||
{
|
||||
*(.got)
|
||||
_GOT2_TABLE_ = .;
|
||||
*(.got2)
|
||||
_FIXUP_TABLE_ = .;
|
||||
*(.fixup)
|
||||
}
|
||||
__got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
|
||||
__fixup_entries = (. - _FIXUP_TABLE_)>>2;
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.sdata)
|
||||
*(.sdata2)
|
||||
*(.dynamic)
|
||||
CONSTRUCTORS
|
||||
}
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
|
||||
__start___ex_table = .;
|
||||
__ex_table : { *(__ex_table) }
|
||||
__stop___ex_table = .;
|
||||
|
||||
. = ALIGN(256);
|
||||
__init_begin = .;
|
||||
.text.init : { *(.text.init) }
|
||||
.data.init : { *(.data.init) }
|
||||
. = ALIGN(256);
|
||||
__init_end = .;
|
||||
|
||||
__bss_start = .;
|
||||
.bss :
|
||||
{
|
||||
*(.sbss) *(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
}
|
||||
_end = . ;
|
||||
PROVIDE (end = .);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#
|
||||
# (C) Copyright 2000
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
#
|
||||
# See file CREDITS for list of people who contributed to this
|
||||
# project.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
# MA 02111-1307 USA
|
||||
#
|
||||
|
||||
include $(TOPDIR)/config.mk
|
||||
|
||||
LIB = lib$(BOARD).a
|
||||
|
||||
OBJS = $(BOARD).o flash.o
|
||||
|
||||
$(LIB): .depend $(OBJS)
|
||||
$(AR) crv $@ $^
|
||||
|
||||
#########################################################################
|
||||
|
||||
.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
|
||||
$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
|
||||
|
||||
sinclude .depend
|
||||
|
||||
#########################################################################
|
||||
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# (C) Copyright 2000
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
#
|
||||
# See file CREDITS for list of people who contributed to this
|
||||
# project.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
# MA 02111-1307 USA
|
||||
#
|
||||
|
||||
#
|
||||
# RMU boards
|
||||
#
|
||||
|
||||
TEXT_BASE = 0xfff00000
|
||||
@@ -0,0 +1,515 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc8xx.h>
|
||||
|
||||
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* 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);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
unsigned long flash_init (void)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
unsigned long size_b0 ;
|
||||
int i;
|
||||
|
||||
/* Init: no FLASHes known */
|
||||
for (i=0; i<CFG_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_BASE_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);
|
||||
}
|
||||
|
||||
/* Remap FLASH according to real size */
|
||||
memctl->memc_or0 = CFG_OR_TIMING_FLASH | (-size_b0 & 0xFFFF8000);
|
||||
memctl->memc_br0 = (CFG_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 *)CFG_FLASH_BASE, &flash_info[0]);
|
||||
flash_get_offsets (CFG_FLASH_BASE, &flash_info[0]);
|
||||
|
||||
#if CFG_MONITOR_BASE >= CFG_FLASH_BASE
|
||||
/* monitor protection ON by default */
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
CFG_MONITOR_BASE,
|
||||
CFG_MONITOR_BASE+monitor_flash_len-1,
|
||||
&flash_info[0]);
|
||||
#endif
|
||||
|
||||
#ifdef CFG_ENV_IS_IN_FLASH
|
||||
/* ENV protection ON by default */
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
CFG_ENV_ADDR,
|
||||
CFG_ENV_ADDR+CFG_ENV_SIZE-1,
|
||||
&flash_info[0]);
|
||||
#endif
|
||||
|
||||
flash_info[0].size = size_b0;
|
||||
|
||||
return (size_b0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
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 + 0x00010000;
|
||||
info->start[2] = base + 0x00018000;
|
||||
info->start[3] = base + 0x00020000;
|
||||
for (i = 4; i < info->sector_count; i++) {
|
||||
info->start[i] = base + ((i-3) * 0x00040000) ;
|
||||
}
|
||||
} else {
|
||||
/* set sector offsets for top boot block type */
|
||||
i = info->sector_count - 1;
|
||||
info->start[i--] = base + info->size - 0x00010000;
|
||||
info->start[i--] = base + info->size - 0x00018000;
|
||||
info->start[i--] = base + info->size - 0x00020000;
|
||||
for (; i >= 0; i--) {
|
||||
info->start[i] = base + i * 0x00040000;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
void flash_print_info (flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (info->flash_id == FLASH_UNKNOWN) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
printf (" Size: %ld MB in %d Sectors\n",
|
||||
info->size >> 20, info->sector_count);
|
||||
|
||||
printf (" Sector Start Addresses:");
|
||||
for (i=0; i<info->sector_count; ++i) {
|
||||
if ((i % 5) == 0)
|
||||
printf ("\n ");
|
||||
printf (" %08lX%s",
|
||||
info->start[i],
|
||||
info->protect[i] ? " (RO)" : " "
|
||||
);
|
||||
}
|
||||
printf ("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following code cannot be run from FLASH!
|
||||
*/
|
||||
|
||||
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[0xAAA] = 0xAAAAAAAA ;
|
||||
addr[0x555] = 0x55555555 ;
|
||||
addr[0xAAA] = 0x90909090 ;
|
||||
|
||||
value = addr[0] ;
|
||||
|
||||
switch (value & 0x00FF00FF) {
|
||||
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[2] ; /* device ID */
|
||||
|
||||
switch (value & 0x00FF00FF) {
|
||||
case (AMD_ID_LV400T & 0x00FF00FF):
|
||||
info->flash_id += FLASH_AM400T;
|
||||
info->sector_count = 11;
|
||||
info->size = 0x00100000;
|
||||
break; /* => 1 MB */
|
||||
|
||||
case (AMD_ID_LV400B & 0x00FF00FF):
|
||||
info->flash_id += FLASH_AM400B;
|
||||
info->sector_count = 11;
|
||||
info->size = 0x00100000;
|
||||
break; /* => 1 MB */
|
||||
|
||||
case (AMD_ID_LV800T & 0x00FF00FF):
|
||||
info->flash_id += FLASH_AM800T;
|
||||
info->sector_count = 19;
|
||||
info->size = 0x00200000;
|
||||
break; /* => 2 MB */
|
||||
|
||||
case (AMD_ID_LV800B & 0x00FF00FF):
|
||||
info->flash_id += FLASH_AM800B;
|
||||
info->sector_count = 19;
|
||||
info->size = 0x00400000; /*%%% Size doubled by yooth */
|
||||
break; /* => 4 MB */
|
||||
|
||||
case (AMD_ID_LV160T & 0x00FF00FF):
|
||||
info->flash_id += FLASH_AM160T;
|
||||
info->sector_count = 35;
|
||||
info->size = 0x00400000;
|
||||
break; /* => 4 MB */
|
||||
|
||||
case (AMD_ID_LV160B & 0x00FF00FF):
|
||||
info->flash_id += FLASH_AM160B;
|
||||
info->sector_count = 35;
|
||||
info->size = 0x00800000;
|
||||
break; /* => 8 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 = 0x01000000;
|
||||
break; /* => 16 MB */
|
||||
#endif
|
||||
default:
|
||||
info->flash_id = FLASH_UNKNOWN;
|
||||
return (0); /* => no or unknown flash */
|
||||
|
||||
}
|
||||
/*%%% sector start address modified */
|
||||
/* 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 + 0x00010000;
|
||||
info->start[2] = base + 0x00018000;
|
||||
info->start[3] = base + 0x00020000;
|
||||
for (i = 4; i < info->sector_count; i++) {
|
||||
info->start[i] = base + ((i-3) * 0x00040000) ;
|
||||
}
|
||||
} else {
|
||||
/* set sector offsets for top boot block type */
|
||||
i = info->sector_count - 1;
|
||||
info->start[i--] = base + info->size - 0x00010000;
|
||||
info->start[i--] = base + info->size - 0x00018000;
|
||||
info->start[i--] = base + info->size - 0x00020000;
|
||||
for (; i >= 0; i--) {
|
||||
info->start[i] = base + i * 0x00040000;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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[4] & 1 ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent writes to uninitialized FLASH.
|
||||
*/
|
||||
if (info->flash_id != FLASH_UNKNOWN) {
|
||||
addr = (volatile unsigned long *)info->start[0];
|
||||
|
||||
*addr = 0xF0F0F0F0; /* reset bank */
|
||||
}
|
||||
|
||||
return (info->size);
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
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;
|
||||
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");
|
||||
}
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
|
||||
prot = 0;
|
||||
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",
|
||||
prot);
|
||||
} else {
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
l_sect = -1;
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
addr[0xAAA] = 0xAAAAAAAA;
|
||||
addr[0x555] = 0x55555555;
|
||||
addr[0xAAA] = 0x80808080;
|
||||
addr[0xAAA] = 0xAAAAAAAA;
|
||||
addr[0x555] = 0x55555555;
|
||||
|
||||
/* Start erase on unprotected sectors */
|
||||
for (sect = s_first; sect<=s_last; sect++) {
|
||||
if (info->protect[sect] == 0) { /* not protected */
|
||||
addr = (vu_long *)(info->start[sect]) ;
|
||||
addr[0] = 0x30303030 ;
|
||||
l_sect = sect;
|
||||
}
|
||||
}
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag)
|
||||
enable_interrupts();
|
||||
|
||||
/* wait at least 80us - let's wait 1 ms */
|
||||
udelay (1000);
|
||||
|
||||
/*
|
||||
* We wait for the last triggered sector
|
||||
*/
|
||||
if (l_sect < 0)
|
||||
goto DONE;
|
||||
|
||||
start = get_timer (0);
|
||||
last = start;
|
||||
addr = (vu_long *)(info->start[l_sect]);
|
||||
while ((addr[0] & 0x80808080) != 0x80808080) {
|
||||
if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
|
||||
printf ("Timeout\n");
|
||||
return 1;
|
||||
}
|
||||
/* show that we're waiting */
|
||||
if ((now - last) > 1000) { /* every second */
|
||||
putc ('.');
|
||||
last = now;
|
||||
}
|
||||
}
|
||||
|
||||
DONE:
|
||||
/* reset to read mode */
|
||||
addr = (vu_long *)info->start[0];
|
||||
addr[0] = 0xF0F0F0F0; /* reset bank */
|
||||
|
||||
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)
|
||||
{
|
||||
ulong cp, wp, data;
|
||||
int i, l, rc;
|
||||
|
||||
wp = (addr & ~3); /* get lower word aligned address */
|
||||
|
||||
/*
|
||||
* handle unaligned start bytes
|
||||
*/
|
||||
if ((l = addr - wp) != 0) {
|
||||
data = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
}
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle word aligned part
|
||||
*/
|
||||
while (cnt >= 4) {
|
||||
data = 0;
|
||||
for (i=0; i<4; ++i) {
|
||||
data = (data << 8) | *src++;
|
||||
}
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
}
|
||||
wp += 4;
|
||||
cnt -= 4;
|
||||
}
|
||||
|
||||
if (cnt == 0) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* handle unaligned tail bytes
|
||||
*/
|
||||
data = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
vu_long *addr = (vu_long *)(info->start[0]);
|
||||
ulong start;
|
||||
int flag;
|
||||
|
||||
/* Check if Flash is (sufficiently) erased */
|
||||
if ((*((vu_long *)dest) & data) != data) {
|
||||
return (2);
|
||||
}
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
addr[0xAAA] = 0xAAAAAAAA;
|
||||
addr[0x555] = 0x55555555;
|
||||
addr[0xAAA] = 0xA0A0A0A0;
|
||||
|
||||
*((vu_long *)dest) = data;
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag)
|
||||
enable_interrupts();
|
||||
|
||||
/* data polling for D7 */
|
||||
start = get_timer (0);
|
||||
while ((*((vu_long *)dest) & 0x80808080) != (data & 0x80808080)) {
|
||||
if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc8xx.h>
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static long int dram_size (long int, long int *, long int);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define _NOT_USED_ 0xFFFFCC25
|
||||
|
||||
const uint sdram_table[] =
|
||||
{
|
||||
/*
|
||||
* Single Read. (Offset 00h in UPMA RAM)
|
||||
*/
|
||||
0x0F03CC04, 0x00ACCC24, 0x1FF74C20, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
|
||||
/*
|
||||
* Burst Read. (Offset 08h in UPMA RAM)
|
||||
*/
|
||||
0x0F03CC04, 0x00ACCC24, 0x00FFCC20, 0x00FFCC20,
|
||||
0x01FFCC20, 0x1FF74C20, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
|
||||
/*
|
||||
* Single Write. (Offset 18h in UPMA RAM)
|
||||
*/
|
||||
0x0F03CC02, 0x00AC0C24, 0x1FF74C25, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
|
||||
/*
|
||||
* Burst Write. (Offset 20h in UPMA RAM)
|
||||
*/
|
||||
0x0F03CC00, 0x00AC0C20, 0x00FFFC20, 0x00FFFC22,
|
||||
0x01FFFC24, 0x1FF74C25, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
|
||||
|
||||
/*
|
||||
* Refresh. (Offset 30h in UPMA RAM)
|
||||
* (Initialization code at 0x36)
|
||||
*/
|
||||
0x0FF0CC24, 0xFFFFCC24, _NOT_USED_, _NOT_USED_,
|
||||
_NOT_USED_, _NOT_USED_, 0xEFFB8C34, 0x0FF74C34,
|
||||
0x0FFACCB4, 0x0FF5CC34, 0x0FFCC34, 0x0FFFCCB4,
|
||||
|
||||
/*
|
||||
* Exception. (Offset 3Ch in UPMA RAM)
|
||||
*/
|
||||
0x0FEA8C34, 0x1FB54C34, 0xFFFFCC34, _NOT_USED_
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
* Check Board Identity:
|
||||
*/
|
||||
|
||||
int checkboard (void)
|
||||
{
|
||||
puts ("Board: RMU\n") ;
|
||||
return (0) ;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
long int initdram (int board_type)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
long int size10 ;
|
||||
|
||||
upmconfig(UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
|
||||
|
||||
/* Refresh clock prescalar */
|
||||
memctl->memc_mptpr = CFG_MPTPR ;
|
||||
|
||||
memctl->memc_mar = 0x00000088;
|
||||
|
||||
/* Map controller banks 1 to the SDRAM bank */
|
||||
memctl->memc_or1 = CFG_OR1_PRELIM;
|
||||
memctl->memc_br1 = CFG_BR1_PRELIM;
|
||||
|
||||
memctl->memc_mamr = CFG_MAMR_10COL & (~(MAMR_PTAE)); /* no refresh yet */
|
||||
|
||||
udelay(200);
|
||||
|
||||
/* perform SDRAM initializsation sequence */
|
||||
|
||||
memctl->memc_mcr = 0x80002136 ; /* SDRAM bank 0 */
|
||||
udelay(1);
|
||||
|
||||
memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */
|
||||
|
||||
udelay (1000);
|
||||
|
||||
/* Check Bank 0 Memory Size
|
||||
* try 10 column mode
|
||||
*/
|
||||
|
||||
size10 = dram_size (CFG_MAMR_10COL, (ulong *)SDRAM_BASE_PRELIM, SDRAM_MAX_SIZE) ;
|
||||
|
||||
return (size10);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Check memory range for valid RAM. A simple memory test determines
|
||||
* the actually available RAM size between addresses `base' and
|
||||
* `base + maxsize'. Some (not all) hardware errors are detected:
|
||||
* - short between address lines
|
||||
* - short between data lines
|
||||
*/
|
||||
|
||||
static long int dram_size (long int mamr_value, long int *base, long int maxsize)
|
||||
{
|
||||
volatile immap_t *immap = (immap_t *)CFG_IMMR;
|
||||
volatile memctl8xx_t *memctl = &immap->im_memctl;
|
||||
volatile long int *addr;
|
||||
ulong cnt, val;
|
||||
ulong save[32]; /* to make test non-destructive */
|
||||
unsigned char i = 0;
|
||||
|
||||
memctl->memc_mamr = mamr_value;
|
||||
|
||||
for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
|
||||
save[i++] = *addr;
|
||||
*addr = ~cnt;
|
||||
}
|
||||
|
||||
/* write 0 to base address */
|
||||
addr = base;
|
||||
save[i] = *addr;
|
||||
*addr = 0;
|
||||
|
||||
/* check at base address */
|
||||
if ((val = *addr) != 0) {
|
||||
*addr = save[i];
|
||||
return (0);
|
||||
}
|
||||
|
||||
for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
|
||||
val = *addr;
|
||||
*addr = save[--i];
|
||||
|
||||
if (val != (~cnt)) {
|
||||
return (cnt * sizeof(long));
|
||||
}
|
||||
}
|
||||
return (maxsize);
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
OUTPUT_ARCH(powerpc)
|
||||
SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
. = + SIZEOF_HEADERS;
|
||||
.interp : { *(.interp) }
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.rel.text : { *(.rel.text) }
|
||||
.rela.text : { *(.rela.text) }
|
||||
.rel.data : { *(.rel.data) }
|
||||
.rela.data : { *(.rela.data) }
|
||||
.rel.rodata : { *(.rel.rodata) }
|
||||
.rela.rodata : { *(.rela.rodata) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
.init : { *(.init) }
|
||||
.plt : { *(.plt) }
|
||||
.text :
|
||||
{
|
||||
/* WARNING - the following is hand-optimized to fit within */
|
||||
/* the sector layout of our flash chips! XXX FIXME XXX */
|
||||
|
||||
cpu/mpc8xx/start.o (.text)
|
||||
common/dlmalloc.o (.text)
|
||||
lib_ppc/ppcstring.o (.text)
|
||||
lib_generic/vsprintf.o (.text)
|
||||
lib_generic/crc32.o (.text)
|
||||
lib_generic/zlib.o (.text)
|
||||
/* XXX ?
|
||||
. = env_offset;
|
||||
*/
|
||||
common/environment.o(.text)
|
||||
|
||||
*(.text)
|
||||
*(.fixup)
|
||||
*(.got1)
|
||||
}
|
||||
_etext = .;
|
||||
PROVIDE (etext = .);
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
}
|
||||
.fini : { *(.fini) } =0
|
||||
.ctors : { *(.ctors) }
|
||||
.dtors : { *(.dtors) }
|
||||
|
||||
/* Read-write section, merged into data segment: */
|
||||
. = (. + 0x00FF) & 0xFFFFFF00;
|
||||
_erotext = .;
|
||||
PROVIDE (erotext = .);
|
||||
.reloc :
|
||||
{
|
||||
*(.got)
|
||||
_GOT2_TABLE_ = .;
|
||||
*(.got2)
|
||||
_FIXUP_TABLE_ = .;
|
||||
*(.fixup)
|
||||
}
|
||||
__got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
|
||||
__fixup_entries = (. - _FIXUP_TABLE_)>>2;
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.sdata)
|
||||
*(.sdata2)
|
||||
*(.dynamic)
|
||||
CONSTRUCTORS
|
||||
}
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
|
||||
__start___ex_table = .;
|
||||
__ex_table : { *(__ex_table) }
|
||||
__stop___ex_table = .;
|
||||
|
||||
. = ALIGN(256);
|
||||
__init_begin = .;
|
||||
.text.init : { *(.text.init) }
|
||||
.data.init : { *(.data.init) }
|
||||
. = ALIGN(256);
|
||||
__init_end = .;
|
||||
|
||||
__bss_start = .;
|
||||
.bss :
|
||||
{
|
||||
*(.sbss) *(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
}
|
||||
_end = . ;
|
||||
PROVIDE (end = .);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
OUTPUT_ARCH(powerpc)
|
||||
SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
. = + SIZEOF_HEADERS;
|
||||
.interp : { *(.interp) }
|
||||
.hash : { *(.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.rel.text : { *(.rel.text) }
|
||||
.rela.text : { *(.rela.text) }
|
||||
.rel.data : { *(.rel.data) }
|
||||
.rela.data : { *(.rela.data) }
|
||||
.rel.rodata : { *(.rel.rodata) }
|
||||
.rela.rodata : { *(.rela.rodata) }
|
||||
.rel.got : { *(.rel.got) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rel.ctors : { *(.rel.ctors) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rel.dtors : { *(.rel.dtors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rel.bss : { *(.rel.bss) }
|
||||
.rela.bss : { *(.rela.bss) }
|
||||
.rel.plt : { *(.rel.plt) }
|
||||
.rela.plt : { *(.rela.plt) }
|
||||
.init : { *(.init) }
|
||||
.plt : { *(.plt) }
|
||||
.text :
|
||||
{
|
||||
/* WARNING - the following is hand-optimized to fit within */
|
||||
/* the sector layout of our flash chips! XXX FIXME XXX */
|
||||
|
||||
cpu/mpc8xx/start.o (.text)
|
||||
common/dlmalloc.o (.text)
|
||||
lib_generic/vsprintf.o (.text)
|
||||
lib_generic/crc32.o (.text)
|
||||
|
||||
. = env_offset;
|
||||
common/environment.o(.text)
|
||||
|
||||
*(.text)
|
||||
*(.fixup)
|
||||
*(.got1)
|
||||
}
|
||||
_etext = .;
|
||||
PROVIDE (etext = .);
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata)
|
||||
*(.rodata1)
|
||||
}
|
||||
.fini : { *(.fini) } =0
|
||||
.ctors : { *(.ctors) }
|
||||
.dtors : { *(.dtors) }
|
||||
|
||||
/* Read-write section, merged into data segment: */
|
||||
. = (. + 0x0FFF) & 0xFFFFF000;
|
||||
_erotext = .;
|
||||
PROVIDE (erotext = .);
|
||||
.reloc :
|
||||
{
|
||||
*(.got)
|
||||
_GOT2_TABLE_ = .;
|
||||
*(.got2)
|
||||
_FIXUP_TABLE_ = .;
|
||||
*(.fixup)
|
||||
}
|
||||
__got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
|
||||
__fixup_entries = (. - _FIXUP_TABLE_)>>2;
|
||||
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
*(.data1)
|
||||
*(.sdata)
|
||||
*(.sdata2)
|
||||
*(.dynamic)
|
||||
CONSTRUCTORS
|
||||
}
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
|
||||
__start___ex_table = .;
|
||||
__ex_table : { *(__ex_table) }
|
||||
__stop___ex_table = .;
|
||||
|
||||
. = ALIGN(4096);
|
||||
__init_begin = .;
|
||||
.text.init : { *(.text.init) }
|
||||
.data.init : { *(.data.init) }
|
||||
. = ALIGN(4096);
|
||||
__init_end = .;
|
||||
|
||||
__bss_start = .;
|
||||
.bss :
|
||||
{
|
||||
*(.sbss) *(.scommon)
|
||||
*(.dynbss)
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
}
|
||||
_end = . ;
|
||||
PROVIDE (end = .);
|
||||
}
|
||||
|
||||
@@ -22,4 +22,4 @@
|
||||
#
|
||||
|
||||
|
||||
TEXT_BASE = 0x387e0000
|
||||
TEXT_BASE = 0x387c0000
|
||||
+561
-368
@@ -1,4 +1,7 @@
|
||||
/*
|
||||
* (C) Copyright 2002, 2003
|
||||
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
||||
* Alex Zuepke <azu@sysgo.de>
|
||||
@@ -23,31 +26,23 @@
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
#include <pci.h>
|
||||
#include <asm/ic/sc520.h>
|
||||
|
||||
ulong myflush(void);
|
||||
#define PROBE_BUFFER_SIZE 1024
|
||||
static unsigned char buffer[PROBE_BUFFER_SIZE];
|
||||
|
||||
#define SC520_MAX_FLASH_BANKS 3
|
||||
#define SC520_FLASH_BANK0_BASE 0x38000000 /* BOOTCS */
|
||||
#define SC520_FLASH_BANK1_BASE 0x30000000 /* ROMCS0 */
|
||||
#define SC520_FLASH_BANK2_BASE 0x28000000 /* ROMCS1 */
|
||||
#define SC520_FLASH_BANKSIZE 0x8000000
|
||||
|
||||
#define FLASH_BANK_SIZE 0x400000 /* 4 MB */
|
||||
#define MAIN_SECT_SIZE 0x20000 /* 128 KB */
|
||||
#define AMD29LV016B_SIZE 0x200000
|
||||
#define AMD29LV016B_SECTORS 32
|
||||
|
||||
flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
|
||||
|
||||
|
||||
#define CMD_READ_ARRAY 0x00F000F0
|
||||
#define CMD_UNLOCK1 0x00AA00AA
|
||||
#define CMD_UNLOCK2 0x00550055
|
||||
#define CMD_ERASE_SETUP 0x00800080
|
||||
#define CMD_ERASE_CONFIRM 0x00300030
|
||||
#define CMD_PROGRAM 0x00A000A0
|
||||
#define CMD_UNLOCK_BYPASS 0x00200020
|
||||
|
||||
#define MEM_FLASH_ADDR1 (*(volatile u32 *)(CFG_FLASH_BASE + (0x00000555 << 2)))
|
||||
#define MEM_FLASH_ADDR2 (*(volatile u32 *)(CFG_FLASH_BASE + (0x000002AA << 2)))
|
||||
|
||||
#define BIT_ERASE_DONE 0x00800080
|
||||
#define BIT_RDY_MASK 0x00800080
|
||||
#define BIT_PROGRAM_ERROR 0x00200020
|
||||
#define BIT_TIMEOUT 0x80000000 /* our flag */
|
||||
flash_info_t flash_info[SC520_MAX_FLASH_BANKS];
|
||||
|
||||
#define READY 1
|
||||
#define ERR 2
|
||||
@@ -56,394 +51,592 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
static u32 _probe_flash(u32 addr, u32 bw, int il)
|
||||
{
|
||||
u32 result=0;
|
||||
|
||||
/* First do an unlock cycle for the benefit of
|
||||
* devices that need it */
|
||||
|
||||
switch (bw) {
|
||||
|
||||
case 1:
|
||||
*(volatile u8*)(addr+0x5555) = 0xaa;
|
||||
*(volatile u8*)(addr+0x2aaa) = 0x55;
|
||||
*(volatile u8*)(addr+0x5555) = 0x90;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u8*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u8*)(addr+2);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u8*)addr = 0xff;
|
||||
*(volatile u8*)(addr+0x5555), 0xf0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*(volatile u16*)(addr+0xaaaa) = 0xaaaa;
|
||||
*(volatile u16*)(addr+0x5554) = 0x5555;
|
||||
|
||||
/* Issue identification command */
|
||||
if (il == 2) {
|
||||
*(volatile u16*)(addr+0xaaaa) = 0x9090;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u8*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u8*)(addr+2);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u16*)addr = 0xffff;
|
||||
*(volatile u16*)(addr+0xaaaa), 0xf0f0;
|
||||
|
||||
} else {
|
||||
*(volatile u8*)(addr+0xaaaa) = 0x90;
|
||||
/* Read vendor */
|
||||
result = *(volatile u16*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u16*)(addr+2);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u8*)addr = 0xff;
|
||||
*(volatile u8*)(addr+0xaaaa), 0xf0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*(volatile u32*)(addr+0x5554) = 0xaaaaaaaa;
|
||||
*(volatile u32*)(addr+0xaaa8) = 0x55555555;
|
||||
|
||||
switch (il) {
|
||||
case 1:
|
||||
/* Issue identification command */
|
||||
*(volatile u8*)(addr+0x5554) = 0x90;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u16*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u16*)(addr+4);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u8*)addr = 0xff;
|
||||
*(volatile u8*)(addr+0x5554), 0xf0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* Issue identification command */
|
||||
*(volatile u32*)(addr + 0x5554) = 0x00900090;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u16*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u16*)(addr+4);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u32*)addr = 0x00ff00ff;
|
||||
*(volatile u32*)(addr+0x5554), 0x00f000f0;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
/* Issue identification command */
|
||||
*(volatile u32*)(addr+0x5554) = 0x90909090;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u8*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u8*)(addr+4);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u32*)addr = 0xffffffff;
|
||||
*(volatile u32*)(addr+0x5554), 0xf0f0f0f0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
extern int _probe_flash_end;
|
||||
asm ("_probe_flash_end:\n"
|
||||
".long 0\n");
|
||||
|
||||
static int identify_flash(unsigned address, int width)
|
||||
{
|
||||
int is;
|
||||
int device;
|
||||
int vendor;
|
||||
int size;
|
||||
unsigned res;
|
||||
|
||||
u32 (*_probe_flash_ptr)(u32 a, u32 bw, int il);
|
||||
|
||||
size = (unsigned)&_probe_flash_end - (unsigned)_probe_flash;
|
||||
|
||||
if (size > PROBE_BUFFER_SIZE) {
|
||||
printf("_probe_flash() routine too large (%d) %p - %p\n",
|
||||
size, &_probe_flash_end, _probe_flash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, _probe_flash, size);
|
||||
_probe_flash_ptr = (void*)buffer;
|
||||
|
||||
is = disable_interrupts();
|
||||
res = _probe_flash_ptr(address, width, 1);
|
||||
if (is) {
|
||||
enable_interrupts();
|
||||
}
|
||||
|
||||
|
||||
vendor = res >> 16;
|
||||
device = res & 0xffff;
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ulong flash_init(void)
|
||||
{
|
||||
int i, j;
|
||||
ulong size = 0;
|
||||
|
||||
for (i = 0; i < CFG_MAX_FLASH_BANKS; i++)
|
||||
{
|
||||
ulong flashbase = 0;
|
||||
flash_info[i].flash_id =
|
||||
(AMD_MANUFACT & FLASH_VENDMASK) |
|
||||
(AMD_ID_LV160B & FLASH_TYPEMASK);
|
||||
flash_info[i].size = FLASH_BANK_SIZE;
|
||||
flash_info[i].sector_count = CFG_MAX_FLASH_SECT;
|
||||
memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
|
||||
if (i == 0)
|
||||
flashbase = PHYS_FLASH_1;
|
||||
else
|
||||
panic("configured to many flash banks!\n");
|
||||
for (j = 0; j < flash_info[i].sector_count; j++)
|
||||
{
|
||||
|
||||
if (j <= 3)
|
||||
{
|
||||
/* 1st one is 32 KB */
|
||||
if (j == 0)
|
||||
{
|
||||
flash_info[i].start[j] = flashbase + 0;
|
||||
int i, j;
|
||||
ulong size = 0;
|
||||
|
||||
for (i = 0; i < SC520_MAX_FLASH_BANKS; i++) {
|
||||
unsigned id;
|
||||
ulong flashbase = 0;
|
||||
int sectsize = 0;
|
||||
|
||||
memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
|
||||
switch (i) {
|
||||
case 0:
|
||||
flashbase = SC520_FLASH_BANK0_BASE;
|
||||
break;
|
||||
case 1:
|
||||
flashbase = SC520_FLASH_BANK1_BASE;
|
||||
break;
|
||||
case 2:
|
||||
flashbase = SC520_FLASH_BANK2_BASE;
|
||||
break;
|
||||
default:
|
||||
panic("configured to many flash banks!\n");
|
||||
}
|
||||
|
||||
/* 2nd and 3rd are both 16 KB */
|
||||
if ((j == 1) || (j == 2))
|
||||
{
|
||||
flash_info[i].start[j] = flashbase + 0x8000 + (j-1)*0x4000;
|
||||
|
||||
id = identify_flash(flashbase, 4);
|
||||
switch (id & 0x00ff00ff) {
|
||||
case 0x000100c8:
|
||||
/* 29LV016B/29LV017B */
|
||||
flash_info[i].flash_id =
|
||||
(AMD_MANUFACT & FLASH_VENDMASK) |
|
||||
(AMD_ID_LV016B & FLASH_TYPEMASK);
|
||||
|
||||
flash_info[i].size = AMD29LV016B_SIZE*4;
|
||||
flash_info[i].sector_count = AMD29LV016B_SECTORS;
|
||||
sectsize = (AMD29LV016B_SIZE*4)/AMD29LV016B_SECTORS;
|
||||
printf("Bank %d: 4 x AMD 29LV017B\n", i);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
printf("Bank %d have unknown flash %08x\n", i, id);
|
||||
flash_info[i].flash_id = FLASH_UNKNOWN;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 4th 64 KB */
|
||||
if (j == 3)
|
||||
{
|
||||
flash_info[i].start[j] = flashbase + 0x10000;
|
||||
|
||||
for (j = 0; j < flash_info[i].sector_count; j++) {
|
||||
flash_info[i].start[j] = flashbase + j * sectsize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flash_info[i].start[j] = flashbase + (j - 3)*MAIN_SECT_SIZE;
|
||||
}
|
||||
size += flash_info[i].size;
|
||||
|
||||
flash_protect(FLAG_PROTECT_CLEAR,
|
||||
flash_info[i].start[0],
|
||||
flash_info[i].start[0] + flash_info[i].size - 1,
|
||||
&flash_info[i]);
|
||||
}
|
||||
size += flash_info[i].size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Protect monitor and environment sectors
|
||||
*/
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
i386boot_start-CFG_FLASH_BASE,
|
||||
i386boot_end-CFG_FLASH_BASE,
|
||||
&flash_info[0]);
|
||||
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
CFG_ENV_ADDR,
|
||||
CFG_ENV_ADDR + CFG_ENV_SIZE - 1,
|
||||
&flash_info[0]);
|
||||
return size;
|
||||
|
||||
/*
|
||||
* Protect monitor and environment sectors
|
||||
*/
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
i386boot_start,
|
||||
i386boot_end,
|
||||
&flash_info[0]);
|
||||
#ifdef CFG_ENV_ADDR
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
CFG_ENV_ADDR,
|
||||
CFG_ENV_ADDR + CFG_ENV_SIZE - 1,
|
||||
&flash_info[0]);
|
||||
#endif
|
||||
return size;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
void flash_print_info (flash_info_t *info)
|
||||
void flash_print_info(flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (info->flash_id & FLASH_VENDMASK)
|
||||
{
|
||||
case (AMD_MANUFACT & FLASH_VENDMASK):
|
||||
printf("AMD: ");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Vendor ");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (info->flash_id & FLASH_TYPEMASK)
|
||||
{
|
||||
case (AMD_ID_LV160B & FLASH_TYPEMASK):
|
||||
printf("2x Amd29F160BB (16Mbit)\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Chip Type\n");
|
||||
goto Done;
|
||||
break;
|
||||
}
|
||||
|
||||
printf(" Size: %ld MB in %d Sectors\n",
|
||||
info->size >> 20, info->sector_count);
|
||||
|
||||
printf(" Sector Start Addresses:");
|
||||
for (i = 0; i < info->sector_count; i++)
|
||||
{
|
||||
if ((i % 5) == 0)
|
||||
{
|
||||
printf ("\n ");
|
||||
int i;
|
||||
|
||||
switch (info->flash_id & FLASH_VENDMASK) {
|
||||
|
||||
case (AMD_MANUFACT & FLASH_VENDMASK):
|
||||
printf("AMD: ");
|
||||
switch (info->flash_id & FLASH_TYPEMASK) {
|
||||
case (AMD_ID_LV016B & FLASH_TYPEMASK):
|
||||
printf("4x AMD29LV017B (4x16Mbit)\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Chip Type\n");
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Vendor ");
|
||||
break;
|
||||
}
|
||||
printf (" %08lX%s", info->start[i],
|
||||
info->protect[i] ? " (RO)" : " ");
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
Done:
|
||||
|
||||
|
||||
printf(" Size: %ld MB in %d Sectors\n",
|
||||
info->size >> 20, info->sector_count);
|
||||
|
||||
printf(" Sector Start Addresses:");
|
||||
for (i = 0; i < info->sector_count; i++) {
|
||||
if ((i % 5) == 0) {
|
||||
printf ("\n ");
|
||||
}
|
||||
printf (" %08lX%s", info->start[i],
|
||||
info->protect[i] ? " (RO)" : " ");
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
done:
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int flash_erase (flash_info_t *info, int s_first, int s_last)
|
||||
/* this needs to be inlined, the SWTMRMMILLI register is reset by each read */
|
||||
#define __udelay(delay) \
|
||||
{ \
|
||||
unsigned micro; \
|
||||
unsigned milli=0; \
|
||||
\
|
||||
micro = *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); \
|
||||
\
|
||||
for (;;) { \
|
||||
\
|
||||
milli += *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); \
|
||||
micro = *(volatile u16*)(0xfffef000+SC520_SWTMRMICRO); \
|
||||
\
|
||||
if ((delay) <= (micro + (milli * 1000))) { \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static u32 _amd_erase_flash(u32 addr, u32 sector)
|
||||
{
|
||||
ulong result;
|
||||
int iflag, prot, sect;
|
||||
int rc = ERR_OK;
|
||||
int chip1, chip2;
|
||||
|
||||
/* first look for protection bits */
|
||||
|
||||
if (info->flash_id == FLASH_UNKNOWN)
|
||||
return ERR_UNKNOWN_FLASH_TYPE;
|
||||
|
||||
if ((s_first < 0) || (s_first > s_last)) {
|
||||
return ERR_INVAL;
|
||||
}
|
||||
|
||||
if ((info->flash_id & FLASH_VENDMASK) !=
|
||||
(AMD_MANUFACT & FLASH_VENDMASK)) {
|
||||
return ERR_UNKNOWN_FLASH_VENDOR;
|
||||
}
|
||||
|
||||
prot = 0;
|
||||
for (sect=s_first; sect<=s_last; ++sect) {
|
||||
if (info->protect[sect]) {
|
||||
prot++;
|
||||
}
|
||||
}
|
||||
if (prot)
|
||||
return ERR_PROTECTED;
|
||||
|
||||
/*
|
||||
* Disable interrupts which might cause a timeout
|
||||
* here. Remember that our exception vectors are
|
||||
* at address 0 in the flash, and we don't want a
|
||||
* (ticker) exception to happen while the flash
|
||||
* chip is in programming mode.
|
||||
*/
|
||||
iflag = disable_interrupts();
|
||||
|
||||
/* Start erase on unprotected sectors */
|
||||
for (sect = s_first; sect<=s_last && !ctrlc(); sect++)
|
||||
{
|
||||
printf("Erasing sector %2d ... ", sect);
|
||||
|
||||
/* arm simple, non interrupt dependent timer */
|
||||
reset_timer();
|
||||
|
||||
if (info->protect[sect] == 0)
|
||||
{ /* not protected */
|
||||
vu_long *addr = (vu_long *)(info->start[sect]);
|
||||
|
||||
MEM_FLASH_ADDR1 = CMD_UNLOCK1;
|
||||
MEM_FLASH_ADDR2 = CMD_UNLOCK2;
|
||||
MEM_FLASH_ADDR1 = CMD_ERASE_SETUP;
|
||||
|
||||
MEM_FLASH_ADDR1 = CMD_UNLOCK1;
|
||||
MEM_FLASH_ADDR2 = CMD_UNLOCK2;
|
||||
*addr = CMD_ERASE_CONFIRM;
|
||||
|
||||
/* wait until flash is ready */
|
||||
chip1 = chip2 = 0;
|
||||
|
||||
do
|
||||
{
|
||||
result = *addr;
|
||||
|
||||
/* check timeout */
|
||||
if (get_timer(0) > CFG_FLASH_ERASE_TOUT)
|
||||
{
|
||||
MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
|
||||
chip1 = TMO;
|
||||
break;
|
||||
unsigned elapsed;
|
||||
|
||||
/* Issue erase */
|
||||
*(volatile u32*)(addr + 0x5554) = 0xAAAAAAAA;
|
||||
*(volatile u32*)(addr + 0xaaa8) = 0x55555555;
|
||||
*(volatile u32*)(addr + 0x5554) = 0x80808080;
|
||||
/* And one unlock */
|
||||
*(volatile u32*)(addr + 0x5554) = 0xAAAAAAAA;
|
||||
*(volatile u32*)(addr + 0xaaa8) = 0x55555555;
|
||||
/* Sector erase command comes last */
|
||||
*(volatile u32*)(addr + sector) = 0x30303030;
|
||||
|
||||
elapsed = *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); /* dummy read */
|
||||
elapsed = 0;
|
||||
__udelay(50);
|
||||
while (((*(volatile u32*)(addr + sector)) & 0x80808080) != 0x80808080) {
|
||||
|
||||
elapsed += *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI);
|
||||
if (elapsed > ((CFG_FLASH_ERASE_TOUT/CFG_HZ) * 1000)) {
|
||||
*(volatile u32*)(addr) = 0xf0f0f0f0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!chip1 && (result & 0xFFFF) & BIT_ERASE_DONE)
|
||||
chip1 = READY;
|
||||
|
||||
if (!chip1 && (result & 0xFFFF) & BIT_PROGRAM_ERROR)
|
||||
chip1 = ERR;
|
||||
|
||||
if (!chip2 && (result >> 16) & BIT_ERASE_DONE)
|
||||
chip2 = READY;
|
||||
|
||||
if (!chip2 && (result >> 16) & BIT_PROGRAM_ERROR)
|
||||
chip2 = ERR;
|
||||
|
||||
} while (!chip1 || !chip2);
|
||||
|
||||
MEM_FLASH_ADDR1 = CMD_READ_ARRAY;
|
||||
|
||||
if (chip1 == ERR || chip2 == ERR)
|
||||
{
|
||||
rc = ERR_PROG_ERROR;
|
||||
goto outahere;
|
||||
}
|
||||
if (chip1 == TMO)
|
||||
{
|
||||
rc = ERR_TIMOUT;
|
||||
goto outahere;
|
||||
}
|
||||
|
||||
printf("ok.\n");
|
||||
}
|
||||
else /* it was protected */
|
||||
{
|
||||
printf("protected!\n");
|
||||
|
||||
*(volatile u32*)(addr) = 0xf0f0f0f0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int _amd_erase_flash_end;
|
||||
asm ("_amd_erase_flash_end:\n"
|
||||
".long 0\n");
|
||||
|
||||
int flash_erase(flash_info_t *info, int s_first, int s_last)
|
||||
{
|
||||
u32 (*_erase_flash_ptr)(u32 a, u32 so);
|
||||
int prot;
|
||||
int sect;
|
||||
unsigned size;
|
||||
|
||||
if ((s_first < 0) || (s_first > s_last)) {
|
||||
if (info->flash_id == FLASH_UNKNOWN) {
|
||||
printf("- missing\n");
|
||||
} else {
|
||||
printf("- no sectors to erase\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((info->flash_id & FLASH_VENDMASK) == (AMD_MANUFACT & FLASH_VENDMASK)) {
|
||||
size = (unsigned)&_amd_erase_flash_end - (unsigned)_amd_erase_flash;
|
||||
|
||||
if (size > PROBE_BUFFER_SIZE) {
|
||||
printf("_amd_erase_flash() routine too large (%d) %p - %p\n",
|
||||
size, &_amd_erase_flash_end, _amd_erase_flash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, _amd_erase_flash, size);
|
||||
_erase_flash_ptr = (void*)buffer;
|
||||
|
||||
} else {
|
||||
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]) {
|
||||
prot++;
|
||||
}
|
||||
}
|
||||
|
||||
if (prot) {
|
||||
printf ("- Warning: %d protected sectors will not be erased!\n", prot);
|
||||
} else {
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
|
||||
/* Start erase on unprotected sectors */
|
||||
for (sect = s_first; sect<=s_last; sect++) {
|
||||
|
||||
if (info->protect[sect] == 0) { /* not protected */
|
||||
int res;
|
||||
int flag;
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
res = _erase_flash_ptr(info->start[0], info->start[sect]-info->start[0]);
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
|
||||
|
||||
if (res) {
|
||||
printf("Erase timed out, sector %d\n", sect);
|
||||
return res;
|
||||
}
|
||||
|
||||
putc('.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ctrlc())
|
||||
printf("User Interrupt!\n");
|
||||
|
||||
outahere:
|
||||
/* allow flash to settle - wait 10 ms */
|
||||
udelay(10000);
|
||||
|
||||
if (iflag)
|
||||
enable_interrupts();
|
||||
|
||||
|
||||
return rc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Copy memory to flash
|
||||
* Write a word to Flash, returns:
|
||||
* 0 - OK
|
||||
* 1 - write timeout
|
||||
* 2 - Flash not erased
|
||||
*/
|
||||
|
||||
volatile static int write_word (flash_info_t *info, ulong dest, ulong data)
|
||||
static int _amd_write_word(unsigned start, unsigned dest, unsigned data)
|
||||
{
|
||||
vu_long *addr = (vu_long *)dest;
|
||||
ulong result;
|
||||
int rc = ERR_OK;
|
||||
int iflag;
|
||||
int chip1, chip2;
|
||||
|
||||
/*
|
||||
* Check if Flash is (sufficiently) erased
|
||||
*/
|
||||
result = *addr;
|
||||
if ((result & data) != data)
|
||||
return ERR_NOT_ERASED;
|
||||
|
||||
|
||||
/*
|
||||
* Disable interrupts which might cause a timeout
|
||||
* here. Remember that our exception vectors are
|
||||
* at address 0 in the flash, and we don't want a
|
||||
* (ticker) exception to happen while the flash
|
||||
* chip is in programming mode.
|
||||
*/
|
||||
iflag = disable_interrupts();
|
||||
|
||||
MEM_FLASH_ADDR1 = CMD_UNLOCK1;
|
||||
MEM_FLASH_ADDR2 = CMD_UNLOCK2;
|
||||
MEM_FLASH_ADDR1 = CMD_UNLOCK_BYPASS;
|
||||
*addr = CMD_PROGRAM;
|
||||
*addr = data;
|
||||
|
||||
/* arm simple, non interrupt dependent timer */
|
||||
reset_timer();
|
||||
|
||||
/* wait until flash is ready */
|
||||
chip1 = chip2 = 0;
|
||||
do
|
||||
{
|
||||
result = *addr;
|
||||
|
||||
/* check timeout */
|
||||
if (get_timer(0) > CFG_FLASH_ERASE_TOUT)
|
||||
{
|
||||
chip1 = ERR | TMO;
|
||||
break;
|
||||
volatile u32 *addr2 = (u32*)start;
|
||||
volatile u32 *dest2 = (u32*)dest;
|
||||
volatile u32 *data2 = (u32*)&data;
|
||||
unsigned elapsed;
|
||||
|
||||
/* Check if Flash is (sufficiently) erased */
|
||||
if ((*((volatile u32*)dest) & (u32)data) != (u32)data) {
|
||||
return 2;
|
||||
}
|
||||
if (!chip1 && ((result & 0x80) == (data & 0x80)))
|
||||
chip1 = READY;
|
||||
|
||||
if (!chip1 && ((result & 0xFFFF) & BIT_PROGRAM_ERROR))
|
||||
{
|
||||
result = *addr;
|
||||
|
||||
if ((result & 0x80) == (data & 0x80))
|
||||
chip1 = READY;
|
||||
else
|
||||
chip1 = ERR;
|
||||
|
||||
addr2[0x5554] = 0xAAAAAAAA;
|
||||
addr2[0xaaa8] = 0x55555555;
|
||||
addr2[0x5554] = 0xA0A0A0A0;
|
||||
|
||||
dest2[0] = data;
|
||||
|
||||
elapsed = *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); /* dummy read */
|
||||
elapsed = 0;
|
||||
|
||||
/* data polling for D7 */
|
||||
while ((dest2[0] & 0x80808080) != (data2[0] & 0x80808080)) {
|
||||
elapsed += *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI);
|
||||
if (elapsed > ((CFG_FLASH_WRITE_TOUT/CFG_HZ) * 1000)) {
|
||||
addr2[0] = 0xf0f0f0f0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!chip2 && ((result & (0x80 << 16)) == (data & (0x80 << 16))))
|
||||
chip2 = READY;
|
||||
|
||||
if (!chip2 && ((result >> 16) & BIT_PROGRAM_ERROR))
|
||||
{
|
||||
result = *addr;
|
||||
|
||||
if ((result & (0x80 << 16)) == (data & (0x80 << 16)))
|
||||
chip2 = READY;
|
||||
else
|
||||
chip2 = ERR;
|
||||
}
|
||||
|
||||
} while (!chip1 || !chip2);
|
||||
|
||||
*addr = CMD_READ_ARRAY;
|
||||
|
||||
if (chip1 == ERR || chip2 == ERR || *addr != data)
|
||||
rc = ERR_PROG_ERROR;
|
||||
|
||||
if (iflag)
|
||||
enable_interrupts();
|
||||
|
||||
|
||||
return rc;
|
||||
|
||||
addr2[0] = 0xf0f0f0f0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int _amd_write_word_end;
|
||||
asm ("_amd_write_word_end:\n"
|
||||
".long 0\n");
|
||||
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Copy memory to flash.
|
||||
* Copy memory to flash, returns:
|
||||
* 0 - OK
|
||||
* 1 - write timeout
|
||||
* 2 - Flash not erased
|
||||
* 3 - Unsupported flash type
|
||||
*/
|
||||
|
||||
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 l;
|
||||
int i, rc;
|
||||
ulong cp, wp, data;
|
||||
int i, l, rc;
|
||||
int flag;
|
||||
u32 (*_write_word_ptr)(unsigned start, unsigned dest, unsigned data);
|
||||
unsigned size;
|
||||
|
||||
if ((info->flash_id & FLASH_VENDMASK) == (AMD_MANUFACT & FLASH_VENDMASK)) {
|
||||
size = (unsigned)&_amd_write_word_end - (unsigned)_amd_write_word;
|
||||
|
||||
if (size > PROBE_BUFFER_SIZE) {
|
||||
printf("_amd_write_word() routine too large (%d) %p - %p\n",
|
||||
size, &_amd_write_word_end, _amd_write_word);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, _amd_write_word, size);
|
||||
_write_word_ptr = (void*)buffer;
|
||||
|
||||
} else {
|
||||
printf ("Can't program unknown flash type - aborted\n");
|
||||
return 3;
|
||||
}
|
||||
|
||||
wp = (addr & ~3); /* get lower word aligned address */
|
||||
|
||||
/*
|
||||
* handle unaligned start bytes
|
||||
*/
|
||||
if ((l = addr - wp) != 0) {
|
||||
wp = (addr & ~3); /* get lower word aligned address */
|
||||
|
||||
|
||||
/*
|
||||
* handle unaligned start bytes
|
||||
*/
|
||||
if ((l = addr - wp) != 0) {
|
||||
data = 0;
|
||||
for (i=0, cp=wp; i<l; ++i, ++cp) {
|
||||
data |= (*(uchar *)cp) << (8*i);
|
||||
}
|
||||
for (; i<4 && cnt>0; ++i) {
|
||||
data |= *src++ << (8*i);
|
||||
--cnt;
|
||||
++cp;
|
||||
}
|
||||
for (; cnt==0 && i<4; ++i, ++cp) {
|
||||
data |= (*(uchar *)cp) << (8*i);
|
||||
}
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
rc = _write_word_ptr(info->start[0], wp, data);
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle word aligned part
|
||||
*/
|
||||
while (cnt >= 4) {
|
||||
data = 0;
|
||||
|
||||
for (i=0; i<4; ++i) {
|
||||
data |= *src++ << (8*i);
|
||||
}
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
rc = _write_word_ptr(info->start[0], wp, data);
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
wp += 4;
|
||||
cnt -= 4;
|
||||
}
|
||||
|
||||
if (cnt == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle unaligned tail bytes
|
||||
*/
|
||||
data = 0;
|
||||
for (i=0, cp=wp; i<l; ++i, ++cp) {
|
||||
data = (data >> 8) | (*(uchar *)cp << 24);
|
||||
for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
|
||||
data |= *src++ << (8*i);
|
||||
--cnt;
|
||||
}
|
||||
for (; i<4 && cnt>0; ++i) {
|
||||
data = (data >> 8) | (*src++ << 24);
|
||||
--cnt;
|
||||
++cp;
|
||||
}
|
||||
for (; cnt==0 && i<4; ++i, ++cp) {
|
||||
data = (data >> 8) | (*(uchar *)cp << 24);
|
||||
|
||||
for (; i<4; ++i, ++cp) {
|
||||
data |= (*(uchar *)cp) << (8*i);
|
||||
}
|
||||
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
rc = _write_word_ptr(info->start[0], wp, data);
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle word aligned part
|
||||
*/
|
||||
while (cnt >= 4) {
|
||||
data = *((vu_long*)src);
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
}
|
||||
src += 4;
|
||||
wp += 4;
|
||||
cnt -= 4;
|
||||
}
|
||||
|
||||
if (cnt == 0) {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle unaligned tail bytes
|
||||
*/
|
||||
data = 0;
|
||||
for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
|
||||
data = (data >> 8) | (*src++ << 24);
|
||||
--cnt;
|
||||
}
|
||||
for (; i<4; ++i, ++cp) {
|
||||
data = (data >> 8) | (*(uchar *)cp << 24);
|
||||
}
|
||||
|
||||
return write_word(info, wp, data);
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* (C) Copyright 2002
|
||||
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
||||
* Alex Zuepke <azu@sysgo.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
ulong myflush(void);
|
||||
|
||||
|
||||
#define SC520_MAX_FLASH_BANKS 3
|
||||
#define SC520_FLASH_BANK0_BASE 0x38000000 /* BOOTCS */
|
||||
#define SC520_FLASH_BANK1_BASE 0x30000000 /* ROMCS0 */
|
||||
#define SC520_FLASH_BANK2_BASE 0x28000000 /* ROMCS1 */
|
||||
#define SC520_FLASH_BANKSIZE 0x8000000
|
||||
|
||||
#define AMD29LV016_SIZE 0x200000
|
||||
#define AMD29LV016_SECTORS 32
|
||||
|
||||
flash_info_t flash_info[SC520_MAX_FLASH_BANKS];
|
||||
|
||||
#define CMD_READ_ARRAY 0x00F000F0
|
||||
#define CMD_UNLOCK1 0x00AA00AA
|
||||
#define CMD_UNLOCK2 0x00550055
|
||||
#define CMD_ERASE_SETUP 0x00800080
|
||||
#define CMD_ERASE_CONFIRM 0x00300030
|
||||
#define CMD_PROGRAM 0x00A000A0
|
||||
#define CMD_UNLOCK_BYPASS 0x00200020
|
||||
|
||||
|
||||
#define BIT_ERASE_DONE 0x00800080
|
||||
#define BIT_RDY_MASK 0x00800080
|
||||
#define BIT_PROGRAM_ERROR 0x00200020
|
||||
#define BIT_TIMEOUT 0x80000000 /* our flag */
|
||||
|
||||
#define READY 1
|
||||
#define ERR 2
|
||||
#define TMO 4
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
ulong flash_init(void)
|
||||
{
|
||||
int i, j;
|
||||
ulong size = 0;
|
||||
|
||||
for (i = 0; i < SC520_MAX_FLASH_BANKS; i++) {
|
||||
ulong flashbase = 0;
|
||||
int sectsize = 0;
|
||||
if (i==0 || i==2) {
|
||||
/* FixMe: this assumes that bank 0 and 2
|
||||
* are mapped to the two 8Mb banks */
|
||||
flash_info[i].flash_id =
|
||||
(AMD_MANUFACT & FLASH_VENDMASK) |
|
||||
(AMD_ID_LV016B & FLASH_TYPEMASK);
|
||||
|
||||
flash_info[i].size = AMD29LV016_SIZE*4;
|
||||
flash_info[i].sector_count = AMD29LV016_SECTORS;
|
||||
sectsize = (AMD29LV016_SIZE*4)/AMD29LV016_SECTORS;
|
||||
} else {
|
||||
/* FixMe: this assumes that bank1 is unmapped
|
||||
* (or mapped to the same flash bank as BOOTCS) */
|
||||
flash_info[i].flash_id = 0;
|
||||
flash_info[i].size = 0;
|
||||
flash_info[i].sector_count = 0;
|
||||
sectsize=0;
|
||||
}
|
||||
memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
|
||||
switch (i) {
|
||||
case 0:
|
||||
flashbase = SC520_FLASH_BANK0_BASE;
|
||||
break;
|
||||
case 1:
|
||||
flashbase = SC520_FLASH_BANK1_BASE;
|
||||
break;
|
||||
case 2:
|
||||
flashbase = SC520_FLASH_BANK0_BASE;
|
||||
break;
|
||||
default:
|
||||
panic("configured to many flash banks!\n");
|
||||
}
|
||||
|
||||
for (j = 0; j < flash_info[i].sector_count; j++) {
|
||||
flash_info[i].start[j] = sectsize;
|
||||
flash_info[i].start[j] = flashbase + j * sectsize;
|
||||
}
|
||||
size += flash_info[i].size;
|
||||
}
|
||||
|
||||
/*
|
||||
* Protect monitor and environment sectors
|
||||
*/
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
i386boot_start-SC520_FLASH_BANK0_BASE,
|
||||
i386boot_end-SC520_FLASH_BANK0_BASE,
|
||||
&flash_info[0]);
|
||||
|
||||
#ifdef CFG_ENV_ADDR
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
CFG_ENV_ADDR,
|
||||
CFG_ENV_ADDR + CFG_ENV_SIZE - 1,
|
||||
&flash_info[0]);
|
||||
#endif
|
||||
return size;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
void flash_print_info(flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (info->flash_id & FLASH_VENDMASK) {
|
||||
case (AMD_MANUFACT & FLASH_VENDMASK):
|
||||
printf("AMD: ");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Vendor ");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (info->flash_id & FLASH_TYPEMASK) {
|
||||
case (AMD_ID_LV016B & FLASH_TYPEMASK):
|
||||
printf("4x Amd29LV016B (16Mbit)\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Chip Type\n");
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
|
||||
printf(" Size: %ld MB in %d Sectors\n",
|
||||
info->size >> 20, info->sector_count);
|
||||
|
||||
printf(" Sector Start Addresses:");
|
||||
for (i = 0; i < info->sector_count; i++) {
|
||||
if ((i % 5) == 0) {
|
||||
printf ("\n ");
|
||||
}
|
||||
printf (" %08lX%s", info->start[i],
|
||||
info->protect[i] ? " (RO)" : " ");
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
done:
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int flash_erase(flash_info_t *info, int s_first, int s_last)
|
||||
{
|
||||
ulong result;
|
||||
int iflag, prot, sect;
|
||||
int rc = ERR_OK;
|
||||
int chip1, chip2;
|
||||
|
||||
/* first look for protection bits */
|
||||
|
||||
if (info->flash_id == FLASH_UNKNOWN) {
|
||||
return ERR_UNKNOWN_FLASH_TYPE;
|
||||
}
|
||||
|
||||
if ((s_first < 0) || (s_first > s_last)) {
|
||||
return ERR_INVAL;
|
||||
}
|
||||
|
||||
if ((info->flash_id & FLASH_VENDMASK) !=
|
||||
(AMD_MANUFACT & FLASH_VENDMASK)) {
|
||||
return ERR_UNKNOWN_FLASH_VENDOR;
|
||||
}
|
||||
|
||||
prot = 0;
|
||||
for (sect=s_first; sect<=s_last; ++sect) {
|
||||
if (info->protect[sect]) {
|
||||
prot++;
|
||||
}
|
||||
}
|
||||
if (prot) {
|
||||
return ERR_PROTECTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable interrupts which might cause a timeout
|
||||
* here. Remember that our exception vectors are
|
||||
* at address 0 in the flash, and we don't want a
|
||||
* (ticker) exception to happen while the flash
|
||||
* chip is in programming mode.
|
||||
*/
|
||||
iflag = disable_interrupts();
|
||||
|
||||
/* Start erase on unprotected sectors */
|
||||
for (sect = s_first; sect<=s_last && !ctrlc(); sect++) {
|
||||
printf("Erasing sector %2d ... ", sect);
|
||||
|
||||
/* arm simple, non interrupt dependent timer */
|
||||
reset_timer();
|
||||
|
||||
if (info->protect[sect] == 0) {
|
||||
/* not protected */
|
||||
ulong addr = info->start[sect];
|
||||
|
||||
writel(CMD_UNLOCK1, addr + 1);
|
||||
writel(CMD_UNLOCK2, addr + 2);
|
||||
writel(CMD_ERASE_SETUP, addr + 1);
|
||||
|
||||
writel(CMD_UNLOCK1, addr + 1);
|
||||
writel(CMD_UNLOCK2, addr + 2);
|
||||
writel(CMD_ERASE_CONFIRM, addr);
|
||||
|
||||
|
||||
/* wait until flash is ready */
|
||||
chip1 = chip2 = 0;
|
||||
|
||||
do {
|
||||
result = readl(addr);
|
||||
|
||||
/* check timeout */
|
||||
if (get_timer(0) > CFG_FLASH_ERASE_TOUT) {
|
||||
writel(CMD_READ_ARRAY, addr + 1);
|
||||
chip1 = TMO;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!chip1 && (result & 0xFFFF) & BIT_ERASE_DONE) {
|
||||
chip1 = READY;
|
||||
}
|
||||
|
||||
if (!chip1 && (result & 0xFFFF) & BIT_PROGRAM_ERROR) {
|
||||
chip1 = ERR;
|
||||
}
|
||||
|
||||
if (!chip2 && (result >> 16) & BIT_ERASE_DONE) {
|
||||
chip2 = READY;
|
||||
}
|
||||
|
||||
if (!chip2 && (result >> 16) & BIT_PROGRAM_ERROR) {
|
||||
chip2 = ERR;
|
||||
}
|
||||
|
||||
} while (!chip1 || !chip2);
|
||||
|
||||
writel(CMD_READ_ARRAY, addr + 1);
|
||||
|
||||
if (chip1 == ERR || chip2 == ERR) {
|
||||
rc = ERR_PROG_ERROR;
|
||||
goto outahere;
|
||||
}
|
||||
|
||||
if (chip1 == TMO) {
|
||||
rc = ERR_TIMOUT;
|
||||
goto outahere;
|
||||
}
|
||||
|
||||
printf("ok.\n");
|
||||
} else { /* it was protected */
|
||||
|
||||
printf("protected!\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (ctrlc()) {
|
||||
printf("User Interrupt!\n");
|
||||
}
|
||||
|
||||
outahere:
|
||||
/* allow flash to settle - wait 10 ms */
|
||||
udelay(10000);
|
||||
|
||||
if (iflag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Copy memory to flash
|
||||
*/
|
||||
|
||||
volatile static int write_word(flash_info_t *info, ulong dest, ulong data)
|
||||
{
|
||||
ulong addr = dest;
|
||||
ulong result;
|
||||
int rc = ERR_OK;
|
||||
int iflag;
|
||||
int chip1, chip2;
|
||||
|
||||
/*
|
||||
* Check if Flash is (sufficiently) erased
|
||||
*/
|
||||
result = readl(addr);
|
||||
if ((result & data) != data) {
|
||||
return ERR_NOT_ERASED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable interrupts which might cause a timeout
|
||||
* here. Remember that our exception vectors are
|
||||
* at address 0 in the flash, and we don't want a
|
||||
* (ticker) exception to happen while the flash
|
||||
* chip is in programming mode.
|
||||
*/
|
||||
iflag = disable_interrupts();
|
||||
|
||||
writel(CMD_UNLOCK1, addr + 1);
|
||||
writel(CMD_UNLOCK2, addr + 2);
|
||||
writel(CMD_UNLOCK_BYPASS, addr + 1);
|
||||
writel(addr, CMD_PROGRAM);
|
||||
writel(addr, data);
|
||||
|
||||
/* arm simple, non interrupt dependent timer */
|
||||
reset_timer();
|
||||
|
||||
/* wait until flash is ready */
|
||||
chip1 = chip2 = 0;
|
||||
do {
|
||||
result = readl(addr);
|
||||
|
||||
/* check timeout */
|
||||
if (get_timer(0) > CFG_FLASH_ERASE_TOUT) {
|
||||
chip1 = ERR | TMO;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!chip1 && ((result & 0x80) == (data & 0x80))) {
|
||||
chip1 = READY;
|
||||
}
|
||||
|
||||
if (!chip1 && ((result & 0xFFFF) & BIT_PROGRAM_ERROR)) {
|
||||
result = readl(addr);
|
||||
|
||||
if ((result & 0x80) == (data & 0x80)) {
|
||||
chip1 = READY;
|
||||
} else {
|
||||
chip1 = ERR;
|
||||
}
|
||||
}
|
||||
|
||||
if (!chip2 && ((result & (0x80 << 16)) == (data & (0x80 << 16)))) {
|
||||
chip2 = READY;
|
||||
}
|
||||
|
||||
if (!chip2 && ((result >> 16) & BIT_PROGRAM_ERROR)) {
|
||||
result = readl(addr);
|
||||
|
||||
if ((result & (0x80 << 16)) == (data & (0x80 << 16))) {
|
||||
chip2 = READY;
|
||||
} else {
|
||||
chip2 = ERR;
|
||||
}
|
||||
}
|
||||
|
||||
} while (!chip1 || !chip2);
|
||||
|
||||
writel(CMD_READ_ARRAY, addr);
|
||||
|
||||
if (chip1 == ERR || chip2 == ERR || readl(addr) != data) {
|
||||
rc = ERR_PROG_ERROR;
|
||||
}
|
||||
|
||||
if (iflag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Copy memory to flash.
|
||||
*/
|
||||
|
||||
int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
|
||||
{
|
||||
ulong cp, wp, data;
|
||||
int l;
|
||||
int i, rc;
|
||||
|
||||
wp = (addr & ~3); /* get lower word aligned address */
|
||||
|
||||
/*
|
||||
* handle unaligned start bytes
|
||||
*/
|
||||
if ((l = addr - wp) != 0) {
|
||||
data = 0;
|
||||
for (i=0, cp=wp; i<l; ++i, ++cp) {
|
||||
data = (data >> 8) | (*(uchar *)cp << 24);
|
||||
}
|
||||
for (; i<4 && cnt>0; ++i) {
|
||||
data = (data >> 8) | (*src++ << 24);
|
||||
--cnt;
|
||||
++cp;
|
||||
}
|
||||
for (; cnt==0 && i<4; ++i, ++cp) {
|
||||
data = (data >> 8) | (*(uchar *)cp << 24);
|
||||
}
|
||||
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return rc;
|
||||
}
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle word aligned part
|
||||
*/
|
||||
while (cnt >= 4) {
|
||||
data = *((vu_long*)src);
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return rc;
|
||||
}
|
||||
src += 4;
|
||||
wp += 4;
|
||||
cnt -= 4;
|
||||
}
|
||||
|
||||
if (cnt == 0) {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle unaligned tail bytes
|
||||
*/
|
||||
data = 0;
|
||||
for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
|
||||
data = (data >> 8) | (*src++ << 24);
|
||||
--cnt;
|
||||
}
|
||||
for (; i<4; ++i, ++cp) {
|
||||
data = (data >> 8) | (*(uchar *)cp << 24);
|
||||
}
|
||||
|
||||
return write_word(info, wp, data);
|
||||
}
|
||||
+390
-65
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
|
||||
*
|
||||
@@ -24,109 +25,162 @@
|
||||
#include <common.h>
|
||||
#include <pci.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/pci.h>
|
||||
#include <asm/ic/sc520.h>
|
||||
#include <asm/ic/ali512x.h>
|
||||
#include <ssi.h>
|
||||
|
||||
#undef SC520_CDP_DEBUG
|
||||
|
||||
#ifdef SC520_CDP_DEBUG
|
||||
#define PRINTF(fmt,args...) printf (fmt ,##args)
|
||||
#else
|
||||
#define PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
* Theory:
|
||||
* We first set up all IRQs to be non-pci, edge triggered,
|
||||
* when we later enumerate the pci bus and pci_sc520_fixup_irq() gets
|
||||
* called we reallocate irqs to the pci bus with sc520_pci_set_irq()
|
||||
* as needed. Whe choose the irqs to gram from a configurable list
|
||||
* inside pci_sc520_fixup_irq() (If this list contains stupid irq's
|
||||
* such as 0 thngas will not work)
|
||||
*/
|
||||
|
||||
static void irq_init(void)
|
||||
{
|
||||
|
||||
/* disable global interrupt mode */
|
||||
write_mmcr_byte(SC520_PICICR, 0x40);
|
||||
|
||||
/* set irq0-7 to edge */
|
||||
/* set all irqs to edge */
|
||||
write_mmcr_byte(SC520_MPICMODE, 0x00);
|
||||
|
||||
/* set irq9-12 to level, all the other (8, 13-15) are edge */
|
||||
write_mmcr_byte(SC520_SL1PICMODE, 0x1e);
|
||||
|
||||
/* set irq16-24 (unused slave pic2) to level */
|
||||
write_mmcr_byte(SC520_SL2PICMODE, 0xff);
|
||||
write_mmcr_byte(SC520_SL1PICMODE, 0x00);
|
||||
write_mmcr_byte(SC520_SL2PICMODE, 0x00);
|
||||
|
||||
/* active low polarity on PIC interrupt pins,
|
||||
active high polarity on all other irq pins */
|
||||
write_mmcr_word(SC520_INTPINPOL, 0);
|
||||
* active high polarity on all other irq pins */
|
||||
write_mmcr_word(SC520_INTPINPOL, 0x0000);
|
||||
|
||||
/* set irq number mapping */
|
||||
write_mmcr_byte(SC520_GPTMR0MAP,0); /* disable GP timer 0 INT */
|
||||
write_mmcr_byte(SC520_GPTMR1MAP,0); /* disable GP timer 1 INT */
|
||||
write_mmcr_byte(SC520_GPTMR2MAP,0); /* disable GP timer 2 INT */
|
||||
write_mmcr_byte(SC520_PIT0MAP,0x1); /* Set PIT timer 0 INT to IRQ0 */
|
||||
write_mmcr_byte(SC520_PIT1MAP,0); /* diable PIT timer 1 INT */
|
||||
write_mmcr_byte(SC520_PIT2MAP,0); /* diable PIT timer 2 INT */
|
||||
write_mmcr_byte(SC520_PCIINTAMAP,0x4); /* Set PCI INT A to IRQ9 */
|
||||
write_mmcr_byte(SC520_PCIINTBMAP,0x5); /* Set PCI INT B to IRQ10 */
|
||||
write_mmcr_byte(SC520_PCIINTCMAP,0x6); /* Set PCI INT C to IRQ11 */
|
||||
write_mmcr_byte(SC520_PCIINTDMAP,0x7); /* Set PCI INT D to IRQ12 */
|
||||
write_mmcr_byte(SC520_DMABCINTMAP,0); /* disable DMA INT */
|
||||
write_mmcr_byte(SC520_SSIMAP,0); /* disable Synchronius serial INT */
|
||||
write_mmcr_byte(SC520_WDTMAP,0); /* disable Watchdor INT */
|
||||
write_mmcr_byte(SC520_RTCMAP,0x3); /* Set RTC int to 8 */
|
||||
write_mmcr_byte(SC520_WPVMAP,0); /* disable write protect INT */
|
||||
write_mmcr_byte(SC520_ICEMAP,0x2); /* Set ICE Debug Serielport INT to IRQ1 */
|
||||
write_mmcr_byte(SC520_FERRMAP,0x8); /* Set FP error INT to IRQ13 */
|
||||
write_mmcr_byte(SC520_GP0IMAP,6); /* Set GPIRQ0 (ISA IRQ2) to IRQ9 */
|
||||
write_mmcr_byte(SC520_GP1IMAP,2); /* Set GPIRQ1 (SIO IRQ1) to IRQ1 */
|
||||
write_mmcr_byte(SC520_GP2IMAP,7); /* Set GPIRQ2 (ISA IRQ12) to IRQ12 */
|
||||
write_mmcr_byte(SC520_GPTMR0MAP, SC520_IRQ_DISABLED); /* disable GP timer 0 INT */
|
||||
write_mmcr_byte(SC520_GPTMR1MAP, SC520_IRQ_DISABLED); /* disable GP timer 1 INT */
|
||||
write_mmcr_byte(SC520_GPTMR2MAP, SC520_IRQ_DISABLED); /* disable GP timer 2 INT */
|
||||
write_mmcr_byte(SC520_PIT0MAP, SC520_IRQ0); /* Set PIT timer 0 INT to IRQ0 */
|
||||
write_mmcr_byte(SC520_PIT1MAP, SC520_IRQ_DISABLED); /* disable PIT timer 1 INT */
|
||||
write_mmcr_byte(SC520_PIT2MAP, SC520_IRQ_DISABLED); /* disable PIT timer 2 INT */
|
||||
write_mmcr_byte(SC520_PCIINTAMAP, SC520_IRQ_DISABLED); /* disable PCI INT A */
|
||||
write_mmcr_byte(SC520_PCIINTBMAP, SC520_IRQ_DISABLED); /* disable PCI INT B */
|
||||
write_mmcr_byte(SC520_PCIINTCMAP, SC520_IRQ_DISABLED); /* disable PCI INT C */
|
||||
write_mmcr_byte(SC520_PCIINTDMAP, SC520_IRQ_DISABLED); /* disable PCI INT D */
|
||||
write_mmcr_byte(SC520_DMABCINTMAP, SC520_IRQ_DISABLED); /* disable DMA INT */
|
||||
write_mmcr_byte(SC520_SSIMAP, SC520_IRQ_DISABLED); /* disable Synchronius serial INT */
|
||||
write_mmcr_byte(SC520_WDTMAP, SC520_IRQ_DISABLED); /* disable Watchdog INT */
|
||||
write_mmcr_byte(SC520_RTCMAP, SC520_IRQ8); /* Set RTC int to 8 */
|
||||
write_mmcr_byte(SC520_WPVMAP, SC520_IRQ_DISABLED); /* disable write protect INT */
|
||||
write_mmcr_byte(SC520_ICEMAP, SC520_IRQ1); /* Set ICE Debug Serielport INT to IRQ1 */
|
||||
write_mmcr_byte(SC520_FERRMAP,SC520_IRQ13); /* Set FP error INT to IRQ13 */
|
||||
|
||||
if (CFG_USE_SIO_UART) {
|
||||
write_mmcr_byte(SC520_UART1MAP,0); /* disable internal UART1 INT */
|
||||
write_mmcr_byte(SC520_UART2MAP,0); /* disable internal UART2 INT */
|
||||
write_mmcr_byte(SC520_GP3IMAP,11); /* Set GPIRQ3 (ISA IRQ3) to IRQ3 */
|
||||
write_mmcr_byte(SC520_GP4IMAP,12); /* Set GPIRQ4 (ISA IRQ4) to IRQ4 */
|
||||
write_mmcr_byte(SC520_UART1MAP, SC520_IRQ_DISABLED); /* disable internal UART1 INT */
|
||||
write_mmcr_byte(SC520_UART2MAP, SC520_IRQ_DISABLED); /* disable internal UART2 INT */
|
||||
write_mmcr_byte(SC520_GP3IMAP, SC520_IRQ3); /* Set GPIRQ3 (ISA IRQ3) to IRQ3 */
|
||||
write_mmcr_byte(SC520_GP4IMAP, SC520_IRQ4); /* Set GPIRQ4 (ISA IRQ4) to IRQ4 */
|
||||
} else {
|
||||
write_mmcr_byte(SC520_UART1MAP,12); /* Set internal UART2 INT to IRQ4 */
|
||||
write_mmcr_byte(SC520_UART2MAP,11); /* Set internal UART2 INT to IRQ3 */
|
||||
write_mmcr_byte(SC520_GP3IMAP,0); /* disable GPIRQ3 (ISA IRQ3) */
|
||||
write_mmcr_byte(SC520_GP4IMAP,0); /* disable GPIRQ4 (ISA IRQ4) */
|
||||
write_mmcr_byte(SC520_UART1MAP, SC520_IRQ4); /* Set internal UART2 INT to IRQ4 */
|
||||
write_mmcr_byte(SC520_UART2MAP, SC520_IRQ3); /* Set internal UART2 INT to IRQ3 */
|
||||
write_mmcr_byte(SC520_GP3IMAP, SC520_IRQ_DISABLED); /* disable GPIRQ3 (ISA IRQ3) */
|
||||
write_mmcr_byte(SC520_GP4IMAP, SC520_IRQ_DISABLED); /* disable GPIRQ4 (ISA IRQ4) */
|
||||
}
|
||||
|
||||
write_mmcr_byte(SC520_GP5IMAP,13); /* Set GPIRQ5 (ISA IRQ5) to IRQ5 */
|
||||
write_mmcr_byte(SC520_GP6IMAP,21); /* Set GPIRQ6 (ISA IRQ6) to IRQ6 */
|
||||
write_mmcr_byte(SC520_GP7IMAP,22); /* Set GPIRQ7 (ISA IRQ7) to IRQ7 */
|
||||
write_mmcr_byte(SC520_GP8IMAP,3); /* Set GPIRQ8 (SIO IRQ8) to IRQ8 */
|
||||
write_mmcr_byte(SC520_GP9IMAP,4); /* Set GPIRQ9 (ISA IRQ9) to IRQ9 */
|
||||
write_mmcr_byte(SC520_GP10IMAP,9); /* Set GPIRQ10 (ISA IRQ10) to IRQ10 */
|
||||
write_mmcr_word(SC520_PCIHOSTMAP,0x11f); /* Map PCI hostbridge INT to NMI */
|
||||
write_mmcr_word(SC520_ECCMAP,0x100); /* Map SDRAM ECC failure INT to NMI */
|
||||
write_mmcr_byte(SC520_GP1IMAP, SC520_IRQ1); /* Set GPIRQ1 (SIO IRQ1) to IRQ1 */
|
||||
write_mmcr_byte(SC520_GP5IMAP, SC520_IRQ5); /* Set GPIRQ5 (ISA IRQ5) to IRQ5 */
|
||||
write_mmcr_byte(SC520_GP6IMAP, SC520_IRQ6); /* Set GPIRQ6 (ISA IRQ6) to IRQ6 */
|
||||
write_mmcr_byte(SC520_GP7IMAP, SC520_IRQ7); /* Set GPIRQ7 (ISA IRQ7) to IRQ7 */
|
||||
write_mmcr_byte(SC520_GP8IMAP, SC520_IRQ8); /* Set GPIRQ8 (SIO IRQ8) to IRQ8 */
|
||||
write_mmcr_byte(SC520_GP9IMAP, SC520_IRQ9); /* Set GPIRQ9 (ISA IRQ2) to IRQ9 */
|
||||
write_mmcr_byte(SC520_GP0IMAP, SC520_IRQ11); /* Set GPIRQ0 (ISA IRQ11) to IRQ10 */
|
||||
write_mmcr_byte(SC520_GP2IMAP, SC520_IRQ12); /* Set GPIRQ2 (ISA IRQ12) to IRQ12 */
|
||||
write_mmcr_byte(SC520_GP10IMAP,SC520_IRQ14); /* Set GPIRQ10 (ISA IRQ14) to IRQ14 */
|
||||
|
||||
write_mmcr_word(SC520_PCIHOSTMAP, 0x11f); /* Map PCI hostbridge INT to NMI */
|
||||
write_mmcr_word(SC520_ECCMAP, 0x100); /* Map SDRAM ECC failure INT to NMI */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* PCI stuff */
|
||||
static void pci_sc520_cdp_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
|
||||
{
|
||||
char pin;
|
||||
int irq;
|
||||
/* a configurable lists of irqs to steal
|
||||
* when we need one (a board with more pci interrupt pins
|
||||
* would use a larger table */
|
||||
static int irq_list[] = {
|
||||
CFG_FIRST_PCI_IRQ,
|
||||
CFG_SECOND_PCI_IRQ,
|
||||
CFG_THIRD_PCI_IRQ,
|
||||
CFG_FORTH_PCI_IRQ
|
||||
};
|
||||
static int next_irq_index=0;
|
||||
|
||||
char tmp_pin;
|
||||
int pin;
|
||||
|
||||
pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_PIN, &tmp_pin);
|
||||
pin = tmp_pin;
|
||||
|
||||
pin-=1; /* pci config space use 1-based numbering */
|
||||
if (-1 == pin) {
|
||||
return; /* device use no irq */
|
||||
}
|
||||
|
||||
|
||||
pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_PIN, &pin);
|
||||
irq = pin-1;
|
||||
|
||||
|
||||
/* map device number + pin to a pin on the sc520 */
|
||||
switch (PCI_DEV(dev)) {
|
||||
case 20:
|
||||
pin+=SC520_PCI_INTA;
|
||||
break;
|
||||
|
||||
case 19:
|
||||
irq+=1;
|
||||
pin+=SC520_PCI_INTB;
|
||||
break;
|
||||
|
||||
case 18:
|
||||
irq+=2;
|
||||
pin+=SC520_PCI_INTC;
|
||||
break;
|
||||
|
||||
case 17:
|
||||
irq+=3;
|
||||
pin+=SC520_PCI_INTD;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
irq&=3; /* wrap around */
|
||||
irq+=9; /* lowest IRQ is 9 */
|
||||
pin&=3; /* wrap around */
|
||||
|
||||
pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, irq);
|
||||
#if 0
|
||||
printf("fixup_irq: device %d pin %c irq %d\n",
|
||||
PCI_DEV(dev), 'A' + pin -1, irq);
|
||||
#endif
|
||||
if (sc520_pci_ints[pin] == -1) {
|
||||
/* re-route one interrupt for us */
|
||||
if (next_irq_index > 3) {
|
||||
return;
|
||||
}
|
||||
if (pci_sc520_set_irq(pin, irq_list[next_irq_index])) {
|
||||
return;
|
||||
}
|
||||
next_irq_index++;
|
||||
}
|
||||
|
||||
|
||||
if (-1 != sc520_pci_ints[pin]) {
|
||||
pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE,
|
||||
sc520_pci_ints[pin]);
|
||||
}
|
||||
PRINTF("fixup_irq: device %d pin %c irq %d\n",
|
||||
PCI_DEV(dev), 'A' + pin, sc520_pci_ints[pin]);
|
||||
}
|
||||
|
||||
static struct pci_controller sc520_cdp_hose = {
|
||||
@@ -162,8 +216,8 @@ void setup_ali_sio(int uart_primary)
|
||||
|
||||
/* SSI chip select pins */
|
||||
ali512x_cio_function(14, 0, 0, 0); /* SSI_CS */
|
||||
ali512x_cio_function(15, 0, 0, 0); /* SSI_MV */
|
||||
ali512x_cio_function(16, 0, 1, 0); /* SSI_SPI# (inverted) */
|
||||
ali512x_cio_function(15, 0, 0, 0); /* SSI_MV */
|
||||
ali512x_cio_function(16, 0, 0, 0); /* SSI_SPI# */
|
||||
|
||||
/* Board REV pins */
|
||||
ali512x_cio_function(20, 0, 0, 1);
|
||||
@@ -202,6 +256,7 @@ static void bus_init(void)
|
||||
* we need to map 1G-128k - 1G (0x38000000 - 0x3fffffff) to CS1 */
|
||||
|
||||
|
||||
|
||||
/* SRAM = GPCS3 128k @ d0000-effff*/
|
||||
write_mmcr_long(SC520_PAR2, 0x4e00400d);
|
||||
|
||||
@@ -219,13 +274,15 @@ static void bus_init(void)
|
||||
/* 680 LEDS */
|
||||
write_mmcr_long(SC520_PAR15, 0x30000640);
|
||||
|
||||
write_mmcr_byte(SC520_ADDDECCTL, 0);
|
||||
|
||||
asm ("wbinvd\n"); /* Flush cache, req. after setting the unchached attribute ona PAR */
|
||||
|
||||
if (CFG_USE_SIO_UART) {
|
||||
write_mmcr_byte(SC520_ADDDECCTL, read_mmcr_byte(SC520_ADDDECCTL) | UART2_DIS|UART1_DIS);
|
||||
setup_ali_sio(1);
|
||||
} else {
|
||||
write_mmcr_byte(SC520_ADDDECCTL, read_mmcr_byte(SC520_ADDDECCTL) & ~(UART2_DIS|UART1_DIS));
|
||||
write_mmcr_byte(SC520_ADDDECCTL, read_mmcr_byte(SC520_ADDDECCTL) & ~(UART2_DIS|UART1_DIS));
|
||||
setup_ali_sio(0);
|
||||
silence_uart(0x3e8);
|
||||
silence_uart(0x2e8);
|
||||
@@ -233,8 +290,193 @@ static void bus_init(void)
|
||||
|
||||
}
|
||||
|
||||
/* GPCS usage
|
||||
* GPCS0 PIO27 (NMI)
|
||||
* GPCS1 ROMCS1
|
||||
* GPCS2 ROMCS2
|
||||
* GPCS3 SRAMCS PAR2
|
||||
* GPCS4 unused PAR3
|
||||
* GPCS5 unused PAR4
|
||||
* GPCS6 IDE
|
||||
* GPCS7 IDE
|
||||
*/
|
||||
|
||||
|
||||
/* par usage:
|
||||
* PAR0 legacy_video
|
||||
* PAR1 PCI ROM mapping
|
||||
* PAR2 SRAM
|
||||
* PAR3 IDE
|
||||
* PAR4 IDE
|
||||
* PAR5 legacy_video
|
||||
* PAR6 legacy_video
|
||||
* PAR7 legacy_video
|
||||
* PAR8 legacy_video
|
||||
* PAR9 legacy_video
|
||||
* PAR10 legacy_video
|
||||
* PAR11 ISAROM
|
||||
* PAR12 BOOTCS
|
||||
* PAR13 ROMCS1
|
||||
* PAR14 ROMCS2
|
||||
* PAR15 Port 0x680 LED display
|
||||
*/
|
||||
|
||||
/*
|
||||
* This function should map a chunk of size bytes
|
||||
* of the system address space to the ISA bus
|
||||
*
|
||||
* The function will return the memory address
|
||||
* as seen by the host (which may very will be the
|
||||
* same as the bus address)
|
||||
*/
|
||||
u32 isa_map_rom(u32 bus_addr, int size)
|
||||
{
|
||||
u32 par;
|
||||
|
||||
PRINTF("isa_map_rom asked to map %d bytes at %x\n",
|
||||
size, bus_addr);
|
||||
|
||||
par = size;
|
||||
if (par < 0x80000) {
|
||||
par = 0x80000;
|
||||
}
|
||||
par >>= 12;
|
||||
par--;
|
||||
par&=0x7f;
|
||||
par <<= 18;
|
||||
par |= (bus_addr>>12);
|
||||
par |= 0x50000000;
|
||||
|
||||
PRINTF ("setting PAR11 to %x\n", par);
|
||||
|
||||
/* Map rom 0x10000 with PAR1 */
|
||||
write_mmcr_long(SC520_PAR11, par);
|
||||
|
||||
return bus_addr;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function removed any mapping created
|
||||
* with pci_get_rom_window()
|
||||
*/
|
||||
void isa_unmap_rom(u32 addr)
|
||||
{
|
||||
PRINTF("isa_unmap_rom asked to unmap %x", addr);
|
||||
if ((addr>>12) == (read_mmcr_long(SC520_PAR11)&0x3ffff)) {
|
||||
write_mmcr_long(SC520_PAR11, 0);
|
||||
PRINTF(" done\n");
|
||||
return;
|
||||
}
|
||||
PRINTF(" not ours\n");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
#define PCI_ROM_TEMP_SPACE 0x10000
|
||||
/*
|
||||
* This function should map a chunk of size bytes
|
||||
* of the system address space to the PCI bus,
|
||||
* suitable to map PCI ROMS (bus address < 16M)
|
||||
* the function will return the host memory address
|
||||
* which should be converted into a bus address
|
||||
* before used to configure the PCI rom address
|
||||
* decoder
|
||||
*/
|
||||
u32 pci_get_rom_window(struct pci_controller *hose, int size)
|
||||
{
|
||||
u32 par;
|
||||
|
||||
par = size;
|
||||
if (par < 0x80000) {
|
||||
par = 0x80000;
|
||||
}
|
||||
par >>= 16;
|
||||
par--;
|
||||
par&=0x7ff;
|
||||
par <<= 14;
|
||||
par |= (PCI_ROM_TEMP_SPACE>>16);
|
||||
par |= 0x72000000;
|
||||
|
||||
PRINTF ("setting PAR1 to %x\n", par);
|
||||
|
||||
/* Map rom 0x10000 with PAR1 */
|
||||
write_mmcr_long(SC520_PAR1, par);
|
||||
|
||||
return PCI_ROM_TEMP_SPACE;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function removed any mapping created
|
||||
* with pci_get_rom_window()
|
||||
*/
|
||||
void pci_remove_rom_window(struct pci_controller *hose, u32 addr)
|
||||
{
|
||||
PRINTF("pci_remove_rom_window: %x", addr);
|
||||
if (addr == PCI_ROM_TEMP_SPACE) {
|
||||
write_mmcr_long(SC520_PAR1, 0);
|
||||
PRINTF(" done\n");
|
||||
return;
|
||||
}
|
||||
PRINTF(" not ours\n");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called in order to provide acces to the
|
||||
* legacy video I/O ports on the PCI bus.
|
||||
* After this function accesses to I/O ports 0x3b0-0x3bb and
|
||||
* 0x3c0-0x3df shuld result in transactions on the PCI bus.
|
||||
*
|
||||
*/
|
||||
int pci_enable_legacy_video_ports(struct pci_controller *hose)
|
||||
{
|
||||
/* Map video memory to 0xa0000*/
|
||||
write_mmcr_long(SC520_PAR0, 0x7200400a);
|
||||
|
||||
/* forward all I/O accesses to PCI */
|
||||
write_mmcr_byte(SC520_ADDDECCTL,
|
||||
read_mmcr_byte(SC520_ADDDECCTL) | IO_HOLE_DEST_PCI);
|
||||
|
||||
|
||||
/* so we map away all io ports to pci (only way to access pci io
|
||||
* below 0x400. But then we have to map back the portions that we dont
|
||||
* use so that the generate cycles on the GPIO bus where the sio and
|
||||
* ISA slots are connected, this requre the use of several PAR registers
|
||||
*/
|
||||
|
||||
/* bring 0x100 - 0x1ef back to ISA using PAR5 */
|
||||
write_mmcr_long(SC520_PAR5, 0x30ef0100);
|
||||
|
||||
/* IDE use 1f0-1f7 */
|
||||
|
||||
/* bring 0x1f8 - 0x2f7 back to ISA using PAR6 */
|
||||
write_mmcr_long(SC520_PAR6, 0x30ff01f8);
|
||||
|
||||
/* com2 use 2f8-2ff */
|
||||
|
||||
/* bring 0x300 - 0x3af back to ISA using PAR7 */
|
||||
write_mmcr_long(SC520_PAR7, 0x30af0300);
|
||||
|
||||
/* vga use 3b0-3bb */
|
||||
|
||||
/* bring 0x3bc - 0x3bf back to ISA using PAR8 */
|
||||
write_mmcr_long(SC520_PAR8, 0x300303bc);
|
||||
|
||||
/* vga use 3c0-3df */
|
||||
|
||||
/* bring 0x3e0 - 0x3f5 back to ISA using PAR9 */
|
||||
write_mmcr_long(SC520_PAR9, 0x301503e0);
|
||||
|
||||
/* ide use 3f6 */
|
||||
|
||||
/* bring 0x3f7 back to ISA using PAR10 */
|
||||
write_mmcr_long(SC520_PAR10, 0x300003f7);
|
||||
|
||||
/* com1 use 3f8-3ff */
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Miscelaneous platform dependent initialisations
|
||||
*/
|
||||
@@ -252,7 +494,6 @@ int board_init(void)
|
||||
|
||||
/* enter debug mode after next reset (only if jumper is also set) */
|
||||
write_mmcr_byte(SC520_RESCFG, 0x08);
|
||||
|
||||
/* configure the software timer to 33.333MHz */
|
||||
write_mmcr_byte(SC520_SWTMRCFG, 0);
|
||||
gd->bus_clk = 33333000;
|
||||
@@ -288,3 +529,87 @@ int last_stage_init(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ssi_chip_select(int dev)
|
||||
{
|
||||
|
||||
/* Spunk board: SPI EEPROM is active-low, MW EEPROM and AUX are active high */
|
||||
switch (dev) {
|
||||
case 1: /* SPI EEPROM */
|
||||
ali512x_cio_out(16, 0);
|
||||
break;
|
||||
|
||||
case 2: /* MW EEPROM */
|
||||
ali512x_cio_out(15, 1);
|
||||
break;
|
||||
|
||||
case 3: /* AUX */
|
||||
ali512x_cio_out(14, 1);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
ali512x_cio_out(16, 1);
|
||||
ali512x_cio_out(15, 0);
|
||||
ali512x_cio_out(14, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Illegal SSI device requested: %d\n", dev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void spi_init_f(void)
|
||||
{
|
||||
#ifdef CONFIG_SC520_CDP_USE_SPI
|
||||
spi_eeprom_probe(1);
|
||||
#endif
|
||||
#ifdef CONFIG_SC520_CDP_USE_MW
|
||||
mw_eeprom_probe(2);
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len)
|
||||
{
|
||||
int offset;
|
||||
int i;
|
||||
ssize_t res;
|
||||
|
||||
offset = 0;
|
||||
for (i=0;i<alen;i++) {
|
||||
offset <<= 8;
|
||||
offset |= addr[i];
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SC520_CDP_USE_SPI
|
||||
res = spi_eeprom_read(1, offset, buffer, len);
|
||||
#endif
|
||||
#ifdef CONFIG_SC520_CDP_USE_MW
|
||||
res = mw_eeprom_read(2, offset, buffer, len);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
ssize_t spi_write(uchar *addr, int alen, uchar *buffer, int len)
|
||||
{
|
||||
int offset;
|
||||
int i;
|
||||
ssize_t res;
|
||||
|
||||
offset = 0;
|
||||
for (i=0;i<alen;i++) {
|
||||
offset <<= 8;
|
||||
offset |= addr[i];
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SC520_CDP_USE_SPI
|
||||
res = spi_eeprom_write(1, offset, buffer, len);
|
||||
#endif
|
||||
#ifdef CONFIG_SC520_CDP_USE_MW
|
||||
res = mw_eeprom_write(2, offset, buffer, len);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -60,3 +60,25 @@ board_init16:
|
||||
/* the return address is tored in bp */
|
||||
jmp *%bp
|
||||
|
||||
|
||||
.section .bios, "ax"
|
||||
.code16
|
||||
.globl realmode_reset
|
||||
realmode_reset:
|
||||
/* Alias MMCR to 0xdf000 */
|
||||
movw $0xfffc, %dx
|
||||
movl $0x800df0cb, %eax
|
||||
outl %eax, %dx
|
||||
|
||||
/* Set ds to point to MMCR alias */
|
||||
movw $0xdf00, %ax
|
||||
movw %ax, %ds
|
||||
|
||||
/* issue software reset thorugh MMCR */
|
||||
movl $0xd72, %edi
|
||||
movb $0x01, %al
|
||||
movb %al, (%di)
|
||||
|
||||
1: hlt
|
||||
jmp 1
|
||||
|
||||
@@ -27,7 +27,7 @@ ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x387e0000; /* Where bootcode in the flash is mapped */
|
||||
. = 0x387c0000; /* Where bootcode in the flash is mapped */
|
||||
.text : { *(.text); }
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# (C) Copyright 2002
|
||||
# Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
|
||||
#
|
||||
# See file CREDITS for list of people who contributed to this
|
||||
# project.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
# MA 02111-1307 USA
|
||||
#
|
||||
|
||||
include $(TOPDIR)/config.mk
|
||||
|
||||
LIB = lib$(BOARD).a
|
||||
|
||||
OBJS := sc520_spunk.o flash.o
|
||||
SOBJS := sc520_spunk_asm.o sc520_spunk_asm16.o
|
||||
|
||||
$(LIB): $(OBJS) $(SOBJS)
|
||||
$(AR) crv $@ $^
|
||||
|
||||
clean:
|
||||
rm -f $(SOBJS) $(OBJS)
|
||||
|
||||
distclean: clean
|
||||
rm -f $(LIB) core *.bak .depend
|
||||
|
||||
#########################################################################
|
||||
|
||||
.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
|
||||
$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
|
||||
|
||||
-include .depend
|
||||
|
||||
#########################################################################
|
||||
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# (C) Copyright 2002
|
||||
# Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
|
||||
#
|
||||
# See file CREDITS for list of people who contributed to this
|
||||
# project.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
# MA 02111-1307 USA
|
||||
#
|
||||
|
||||
|
||||
TEXT_BASE = 0x387c0000
|
||||
@@ -0,0 +1,813 @@
|
||||
/*
|
||||
* (C) Copyright 2002, 2003
|
||||
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
||||
* Alex Zuepke <azu@sysgo.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
#include <pci.h>
|
||||
#include <asm/ic/sc520.h>
|
||||
|
||||
#define PROBE_BUFFER_SIZE 1024
|
||||
static unsigned char buffer[PROBE_BUFFER_SIZE];
|
||||
|
||||
|
||||
#define SC520_MAX_FLASH_BANKS 1
|
||||
#define SC520_FLASH_BANK0_BASE 0x38000000 /* BOOTCS */
|
||||
#define SC520_FLASH_BANKSIZE 0x8000000
|
||||
|
||||
#define A29LV641DH_SIZE 0x800000
|
||||
#define A29LV641DH_SECTORS 128
|
||||
|
||||
#define A29LV641MH_SIZE 0x800000
|
||||
#define A29LV641MH_SECTORS 128
|
||||
|
||||
#define I28F320J3A_SIZE 0x400000
|
||||
#define I28F320J3A_SECTORS 32
|
||||
|
||||
#define I28F640J3A_SIZE 0x800000
|
||||
#define I28F640J3A_SECTORS 64
|
||||
|
||||
#define I28F128J3A_SIZE 0x1000000
|
||||
#define I28F128J3A_SECTORS 128
|
||||
|
||||
flash_info_t flash_info[SC520_MAX_FLASH_BANKS];
|
||||
|
||||
#define READY 1
|
||||
#define ERR 2
|
||||
#define TMO 4
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
static u32 _probe_flash(u32 addr, u32 bw, int il)
|
||||
{
|
||||
u32 result=0;
|
||||
|
||||
/* First do an unlock cycle for the benefit of
|
||||
* devices that need it */
|
||||
|
||||
switch (bw) {
|
||||
|
||||
case 1:
|
||||
*(volatile u8*)(addr+0x5555) = 0xaa;
|
||||
*(volatile u8*)(addr+0x2aaa) = 0x55;
|
||||
*(volatile u8*)(addr+0x5555) = 0x90;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u8*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u8*)(addr+2);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u8*)addr = 0xff;
|
||||
*(volatile u8*)(addr+0x5555), 0xf0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*(volatile u16*)(addr+0xaaaa) = 0xaaaa;
|
||||
*(volatile u16*)(addr+0x5554) = 0x5555;
|
||||
|
||||
/* Issue identification command */
|
||||
if (il == 2) {
|
||||
*(volatile u16*)(addr+0xaaaa) = 0x9090;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u8*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u8*)(addr+2);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u16*)addr = 0xffff;
|
||||
*(volatile u16*)(addr+0xaaaa), 0xf0f0;
|
||||
|
||||
} else {
|
||||
*(volatile u8*)(addr+0xaaaa) = 0x90;
|
||||
/* Read vendor */
|
||||
result = *(volatile u16*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u16*)(addr+2);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u8*)addr = 0xff;
|
||||
*(volatile u8*)(addr+0xaaaa), 0xf0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*(volatile u32*)(addr+0x5554) = 0xaaaaaaaa;
|
||||
*(volatile u32*)(addr+0xaaa8) = 0x55555555;
|
||||
|
||||
switch (il) {
|
||||
case 1:
|
||||
/* Issue identification command */
|
||||
*(volatile u8*)(addr+0x5554) = 0x90;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u16*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u16*)(addr+4);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u8*)addr = 0xff;
|
||||
*(volatile u8*)(addr+0x5554), 0xf0;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/* Issue identification command */
|
||||
*(volatile u32*)(addr + 0x5554) = 0x00900090;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u16*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u16*)(addr+4);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u32*)addr = 0x00ff00ff;
|
||||
*(volatile u32*)(addr+0x5554), 0x00f000f0;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
/* Issue identification command */
|
||||
*(volatile u32*)(addr+0x5554) = 0x90909090;
|
||||
|
||||
/* Read vendor */
|
||||
result = *(volatile u8*)addr;
|
||||
result <<= 16;
|
||||
|
||||
/* Read device */
|
||||
result |= *(volatile u8*)(addr+4);
|
||||
|
||||
/* Return device to data mode */
|
||||
*(volatile u32*)addr = 0xffffffff;
|
||||
*(volatile u32*)(addr+0x5554), 0xf0f0f0f0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
extern int _probe_flash_end;
|
||||
asm ("_probe_flash_end:\n"
|
||||
".long 0\n");
|
||||
|
||||
static int identify_flash(unsigned address, int width)
|
||||
{
|
||||
int is;
|
||||
int device;
|
||||
int vendor;
|
||||
int size;
|
||||
unsigned res;
|
||||
|
||||
u32 (*_probe_flash_ptr)(u32 a, u32 bw, int il);
|
||||
|
||||
size = (unsigned)&_probe_flash_end - (unsigned)_probe_flash;
|
||||
|
||||
if (size > PROBE_BUFFER_SIZE) {
|
||||
printf("_probe_flash() routine too large (%d) %p - %p\n",
|
||||
size, &_probe_flash_end, _probe_flash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, _probe_flash, size);
|
||||
_probe_flash_ptr = (void*)buffer;
|
||||
|
||||
is = disable_interrupts();
|
||||
res = _probe_flash_ptr(address, width, 1);
|
||||
if (is) {
|
||||
enable_interrupts();
|
||||
}
|
||||
|
||||
|
||||
vendor = res >> 16;
|
||||
device = res & 0xffff;
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ulong flash_init(void)
|
||||
{
|
||||
int i, j;
|
||||
ulong size = 0;
|
||||
|
||||
for (i = 0; i < SC520_MAX_FLASH_BANKS; i++) {
|
||||
unsigned id;
|
||||
ulong flashbase = 0;
|
||||
int sectsize = 0;
|
||||
|
||||
memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
|
||||
switch (i) {
|
||||
case 0:
|
||||
flashbase = SC520_FLASH_BANK0_BASE;
|
||||
break;
|
||||
default:
|
||||
panic("configured to many flash banks!\n");
|
||||
}
|
||||
|
||||
id = identify_flash(flashbase, 2);
|
||||
switch (id) {
|
||||
case 0x000122d7:
|
||||
/* 29LV641DH */
|
||||
flash_info[i].flash_id =
|
||||
(AMD_MANUFACT & FLASH_VENDMASK) |
|
||||
(AMD_ID_LV640U & FLASH_TYPEMASK);
|
||||
|
||||
flash_info[i].size = A29LV641DH_SIZE;
|
||||
flash_info[i].sector_count = A29LV641DH_SECTORS;
|
||||
sectsize = A29LV641DH_SIZE/A29LV641DH_SECTORS;
|
||||
printf("Bank %d: AMD 29LV641DH\n", i);
|
||||
break;
|
||||
|
||||
case 0x0001227E:
|
||||
/* 29LV641MH */
|
||||
flash_info[i].flash_id =
|
||||
(AMD_MANUFACT & FLASH_VENDMASK) |
|
||||
(AMD_ID_DL640 & FLASH_TYPEMASK);
|
||||
|
||||
flash_info[i].size = A29LV641MH_SIZE;
|
||||
flash_info[i].sector_count = A29LV641MH_SECTORS;
|
||||
sectsize = A29LV641MH_SIZE/A29LV641MH_SECTORS;
|
||||
printf("Bank %d: AMD 29LV641MH\n", i);
|
||||
break;
|
||||
|
||||
case 0x00890016:
|
||||
/* 28F320J3A */
|
||||
flash_info[i].flash_id =
|
||||
(INTEL_MANUFACT & FLASH_VENDMASK) |
|
||||
(INTEL_ID_28F320J3A & FLASH_TYPEMASK);
|
||||
|
||||
flash_info[i].size = I28F320J3A_SIZE;
|
||||
flash_info[i].sector_count = I28F320J3A_SECTORS;
|
||||
sectsize = I28F320J3A_SIZE/I28F320J3A_SECTORS;
|
||||
printf("Bank %d: Intel 28F320J3A\n", i);
|
||||
break;
|
||||
|
||||
case 0x00890017:
|
||||
/* 28F640J3A */
|
||||
flash_info[i].flash_id =
|
||||
(INTEL_MANUFACT & FLASH_VENDMASK) |
|
||||
(INTEL_ID_28F640J3A & FLASH_TYPEMASK);
|
||||
|
||||
flash_info[i].size = I28F640J3A_SIZE;
|
||||
flash_info[i].sector_count = I28F640J3A_SECTORS;
|
||||
sectsize = I28F640J3A_SIZE/I28F640J3A_SECTORS;
|
||||
printf("Bank %d: Intel 28F640J3A\n", i);
|
||||
break;
|
||||
|
||||
case 0x00890018:
|
||||
/* 28F128J3A */
|
||||
flash_info[i].flash_id =
|
||||
(INTEL_MANUFACT & FLASH_VENDMASK) |
|
||||
(INTEL_ID_28F128J3A & FLASH_TYPEMASK);
|
||||
|
||||
flash_info[i].size = I28F128J3A_SIZE;
|
||||
flash_info[i].sector_count = I28F128J3A_SECTORS;
|
||||
sectsize = I28F128J3A_SIZE/I28F128J3A_SECTORS;
|
||||
printf("Bank %d: Intel 28F128J3A\n", i);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Bank %d have unknown flash %08x\n", i, id);
|
||||
flash_info[i].flash_id = FLASH_UNKNOWN;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < flash_info[i].sector_count; j++) {
|
||||
flash_info[i].start[j] = flashbase + j * sectsize;
|
||||
}
|
||||
size += flash_info[i].size;
|
||||
|
||||
flash_protect(FLAG_PROTECT_CLEAR,
|
||||
flash_info[i].start[0],
|
||||
flash_info[i].start[0] + flash_info[i].size - 1,
|
||||
&flash_info[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Protect monitor and environment sectors
|
||||
*/
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
i386boot_start,
|
||||
i386boot_end,
|
||||
&flash_info[0]);
|
||||
#ifdef CFG_ENV_ADDR
|
||||
flash_protect(FLAG_PROTECT_SET,
|
||||
CFG_ENV_ADDR,
|
||||
CFG_ENV_ADDR + CFG_ENV_SIZE - 1,
|
||||
&flash_info[0]);
|
||||
#endif
|
||||
return size;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
void flash_print_info(flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (info->flash_id & FLASH_VENDMASK) {
|
||||
case (INTEL_MANUFACT & FLASH_VENDMASK):
|
||||
printf("INTEL: ");
|
||||
switch (info->flash_id & FLASH_TYPEMASK) {
|
||||
case (INTEL_ID_28F320J3A & FLASH_TYPEMASK):
|
||||
printf("1x I28F320J3A (32Mbit)\n");
|
||||
break;
|
||||
case (INTEL_ID_28F640J3A & FLASH_TYPEMASK):
|
||||
printf("1x I28F640J3A (64Mbit)\n");
|
||||
break;
|
||||
case (INTEL_ID_28F128J3A & FLASH_TYPEMASK):
|
||||
printf("1x I28F128J3A (128Mbit)\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Chip Type\n");
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case (AMD_MANUFACT & FLASH_VENDMASK):
|
||||
printf("AMD: ");
|
||||
switch (info->flash_id & FLASH_TYPEMASK) {
|
||||
case (AMD_ID_LV640U & FLASH_TYPEMASK):
|
||||
printf("1x AMD29LV641DH (64Mbit)\n");
|
||||
break;
|
||||
case (AMD_ID_DL640 & FLASH_TYPEMASK):
|
||||
printf("1x AMD29LV641MH (64Mbit)\n");
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Chip Type\n");
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
printf("Unknown Vendor ");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf(" Size: %ld MB in %d Sectors\n",
|
||||
info->size >> 20, info->sector_count);
|
||||
|
||||
printf(" Sector Start Addresses:");
|
||||
for (i = 0; i < info->sector_count; i++) {
|
||||
if ((i % 5) == 0) {
|
||||
printf ("\n ");
|
||||
}
|
||||
printf (" %08lX%s", info->start[i],
|
||||
info->protect[i] ? " (RO)" : " ");
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
done:
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
static u32 _amd_erase_flash(u32 addr, u32 sector)
|
||||
{
|
||||
unsigned elapsed;
|
||||
|
||||
/* Issue erase */
|
||||
*(volatile u16*)(addr + 0xaaaa) = 0x00AA;
|
||||
*(volatile u16*)(addr + 0x5554) = 0x0055;
|
||||
*(volatile u16*)(addr + 0xaaaa) = 0x0080;
|
||||
/* And one unlock */
|
||||
*(volatile u16*)(addr + 0xaaaa) = 0x00AA;
|
||||
*(volatile u16*)(addr + 0x5554) = 0x0055;
|
||||
/* Sector erase command comes last */
|
||||
*(volatile u16*)(addr + sector) = 0x0030;
|
||||
|
||||
elapsed = *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); /* dummy read */
|
||||
elapsed = 0;
|
||||
while (((*(volatile u16*)(addr + sector)) & 0x0080) != 0x0080) {
|
||||
|
||||
elapsed += *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI);
|
||||
if (elapsed > ((CFG_FLASH_ERASE_TOUT/CFG_HZ) * 1000)) {
|
||||
*(volatile u16*)(addr) = 0x00f0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
*(volatile u16*)(addr) = 0x00f0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int _amd_erase_flash_end;
|
||||
asm ("_amd_erase_flash_end:\n"
|
||||
".long 0\n");
|
||||
|
||||
/* this needs to be inlined, the SWTMRMMILLI register is reset by each read */
|
||||
#define __udelay(delay) \
|
||||
{ \
|
||||
unsigned micro; \
|
||||
unsigned milli=0; \
|
||||
\
|
||||
micro = *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); \
|
||||
\
|
||||
for (;;) { \
|
||||
\
|
||||
milli += *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); \
|
||||
micro = *(volatile u16*)(0xfffef000+SC520_SWTMRMICRO); \
|
||||
\
|
||||
if ((delay) <= (micro + (milli * 1000))) { \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static u32 _intel_erase_flash(u32 addr, u32 sector)
|
||||
{
|
||||
unsigned elapsed;
|
||||
|
||||
*(volatile u16*)(addr + sector) = 0x0050; /* clear status register */
|
||||
*(volatile u16*)(addr + sector) = 0x0020; /* erase setup */
|
||||
*(volatile u16*)(addr + sector) = 0x00D0; /* erase confirm */
|
||||
|
||||
|
||||
/* Wait at least 80us - let's wait 1 ms */
|
||||
__udelay(1000);
|
||||
|
||||
elapsed = 0;
|
||||
while (((*(volatile u16*)(addr + sector)) & 0x0080) != 0x0080) {
|
||||
elapsed += *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI);
|
||||
if (elapsed > ((CFG_FLASH_ERASE_TOUT/CFG_HZ) * 1000)) {
|
||||
*(volatile u16*)(addr + sector) = 0x00B0; /* suspend erase */
|
||||
*(volatile u16*)(addr + sector) = 0x00FF; /* reset to read mode */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
*(volatile u16*)(addr + sector) = 0x00FF; /* reset to read mode */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
extern int _intel_erase_flash_end;
|
||||
asm ("_intel_erase_flash_end:\n"
|
||||
".long 0\n");
|
||||
|
||||
int flash_erase(flash_info_t *info, int s_first, int s_last)
|
||||
{
|
||||
u32 (*_erase_flash_ptr)(u32 a, u32 so);
|
||||
int prot;
|
||||
int sect;
|
||||
unsigned size;
|
||||
|
||||
if ((s_first < 0) || (s_first > s_last)) {
|
||||
if (info->flash_id == FLASH_UNKNOWN) {
|
||||
printf("- missing\n");
|
||||
} else {
|
||||
printf("- no sectors to erase\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((info->flash_id & FLASH_VENDMASK) == (AMD_MANUFACT & FLASH_VENDMASK)) {
|
||||
size = (unsigned)&_amd_erase_flash_end - (unsigned)_amd_erase_flash;
|
||||
|
||||
if (size > PROBE_BUFFER_SIZE) {
|
||||
printf("_amd_erase_flash() routine too large (%d) %p - %p\n",
|
||||
size, &_amd_erase_flash_end, _amd_erase_flash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, _amd_erase_flash, size);
|
||||
_erase_flash_ptr = (void*)buffer;
|
||||
|
||||
} else if ((info->flash_id & FLASH_VENDMASK) == (INTEL_MANUFACT & FLASH_VENDMASK)) {
|
||||
size = (unsigned)&_intel_erase_flash_end - (unsigned)_intel_erase_flash;
|
||||
|
||||
if (size > PROBE_BUFFER_SIZE) {
|
||||
printf("_intel_erase_flash() routine too large (%d) %p - %p\n",
|
||||
size, &_intel_erase_flash_end, _intel_erase_flash);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, _intel_erase_flash, size);
|
||||
_erase_flash_ptr = (void*)buffer;
|
||||
} else {
|
||||
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]) {
|
||||
prot++;
|
||||
}
|
||||
}
|
||||
|
||||
if (prot) {
|
||||
printf ("- Warning: %d protected sectors will not be erased!\n", prot);
|
||||
} else {
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
|
||||
/* Start erase on unprotected sectors */
|
||||
for (sect = s_first; sect<=s_last; sect++) {
|
||||
|
||||
if (info->protect[sect] == 0) { /* not protected */
|
||||
int res;
|
||||
int flag;
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
res = _erase_flash_ptr(info->start[0], info->start[sect]-info->start[0]);
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
|
||||
|
||||
if (res) {
|
||||
printf("Erase timed out, sector %d\n", sect);
|
||||
return res;
|
||||
}
|
||||
|
||||
putc('.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Write a word to Flash, returns:
|
||||
* 0 - OK
|
||||
* 1 - write timeout
|
||||
* 2 - Flash not erased
|
||||
*/
|
||||
static int _amd_write_word(unsigned start, unsigned dest, unsigned data)
|
||||
{
|
||||
volatile u16 *addr2 = (u16*)start;
|
||||
volatile u16 *dest2 = (u16*)dest;
|
||||
volatile u16 *data2 = (u16*)&data;
|
||||
int i;
|
||||
unsigned elapsed;
|
||||
|
||||
/* Check if Flash is (sufficiently) erased */
|
||||
if ((*((volatile u16*)dest) & (u16)data) != (u16)data) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
|
||||
|
||||
addr2[0x5555] = 0x00AA;
|
||||
addr2[0x2aaa] = 0x0055;
|
||||
addr2[0x5555] = 0x00A0;
|
||||
|
||||
dest2[i] = (data >> (i*16)) & 0xffff;
|
||||
|
||||
elapsed = *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); /* dummy read */
|
||||
elapsed = 0;
|
||||
|
||||
/* data polling for D7 */
|
||||
while ((dest2[i] & 0x0080) != (data2[i] & 0x0080)) {
|
||||
elapsed += *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI);
|
||||
if (elapsed > ((CFG_FLASH_WRITE_TOUT/CFG_HZ) * 1000)) {
|
||||
addr2[i] = 0x00f0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addr2[i] = 0x00f0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int _amd_write_word_end;
|
||||
asm ("_amd_write_word_end:\n"
|
||||
".long 0\n");
|
||||
|
||||
|
||||
|
||||
static int _intel_write_word(unsigned start, unsigned dest, unsigned data)
|
||||
{
|
||||
int i;
|
||||
unsigned elapsed;
|
||||
|
||||
/* Check if Flash is (sufficiently) erased */
|
||||
if ((*((volatile u16*)dest) & (u16)data) != (u16)data) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
|
||||
*(volatile u16*)(dest+2*i) = 0x0040; /* write setup */
|
||||
*(volatile u16*)(dest+2*i) = (data >> (i*16)) & 0xffff;
|
||||
|
||||
elapsed = *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI); /* dummy read */
|
||||
elapsed = 0;
|
||||
|
||||
/* data polling for D7 */
|
||||
while ((*(volatile u16*)dest & 0x0080) != 0x0080) {
|
||||
elapsed += *(volatile u16*)(0xfffef000+SC520_SWTMRMILLI);
|
||||
if (elapsed > ((CFG_FLASH_WRITE_TOUT/CFG_HZ) * 1000)) {
|
||||
*(volatile u16*)dest = 0x00ff;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*(volatile u16*)dest = 0x00ff;
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
extern int _intel_write_word_end;
|
||||
asm ("_intel_write_word_end:\n"
|
||||
".long 0\n");
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Copy memory to flash, returns:
|
||||
* 0 - OK
|
||||
* 1 - write timeout
|
||||
* 2 - Flash not erased
|
||||
* 3 - Unsupported flash type
|
||||
*/
|
||||
|
||||
int write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt)
|
||||
{
|
||||
ulong cp, wp, data;
|
||||
int i, l, rc;
|
||||
int flag;
|
||||
u32 (*_write_word_ptr)(unsigned start, unsigned dest, unsigned data);
|
||||
unsigned size;
|
||||
|
||||
if ((info->flash_id & FLASH_VENDMASK) == (AMD_MANUFACT & FLASH_VENDMASK)) {
|
||||
size = (unsigned)&_amd_write_word_end - (unsigned)_amd_write_word;
|
||||
|
||||
if (size > PROBE_BUFFER_SIZE) {
|
||||
printf("_amd_write_word() routine too large (%d) %p - %p\n",
|
||||
size, &_amd_write_word_end, _amd_write_word);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, _amd_write_word, size);
|
||||
_write_word_ptr = (void*)buffer;
|
||||
|
||||
} else if ((info->flash_id & FLASH_VENDMASK) == (INTEL_MANUFACT & FLASH_VENDMASK)) {
|
||||
size = (unsigned)&_intel_write_word_end - (unsigned)_intel_write_word;
|
||||
|
||||
if (size > PROBE_BUFFER_SIZE) {
|
||||
printf("_intel_write_word() routine too large (%d) %p - %p\n",
|
||||
size, &_intel_write_word_end, _intel_write_word);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(buffer, _intel_write_word, size);
|
||||
_write_word_ptr = (void*)buffer;
|
||||
} else {
|
||||
printf ("Can't program unknown flash type - aborted\n");
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
wp = (addr & ~3); /* get lower word aligned address */
|
||||
|
||||
|
||||
/*
|
||||
* handle unaligned start bytes
|
||||
*/
|
||||
if ((l = addr - wp) != 0) {
|
||||
data = 0;
|
||||
for (i=0, cp=wp; i<l; ++i, ++cp) {
|
||||
data |= (*(uchar *)cp) << (8*i);
|
||||
}
|
||||
for (; i<4 && cnt>0; ++i) {
|
||||
data |= *src++ << (8*i);
|
||||
--cnt;
|
||||
++cp;
|
||||
}
|
||||
for (; cnt==0 && i<4; ++i, ++cp) {
|
||||
data |= (*(uchar *)cp) << (8*i);
|
||||
}
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
rc = _write_word_ptr(info->start[0], wp, data);
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle word aligned part
|
||||
*/
|
||||
while (cnt >= 4) {
|
||||
data = 0;
|
||||
|
||||
for (i=0; i<4; ++i) {
|
||||
data |= *src++ << (8*i);
|
||||
}
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
rc = _write_word_ptr(info->start[0], wp, data);
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
wp += 4;
|
||||
cnt -= 4;
|
||||
}
|
||||
|
||||
if (cnt == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle unaligned tail bytes
|
||||
*/
|
||||
data = 0;
|
||||
for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
|
||||
data |= *src++ << (8*i);
|
||||
--cnt;
|
||||
}
|
||||
|
||||
for (; i<4; ++i, ++cp) {
|
||||
data |= (*(uchar *)cp) << (8*i);
|
||||
}
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
rc = _write_word_ptr(info->start[0], wp, data);
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag) {
|
||||
enable_interrupts();
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,686 @@
|
||||
/*
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <pci.h>
|
||||
#include <ssi.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/pci.h>
|
||||
#include <asm/ic/sc520.h>
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
* Theory:
|
||||
* We first set up all IRQs to be non-pci, edge triggered,
|
||||
* when we later enumerate the pci bus and pci_sc520_fixup_irq() gets
|
||||
* called we reallocate irqs to the pci bus with sc520_pci_set_irq()
|
||||
* as needed. Whe choose the irqs to gram from a configurable list
|
||||
* inside pci_sc520_fixup_irq() (If this list contains stupid irq's
|
||||
* such as 0 thngas will not work)
|
||||
*/
|
||||
|
||||
static void irq_init(void)
|
||||
{
|
||||
/* disable global interrupt mode */
|
||||
write_mmcr_byte(SC520_PICICR, 0x40);
|
||||
|
||||
/* set all irqs to edge */
|
||||
write_mmcr_byte(SC520_MPICMODE, 0x00);
|
||||
write_mmcr_byte(SC520_SL1PICMODE, 0x00);
|
||||
write_mmcr_byte(SC520_SL2PICMODE, 0x00);
|
||||
|
||||
/* active low polarity on PIC interrupt pins,
|
||||
* active high polarity on all other irq pins */
|
||||
write_mmcr_word(SC520_INTPINPOL, 0x0000);
|
||||
|
||||
/* set irq number mapping */
|
||||
write_mmcr_byte(SC520_GPTMR0MAP, SC520_IRQ_DISABLED); /* disable GP timer 0 INT */
|
||||
write_mmcr_byte(SC520_GPTMR1MAP, SC520_IRQ_DISABLED); /* disable GP timer 1 INT */
|
||||
write_mmcr_byte(SC520_GPTMR2MAP, SC520_IRQ_DISABLED); /* disable GP timer 2 INT */
|
||||
write_mmcr_byte(SC520_PIT0MAP, SC520_IRQ0); /* Set PIT timer 0 INT to IRQ0 */
|
||||
write_mmcr_byte(SC520_PIT1MAP, SC520_IRQ_DISABLED); /* disable PIT timer 1 INT */
|
||||
write_mmcr_byte(SC520_PIT2MAP, SC520_IRQ_DISABLED); /* disable PIT timer 2 INT */
|
||||
write_mmcr_byte(SC520_PCIINTAMAP, SC520_IRQ_DISABLED); /* disable PCI INT A */
|
||||
write_mmcr_byte(SC520_PCIINTBMAP, SC520_IRQ_DISABLED); /* disable PCI INT B */
|
||||
write_mmcr_byte(SC520_PCIINTCMAP, SC520_IRQ_DISABLED); /* disable PCI INT C */
|
||||
write_mmcr_byte(SC520_PCIINTDMAP, SC520_IRQ_DISABLED); /* disable PCI INT D */
|
||||
write_mmcr_byte(SC520_DMABCINTMAP, SC520_IRQ_DISABLED); /* disable DMA INT */
|
||||
write_mmcr_byte(SC520_SSIMAP, SC520_IRQ6); /* Set Synchronius serial INT to IRQ6*/
|
||||
write_mmcr_byte(SC520_WDTMAP, SC520_IRQ_DISABLED); /* disable Watchdog INT */
|
||||
write_mmcr_byte(SC520_RTCMAP, SC520_IRQ8); /* Set RTC int to 8 */
|
||||
write_mmcr_byte(SC520_WPVMAP, SC520_IRQ_DISABLED); /* disable write protect INT */
|
||||
write_mmcr_byte(SC520_ICEMAP, SC520_IRQ1); /* Set ICE Debug Serielport INT to IRQ1 */
|
||||
write_mmcr_byte(SC520_FERRMAP,SC520_IRQ13); /* Set FP error INT to IRQ13 */
|
||||
|
||||
write_mmcr_byte(SC520_UART1MAP, SC520_IRQ4); /* Set internal UART2 INT to IRQ4 */
|
||||
write_mmcr_byte(SC520_UART2MAP, SC520_IRQ3); /* Set internal UART2 INT to IRQ3 */
|
||||
|
||||
write_mmcr_byte(SC520_GP0IMAP, SC520_IRQ7); /* Set GPIRQ0 (PC-Card AUX IRQ) to IRQ7 */
|
||||
write_mmcr_byte(SC520_GP1IMAP, SC520_IRQ14); /* Set GPIRQ1 (CF IRQ) to IRQ14 */
|
||||
write_mmcr_byte(SC520_GP3IMAP, SC520_IRQ5); /* Set GPIRQ3 ( CAN IRQ ) ti IRQ5 */
|
||||
write_mmcr_byte(SC520_GP4IMAP, SC520_IRQ_DISABLED); /* disbale GIRQ4 ( IRR IRQ ) */
|
||||
write_mmcr_byte(SC520_GP5IMAP, SC520_IRQ_DISABLED); /* disable GPIRQ5 */
|
||||
write_mmcr_byte(SC520_GP6IMAP, SC520_IRQ_DISABLED); /* disable GPIRQ6 */
|
||||
write_mmcr_byte(SC520_GP7IMAP, SC520_IRQ_DISABLED); /* disable GPIRQ7 */
|
||||
write_mmcr_byte(SC520_GP8IMAP, SC520_IRQ_DISABLED); /* disable GPIRQ8 */
|
||||
write_mmcr_byte(SC520_GP9IMAP, SC520_IRQ_DISABLED); /* disable GPIRQ9 */
|
||||
write_mmcr_byte(SC520_GP2IMAP, SC520_IRQ_DISABLED); /* disable GPIRQ2 */
|
||||
write_mmcr_byte(SC520_GP10IMAP,SC520_IRQ_DISABLED); /* disable GPIRQ10 */
|
||||
|
||||
write_mmcr_word(SC520_PCIHOSTMAP, 0x11f); /* Map PCI hostbridge INT to NMI */
|
||||
write_mmcr_word(SC520_ECCMAP, 0x100); /* Map SDRAM ECC failure INT to NMI */
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* PCI stuff */
|
||||
static void pci_sc520_spunk_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
|
||||
{
|
||||
int version = read_mmcr_byte(SC520_SYSINFO);
|
||||
|
||||
/* a configurable lists of irqs to steal
|
||||
* when we need one (a board with more pci interrupt pins
|
||||
* would use a larger table */
|
||||
static int irq_list[] = {
|
||||
CFG_FIRST_PCI_IRQ,
|
||||
CFG_SECOND_PCI_IRQ,
|
||||
CFG_THIRD_PCI_IRQ,
|
||||
CFG_FORTH_PCI_IRQ
|
||||
};
|
||||
static int next_irq_index=0;
|
||||
|
||||
char tmp_pin;
|
||||
int pin;
|
||||
|
||||
pci_hose_read_config_byte(hose, dev, PCI_INTERRUPT_PIN, &tmp_pin);
|
||||
pin = tmp_pin;
|
||||
|
||||
pin-=1; /* pci config space use 1-based numbering */
|
||||
if (-1 == pin) {
|
||||
return; /* device use no irq */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* map device number + pin to a pin on the sc520 */
|
||||
switch (PCI_DEV(dev)) {
|
||||
case 6: /* ETH0 */
|
||||
pin+=SC520_PCI_INTA;
|
||||
break;
|
||||
|
||||
case 7: /* ETH1 */
|
||||
pin+=SC520_PCI_INTB;
|
||||
break;
|
||||
|
||||
case 8: /* Crypto */
|
||||
pin+=SC520_PCI_INTC;
|
||||
break;
|
||||
|
||||
case 9: /* PMC slot */
|
||||
pin+=SC520_PCI_INTD;
|
||||
break;
|
||||
|
||||
case 10: /* PC-Card */
|
||||
|
||||
if (version < 10) {
|
||||
pin+=SC520_PCI_INTD;
|
||||
} else {
|
||||
pin+=SC520_PCI_INTC;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
pin&=3; /* wrap around */
|
||||
|
||||
if (sc520_pci_ints[pin] == -1) {
|
||||
/* re-route one interrupt for us */
|
||||
if (next_irq_index > 3) {
|
||||
return;
|
||||
}
|
||||
if (pci_sc520_set_irq(pin, irq_list[next_irq_index])) {
|
||||
return;
|
||||
}
|
||||
next_irq_index++;
|
||||
}
|
||||
|
||||
|
||||
if (-1 != sc520_pci_ints[pin]) {
|
||||
pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE,
|
||||
sc520_pci_ints[pin]);
|
||||
}
|
||||
#if 0
|
||||
printf("fixup_irq: device %d pin %c irq %d\n",
|
||||
PCI_DEV(dev), 'A' + pin, sc520_pci_ints[pin]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void pci_sc520_spunk_configure_cardbus(struct pci_controller *hose,
|
||||
pci_dev_t dev, struct pci_config_table *te)
|
||||
{
|
||||
u32 io_base;
|
||||
u32 temp;
|
||||
|
||||
pciauto_config_device(hose, dev);
|
||||
|
||||
pci_hose_write_config_word(hose, dev, PCI_COMMAND, 0x07); /* enable device */
|
||||
pci_hose_write_config_byte(hose, dev, 0x0c, 0x10); /* cacheline size */
|
||||
pci_hose_write_config_byte(hose, dev, 0x0d, 0x40); /* latency timer */
|
||||
pci_hose_write_config_byte(hose, dev, 0x1b, 0x40); /* cardbus latency timer */
|
||||
pci_hose_write_config_word(hose, dev, PCI_BRIDGE_CONTROL, 0x0040); /* reset cardbus */
|
||||
pci_hose_write_config_word(hose, dev, PCI_BRIDGE_CONTROL, 0x0080); /* route interrupts though ExCA */
|
||||
pci_hose_write_config_word(hose, dev, 0x44, 0x3e0); /* map legacy I/O port to 0x3e0 */
|
||||
|
||||
pci_hose_read_config_dword(hose, dev, 0x80, &temp); /* System control */
|
||||
pci_hose_write_config_dword(hose, dev, 0x80, temp | 0x60); /* System control: disable clockrun */
|
||||
/* route MF0 to ~INT and MF3 to IRQ7
|
||||
* reserve all others */
|
||||
pci_hose_write_config_dword(hose, dev, 0x8c, 0x00007002);
|
||||
pci_hose_write_config_byte(hose, dev, 0x91, 0x00); /* card control */
|
||||
pci_hose_write_config_byte(hose, dev, 0x92, 0x62); /* device control */
|
||||
|
||||
if (te->device != 0xac56) {
|
||||
pci_hose_write_config_byte(hose, dev, 0x93, 0x21); /* async interrupt enable */
|
||||
pci_hose_write_config_word(hose, dev, 0xa8, 0x0000); /* reset GPIO */
|
||||
pci_hose_write_config_word(hose, dev, 0xac, 0x0000); /* reset GPIO */
|
||||
pci_hose_write_config_word(hose, dev, 0xaa, 0x0000); /* reset GPIO */
|
||||
pci_hose_write_config_word(hose, dev, 0xae, 0x0000); /* reset GPIO */
|
||||
} else {
|
||||
pci_hose_write_config_byte(hose, dev, 0x93, 0x20); /* */
|
||||
}
|
||||
pci_hose_write_config_word(hose, dev, 0xa4, 0x8000); /* reset power management */
|
||||
|
||||
|
||||
pci_hose_read_config_dword(hose, dev, PCI_BASE_ADDRESS_0, &io_base);
|
||||
io_base &= ~0xfL;
|
||||
|
||||
writeb(0x07, io_base+0x803); /* route CSC irq though ExCA and enable IRQ7 */
|
||||
writel(0, io_base+0x10); /* CLKRUN default */
|
||||
writel(0, io_base+0x20); /* CLKRUN default */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct pci_config_table pci_sc520_spunk_config_table[] = {
|
||||
{ 0x104c, 0xac50, PCI_ANY_ID, 0, 0x0a, 0, pci_sc520_spunk_configure_cardbus, { 0, 0, 0} },
|
||||
{ 0x104c, 0xac56, PCI_ANY_ID, 0, 0x0a, 0, pci_sc520_spunk_configure_cardbus, { 0, 0, 0} },
|
||||
{ 0, 0, 0, 0, 0, 0, NULL, {0,0,0}}
|
||||
};
|
||||
|
||||
static struct pci_controller sc520_spunk_hose = {
|
||||
fixup_irq: pci_sc520_spunk_fixup_irq,
|
||||
config_table: pci_sc520_spunk_config_table,
|
||||
first_busno: 0x00,
|
||||
last_busno: 0xff,
|
||||
};
|
||||
|
||||
void pci_init_board(void)
|
||||
{
|
||||
pci_sc520_init(&sc520_spunk_hose);
|
||||
}
|
||||
|
||||
|
||||
/* set up the ISA bus timing and system address mappings */
|
||||
static void bus_init(void)
|
||||
{
|
||||
/* versions
|
||||
* 0 Hyglo versions 0.95 and 0.96 (large baords)
|
||||
* ?? Hyglo version 0.97 (small board)
|
||||
* 10 Spunk board
|
||||
*/
|
||||
int version = read_mmcr_byte(SC520_SYSINFO);
|
||||
|
||||
if (version) {
|
||||
/* set up the GP IO pins (for the Spunk board) */
|
||||
write_mmcr_word(SC520_PIOPFS31_16, 0xfff0); /* set the GPIO pin function 31-16 reg */
|
||||
write_mmcr_word(SC520_PIOPFS15_0, 0x000f); /* set the GPIO pin function 15-0 reg */
|
||||
write_mmcr_word(SC520_PIODIR31_16, 0x000f); /* set the GPIO direction 31-16 reg */
|
||||
write_mmcr_word(SC520_PIODIR15_0, 0x1ff0); /* set the GPIO direction 15-0 reg */
|
||||
write_mmcr_byte(SC520_CSPFS, 0xc0); /* set the CS pin function reg */
|
||||
write_mmcr_byte(SC520_CLKSEL, 0x70);
|
||||
|
||||
write_mmcr_word(SC520_PIOCLR31_16, 0x0003); /* reset SSI chip-selects */
|
||||
write_mmcr_word(SC520_PIOSET31_16, 0x000c);
|
||||
|
||||
} else {
|
||||
/* set up the GP IO pins (for the Hyglo board) */
|
||||
write_mmcr_word(SC520_PIOPFS31_16, 0xffc0); /* set the GPIO pin function 31-16 reg */
|
||||
write_mmcr_word(SC520_PIOPFS15_0, 0x1e7f); /* set the GPIO pin function 15-0 reg */
|
||||
write_mmcr_word(SC520_PIODIR31_16, 0x003f); /* set the GPIO direction 31-16 reg */
|
||||
write_mmcr_word(SC520_PIODIR15_0, 0xe180); /* set the GPIO direction 15-0 reg */
|
||||
write_mmcr_byte(SC520_CSPFS, 0x00); /* set the CS pin function reg */
|
||||
write_mmcr_byte(SC520_CLKSEL, 0x70);
|
||||
|
||||
write_mmcr_word(SC520_PIOCLR15_0, 0x0180); /* reset SSI chip-selects */
|
||||
}
|
||||
|
||||
write_mmcr_byte(SC520_GPCSRT, 1); /* set the GP CS offset */
|
||||
write_mmcr_byte(SC520_GPCSPW, 3); /* set the GP CS pulse width */
|
||||
write_mmcr_byte(SC520_GPCSOFF, 1); /* set the GP CS offset */
|
||||
write_mmcr_byte(SC520_GPRDW, 3); /* set the RD pulse width */
|
||||
write_mmcr_byte(SC520_GPRDOFF, 1); /* set the GP RD offset */
|
||||
write_mmcr_byte(SC520_GPWRW, 3); /* set the GP WR pulse width */
|
||||
write_mmcr_byte(SC520_GPWROFF, 1); /* set the GP WR offset */
|
||||
|
||||
write_mmcr_word(SC520_BOOTCSCTL, 0x0407); /* set up timing of BOOTCS */
|
||||
|
||||
/* adjust the memory map:
|
||||
* by default the first 256MB (0x00000000 - 0x0fffffff) is mapped to SDRAM
|
||||
* and 256MB to 1G-128k (0x1000000 - 0x37ffffff) is mapped to PCI mmio
|
||||
* we need to map 1G-128k - 1G (0x38000000 - 0x3fffffff) to CS1 */
|
||||
|
||||
|
||||
|
||||
/* bootcs */
|
||||
write_mmcr_long(SC520_PAR12, 0x8bffe800);
|
||||
|
||||
/* IDE0 = GPCS6 1f0-1f7 */
|
||||
write_mmcr_long(SC520_PAR3, 0x380801f0);
|
||||
|
||||
/* IDE1 = GPCS7 3f6 */
|
||||
write_mmcr_long(SC520_PAR4, 0x3c0003f6);
|
||||
|
||||
asm ("wbinvd\n"); /* Flush cache, req. after setting the unchached attribute ona PAR */
|
||||
|
||||
write_mmcr_byte(SC520_ADDDECCTL, read_mmcr_byte(SC520_ADDDECCTL) & ~(UART2_DIS|UART1_DIS));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* par usage:
|
||||
* PAR0 (legacy_video)
|
||||
* PAR1 (PCI ROM mapping)
|
||||
* PAR2
|
||||
* PAR3 IDE
|
||||
* PAR4 IDE
|
||||
* PAR5 (legacy_video)
|
||||
* PAR6
|
||||
* PAR7 (legacy_video)
|
||||
* PAR8 (legacy_video)
|
||||
* PAR9 (legacy_video)
|
||||
* PAR10
|
||||
* PAR11 (ISAROM)
|
||||
* PAR12 BOOTCS
|
||||
* PAR13
|
||||
* PAR14
|
||||
* PAR15
|
||||
*/
|
||||
|
||||
/*
|
||||
* This function should map a chunk of size bytes
|
||||
* of the system address space to the ISA bus
|
||||
*
|
||||
* The function will return the memory address
|
||||
* as seen by the host (which may very will be the
|
||||
* same as the bus address)
|
||||
*/
|
||||
u32 isa_map_rom(u32 bus_addr, int size)
|
||||
{
|
||||
u32 par;
|
||||
|
||||
printf("isa_map_rom asked to map %d bytes at %x\n",
|
||||
size, bus_addr);
|
||||
|
||||
par = size;
|
||||
if (par < 0x80000) {
|
||||
par = 0x80000;
|
||||
}
|
||||
par >>= 12;
|
||||
par--;
|
||||
par&=0x7f;
|
||||
par <<= 18;
|
||||
par |= (bus_addr>>12);
|
||||
par |= 0x50000000;
|
||||
|
||||
printf ("setting PAR11 to %x\n", par);
|
||||
|
||||
/* Map rom 0x10000 with PAR1 */
|
||||
write_mmcr_long(SC520_PAR11, par);
|
||||
|
||||
return bus_addr;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function removed any mapping created
|
||||
* with pci_get_rom_window()
|
||||
*/
|
||||
void isa_unmap_rom(u32 addr)
|
||||
{
|
||||
printf("isa_unmap_rom asked to unmap %x", addr);
|
||||
if ((addr>>12) == (read_mmcr_long(SC520_PAR11)&0x3ffff)) {
|
||||
write_mmcr_long(SC520_PAR11, 0);
|
||||
printf(" done\n");
|
||||
return;
|
||||
}
|
||||
printf(" not ours\n");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
#define PCI_ROM_TEMP_SPACE 0x10000
|
||||
/*
|
||||
* This function should map a chunk of size bytes
|
||||
* of the system address space to the PCI bus,
|
||||
* suitable to map PCI ROMS (bus address < 16M)
|
||||
* the function will return the host memory address
|
||||
* which should be converted into a bus address
|
||||
* before used to configure the PCI rom address
|
||||
* decoder
|
||||
*/
|
||||
u32 pci_get_rom_window(struct pci_controller *hose, int size)
|
||||
{
|
||||
u32 par;
|
||||
|
||||
par = size;
|
||||
if (par < 0x80000) {
|
||||
par = 0x80000;
|
||||
}
|
||||
par >>= 16;
|
||||
par--;
|
||||
par&=0x7ff;
|
||||
par <<= 14;
|
||||
par |= (PCI_ROM_TEMP_SPACE>>16);
|
||||
par |= 0x72000000;
|
||||
|
||||
printf ("setting PAR1 to %x\n", par);
|
||||
|
||||
/* Map rom 0x10000 with PAR1 */
|
||||
write_mmcr_long(SC520_PAR1, par);
|
||||
|
||||
return PCI_ROM_TEMP_SPACE;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function removed any mapping created
|
||||
* with pci_get_rom_window()
|
||||
*/
|
||||
void pci_remove_rom_window(struct pci_controller *hose, u32 addr)
|
||||
{
|
||||
printf("pci_remove_rom_window: %x", addr);
|
||||
if (addr == PCI_ROM_TEMP_SPACE) {
|
||||
write_mmcr_long(SC520_PAR1, 0);
|
||||
printf(" done\n");
|
||||
return;
|
||||
}
|
||||
printf(" not ours\n");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called in order to provide acces to the
|
||||
* legacy video I/O ports on the PCI bus.
|
||||
* After this function accesses to I/O ports 0x3b0-0x3bb and
|
||||
* 0x3c0-0x3df shuld result in transactions on the PCI bus.
|
||||
*
|
||||
*/
|
||||
int pci_enable_legacy_video_ports(struct pci_controller *hose)
|
||||
{
|
||||
/* Map video memory to 0xa0000*/
|
||||
write_mmcr_long(SC520_PAR0, 0x7200400a);
|
||||
|
||||
/* forward all I/O accesses to PCI */
|
||||
write_mmcr_byte(SC520_ADDDECCTL,
|
||||
read_mmcr_byte(SC520_ADDDECCTL) | IO_HOLE_DEST_PCI);
|
||||
|
||||
|
||||
/* so we map away all io ports to pci (only way to access pci io
|
||||
* below 0x400. But then we have to map back the portions that we dont
|
||||
* use so that the generate cycles on the GPIO bus where the sio and
|
||||
* ISA slots are connected, this requre the use of several PAR registers
|
||||
*/
|
||||
|
||||
/* bring 0x100 - 0x2f7 back to ISA using PAR5 */
|
||||
write_mmcr_long(SC520_PAR5, 0x31f70100);
|
||||
|
||||
/* com2 use 2f8-2ff */
|
||||
|
||||
/* bring 0x300 - 0x3af back to ISA using PAR7 */
|
||||
write_mmcr_long(SC520_PAR7, 0x30af0300);
|
||||
|
||||
/* vga use 3b0-3bb */
|
||||
|
||||
/* bring 0x3bc - 0x3bf back to ISA using PAR8 */
|
||||
write_mmcr_long(SC520_PAR8, 0x300303bc);
|
||||
|
||||
/* vga use 3c0-3df */
|
||||
|
||||
/* bring 0x3e0 - 0x3f7 back to ISA using PAR9 */
|
||||
write_mmcr_long(SC520_PAR9, 0x301703e0);
|
||||
|
||||
/* com1 use 3f8-3ff */
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Miscelaneous platform dependent initialisations
|
||||
*/
|
||||
|
||||
int board_init(void)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
init_sc520();
|
||||
bus_init();
|
||||
irq_init();
|
||||
|
||||
/* max drive current on SDRAM */
|
||||
write_mmcr_word(SC520_DSCTL, 0x0100);
|
||||
|
||||
/* enter debug mode after next reset (only if jumper is also set) */
|
||||
write_mmcr_byte(SC520_RESCFG, 0x08);
|
||||
/* configure the software timer to 33.000MHz */
|
||||
write_mmcr_byte(SC520_SWTMRCFG, 1);
|
||||
gd->bus_clk = 33000000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dram_init(void)
|
||||
{
|
||||
init_sc520_dram();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void show_boot_progress(int val)
|
||||
{
|
||||
int version = read_mmcr_byte(SC520_SYSINFO);
|
||||
|
||||
if (version == 0) {
|
||||
/* PIO31-PIO16 Data */
|
||||
write_mmcr_word(SC520_PIODATA31_16,
|
||||
(read_mmcr_word(SC520_PIODATA31_16) & 0xffc0)| ((val&0x7e)>>1)); /* 0x1f8 >> 3 */
|
||||
|
||||
/* PIO0-PIO15 Data */
|
||||
write_mmcr_word(SC520_PIODATA15_0,
|
||||
(read_mmcr_word(SC520_PIODATA15_0) & 0x1fff)| ((val&0x7)<<13));
|
||||
} else {
|
||||
/* newer boards use PIO4-PIO12 */
|
||||
/* PIO0-PIO15 Data */
|
||||
#if 0
|
||||
val = (val & 0x007) | ((val & 0x038) << 3) | ((val & 0x1c0) >> 3);
|
||||
#else
|
||||
val = (val & 0x007) | ((val & 0x07e) << 2);
|
||||
#endif
|
||||
write_mmcr_word(SC520_PIODATA15_0,
|
||||
(read_mmcr_word(SC520_PIODATA15_0) & 0xe00f) | ((val&0x01ff)<<4));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int last_stage_init(void)
|
||||
{
|
||||
|
||||
int version = read_mmcr_byte(SC520_SYSINFO);
|
||||
|
||||
printf("Omicron Ceti SC520 Spunk revision %x\n", version);
|
||||
|
||||
#if 0
|
||||
if (version) {
|
||||
int x, y;
|
||||
|
||||
printf("eeprom probe %d\n", spi_eeprom_probe(1));
|
||||
|
||||
spi_eeprom_read(1, 0, (u8*)&x, 2);
|
||||
spi_eeprom_read(1, 1, (u8*)&y, 2);
|
||||
printf("eeprom bytes %04x%04x\n", x, y);
|
||||
x ^= 0xffff;
|
||||
y ^= 0xffff;
|
||||
spi_eeprom_write(1, 0, (u8*)&x, 2);
|
||||
spi_eeprom_write(1, 1, (u8*)&y, 2);
|
||||
|
||||
spi_eeprom_read(1, 0, (u8*)&x, 2);
|
||||
spi_eeprom_read(1, 1, (u8*)&y, 2);
|
||||
printf("eeprom bytes %04x%04x\n", x, y);
|
||||
|
||||
} else {
|
||||
int x, y;
|
||||
|
||||
printf("eeprom probe %d\n", mw_eeprom_probe(1));
|
||||
|
||||
mw_eeprom_read(1, 0, (u8*)&x, 2);
|
||||
mw_eeprom_read(1, 1, (u8*)&y, 2);
|
||||
printf("eeprom bytes %04x%04x\n", x, y);
|
||||
|
||||
x ^= 0xffff;
|
||||
y ^= 0xffff;
|
||||
mw_eeprom_write(1, 0, (u8*)&x, 2);
|
||||
mw_eeprom_write(1, 1, (u8*)&y, 2);
|
||||
|
||||
mw_eeprom_read(1, 0, (u8*)&x, 2);
|
||||
mw_eeprom_read(1, 1, (u8*)&y, 2);
|
||||
printf("eeprom bytes %04x%04x\n", x, y);
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
ds1722_probe(2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ssi_chip_select(int dev)
|
||||
{
|
||||
int version = read_mmcr_byte(SC520_SYSINFO);
|
||||
|
||||
if (version) {
|
||||
/* Spunk board: EEPROM and CAN are actove-low, TEMP and AUX are active high */
|
||||
switch (dev) {
|
||||
case 1: /* EEPROM */
|
||||
write_mmcr_word(SC520_PIOCLR31_16, 0x0004);
|
||||
break;
|
||||
|
||||
case 2: /* Temp Probe */
|
||||
write_mmcr_word(SC520_PIOSET31_16, 0x0002);
|
||||
break;
|
||||
|
||||
case 3: /* CAN */
|
||||
write_mmcr_word(SC520_PIOCLR31_16, 0x0008);
|
||||
break;
|
||||
|
||||
case 4: /* AUX */
|
||||
write_mmcr_word(SC520_PIOSET31_16, 0x0001);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
write_mmcr_word(SC520_PIOCLR31_16, 0x0003);
|
||||
write_mmcr_word(SC520_PIOSET31_16, 0x000c);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Illegal SSI device requested: %d\n", dev);
|
||||
}
|
||||
} else {
|
||||
|
||||
/* Globox board: Both EEPROM and TEMP are active-high */
|
||||
|
||||
switch (dev) {
|
||||
case 1: /* EEPROM */
|
||||
write_mmcr_word(SC520_PIOSET15_0, 0x0100);
|
||||
break;
|
||||
|
||||
case 2: /* Temp Probe */
|
||||
write_mmcr_word(SC520_PIOSET15_0, 0x0080);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
write_mmcr_word(SC520_PIOCLR15_0, 0x0180);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Illegal SSI device requested: %d\n", dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void spi_init_f(void)
|
||||
{
|
||||
read_mmcr_byte(SC520_SYSINFO) ?
|
||||
spi_eeprom_probe(1) :
|
||||
mw_eeprom_probe(1);
|
||||
|
||||
}
|
||||
|
||||
ssize_t spi_read(uchar *addr, int alen, uchar *buffer, int len)
|
||||
{
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
offset = 0;
|
||||
for (i=0;i<alen;i++) {
|
||||
offset <<= 8;
|
||||
offset |= addr[i];
|
||||
}
|
||||
|
||||
return read_mmcr_byte(SC520_SYSINFO) ?
|
||||
spi_eeprom_read(1, offset, buffer, len) :
|
||||
mw_eeprom_read(1, offset, buffer, len);
|
||||
}
|
||||
|
||||
ssize_t spi_write(uchar *addr, int alen, uchar *buffer, int len)
|
||||
{
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
offset = 0;
|
||||
for (i=0;i<alen;i++) {
|
||||
offset <<= 8;
|
||||
offset |= addr[i];
|
||||
}
|
||||
|
||||
return read_mmcr_byte(SC520_SYSINFO) ?
|
||||
spi_eeprom_write(1, offset, buffer, len) :
|
||||
mw_eeprom_write(1, offset, buffer, len);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* (C) Copyright 2002
|
||||
* Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* now setup the General purpose bus to give us access to the LEDs.
|
||||
* We can then use the leds to display status information.
|
||||
*/
|
||||
|
||||
sc520_cdp_registers:
|
||||
/* size offset value */
|
||||
.word 1 ; .word 0x040 ; .long 0x00 /* SDRAM buffer control */
|
||||
.word 2 ; .word 0xc08 ; .long 0x0001 /* GP CS offset */
|
||||
.word 2 ; .word 0xc09 ; .long 0x0003 /* GP CS width */
|
||||
.word 2 ; .word 0xc0a ; .long 0x0001 /* GP CS width */
|
||||
.word 2 ; .word 0xc0b ; .long 0x0003 /* GP RD pulse width */
|
||||
.word 2 ; .word 0xc0c ; .long 0x0001 /* GP RD offse */
|
||||
.word 2 ; .word 0xc0d ; .long 0x0003 /* GP WR pulse width */
|
||||
.word 2 ; .word 0xc0e ; .long 0x0001 /* GP WR offset */
|
||||
.word 2 ; .word 0xc2c ; .long 0x003f /* GPIO directionreg 31-16 */
|
||||
.word 2 ; .word 0xc2a ; .long 0xe000 /* GPIO directionreg 15-0 */
|
||||
.word 2 ; .word 0xc22 ; .long 0xffc0 /* GPIO pin function 31-16 reg */
|
||||
.word 2 ; .word 0xc20 ; .long 0x1fff /* GPIO pin function 15-0 reg */
|
||||
.word 0 ; .word 0x000 ; .long 0x00
|
||||
|
||||
/* board early intialization */
|
||||
.globl early_board_init
|
||||
early_board_init:
|
||||
movl $sc520_cdp_registers,%esi
|
||||
init_loop:
|
||||
movl $0xfffef000,%edi /* MMCR base to edi */
|
||||
movw (%esi), %bx /* load size to bx */
|
||||
cmpw $0, %bx /* if size is 0 we're done */
|
||||
je done
|
||||
xorl %edx,%edx
|
||||
movw 2(%esi), %dx /* load MMCR offset to dx */
|
||||
addl %edx, %edi /* add offset to base in edi */
|
||||
movl 4(%esi), %eax /* load value in eax */
|
||||
cmpw $1, %bx
|
||||
je byte /* byte op? */
|
||||
cmpw $2, %bx
|
||||
je word /* word op? */
|
||||
movl %eax, (%edi) /* must be long, then */
|
||||
jmp next
|
||||
byte: movb %al,(%edi)
|
||||
jmp next
|
||||
word: movw %ax,(%edi)
|
||||
next: addl $8, %esi /* advance esi */
|
||||
jmp init_loop
|
||||
|
||||
/* light all leds */
|
||||
done: movl $0xfffefc32,%edx
|
||||
movw $0000,(%edx)
|
||||
|
||||
jmp *%ebp /* return to caller */
|
||||
|
||||
|
||||
.globl __show_boot_progress
|
||||
__show_boot_progress:
|
||||
movl $0xfffefc32,%edx
|
||||
xorw $0xffff, %ax
|
||||
movw %ax,(%edx)
|
||||
jmp *%ebp
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* (C) Copyright 2002
|
||||
* Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* 16bit initialization code.
|
||||
* This code have to map the area of the boot flash
|
||||
* that is used by U-boot to its final destination.
|
||||
*/
|
||||
|
||||
.text
|
||||
.section .start16, "ax"
|
||||
.code16
|
||||
.globl board_init16
|
||||
board_init16:
|
||||
/* Alias MMCR to 0xdf000 */
|
||||
movw $0xfffc, %dx
|
||||
movl $0x800df0cb, %eax
|
||||
outl %eax, %dx
|
||||
|
||||
/* Set ds to point to MMCR alias */
|
||||
movw $0xdf00, %ax
|
||||
movw %ax, %ds
|
||||
|
||||
/* Map the entire flash at 0x38000000
|
||||
* (with BOOTCS and PAR14, use 0xabfff800 for ROMCS1) */
|
||||
movl $0xc0, %edi
|
||||
movl $0x8bfff800, %eax
|
||||
movl %eax, (%di)
|
||||
|
||||
/* Disable SDRAM write buffer */
|
||||
movw $0x40,%di
|
||||
xorw %ax,%ax
|
||||
movb %al, (%di)
|
||||
|
||||
/* Disabe MMCR alias */
|
||||
movw $0xfffc, %dx
|
||||
movl $0x000000cb, %eax
|
||||
outl %eax, %dx
|
||||
|
||||
/* the return address is stored in bp */
|
||||
jmp *%bp
|
||||
|
||||
|
||||
.section .bios, "ax"
|
||||
.code16
|
||||
.globl realmode_reset
|
||||
realmode_reset:
|
||||
/* Alias MMCR to 0xdf000 */
|
||||
movw $0xfffc, %dx
|
||||
movl $0x800df0cb, %eax
|
||||
outl %eax, %dx
|
||||
|
||||
/* Set ds to point to MMCR alias */
|
||||
movw $0xdf00, %ax
|
||||
movw %ax, %ds
|
||||
|
||||
/* issue software reset thorugh MMCR */
|
||||
movl $0xd72, %edi
|
||||
movb $0x01, %al
|
||||
movb %al, (%di)
|
||||
|
||||
1: hlt
|
||||
jmp 1
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* (C) Copyright 2002
|
||||
* Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
|
||||
OUTPUT_ARCH(i386)
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x387c0000; /* Where bootcode in the flash is mapped */
|
||||
.text : { *(.text); }
|
||||
|
||||
. = ALIGN(4);
|
||||
.rodata : { *(.rodata) }
|
||||
|
||||
. = 0x400000; /* Ram data segment to use */
|
||||
_i386boot_romdata_dest = ABSOLUTE(.);
|
||||
.data : AT ( LOADADDR(.rodata) + SIZEOF(.rodata) ) { *(.data) }
|
||||
_i386boot_romdata_start = LOADADDR(.data);
|
||||
|
||||
. = ALIGN(4);
|
||||
.got : AT ( LOADADDR(.data) + SIZEOF(.data) ) { *(.got) }
|
||||
_i386boot_romdata_size = SIZEOF(.data) + SIZEOF(.got);
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
_i386boot_bss_start = ABSOLUTE(.);
|
||||
.bss : { *(.bss) }
|
||||
_i386boot_bss_size = SIZEOF(.bss);
|
||||
|
||||
|
||||
/* 16bit realmode trampoline code */
|
||||
.realmode 0x7c0 : AT ( LOADADDR(.got) + SIZEOF(.got) ) { *(.realmode) }
|
||||
|
||||
_i386boot_realmode = LOADADDR(.realmode);
|
||||
_i386boot_realmode_size = SIZEOF(.realmode);
|
||||
|
||||
/* 16bit BIOS emulation code (just enough to boot Linux) */
|
||||
.bios 0 : AT ( LOADADDR(.realmode) + SIZEOF(.realmode) ) { *(.bios) }
|
||||
|
||||
_i386boot_bios = LOADADDR(.bios);
|
||||
_i386boot_bios_size = SIZEOF(.bios);
|
||||
|
||||
|
||||
/* The load addresses below assumes that the flash
|
||||
* will be mapped so that 0x387f0000 == 0xffff0000
|
||||
* at reset time
|
||||
*
|
||||
* The fe00 and ff00 offsets of the start32 and start16
|
||||
* segments are arbitrary, the just have to be mapped
|
||||
* at reset and the code have to fit.
|
||||
* The fff0 offset of reset is important, however.
|
||||
*/
|
||||
|
||||
|
||||
. = 0xfffffe00;
|
||||
.start32 : AT (0x387ffe00) { *(.start32); }
|
||||
|
||||
. = 0xff00;
|
||||
.start16 : AT (0x387fff00) { *(.start16); }
|
||||
|
||||
. = 0xfff0;
|
||||
.reset : AT (0x387ffff0) { *(.reset); }
|
||||
_i386boot_end = (LOADADDR(.reset) + SIZEOF(.reset) );
|
||||
}
|
||||
+1655
-1655
File diff suppressed because it is too large.
Load diff
@@ -32,6 +32,11 @@
|
||||
# include <status_led.h>
|
||||
#endif
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
|
||||
#include <linux/mtd/nand.h>
|
||||
extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
|
||||
#endif
|
||||
|
||||
#define ORMASK(size) ((-size) & OR_AM_MSK)
|
||||
|
||||
static long ram_size(ulong *, long);
|
||||
@@ -321,6 +326,17 @@ int misc_init_r (void)
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
|
||||
void nand_init(void)
|
||||
{
|
||||
nand_probe(CFG_DFLASH_BASE); /* see if any NAND flash present */
|
||||
if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
|
||||
puts("NAND: ");
|
||||
print_size(nand_dev_desc[0].totlen, "\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* #define DEBUG */
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc8xx.h>
|
||||
|
||||
@@ -53,8 +55,12 @@ unsigned long flash_init (void)
|
||||
|
||||
/* Static FLASH Bank configuration here - FIXME XXX */
|
||||
|
||||
debug ("\n## Get flash bank 1 size @ 0x%08x\n",FLASH_BASE0_PRELIM);
|
||||
|
||||
size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
|
||||
|
||||
debug ("## Get flash bank 2 size @ 0x%08x\n",FLASH_BASE1_PRELIM);
|
||||
|
||||
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);
|
||||
@@ -62,6 +68,8 @@ unsigned long flash_init (void)
|
||||
|
||||
size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
|
||||
|
||||
debug ("## Prelim. Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1);
|
||||
|
||||
if (size_b1 > size_b0) {
|
||||
printf ("## ERROR: "
|
||||
"Bank 1 (0x%08lx = %ld MB) > Bank 0 (0x%08lx = %ld MB)\n",
|
||||
@@ -77,10 +85,19 @@ unsigned long flash_init (void)
|
||||
return (0);
|
||||
}
|
||||
|
||||
debug ("## Before remap: "
|
||||
"BR0: 0x%08x OR0: 0x%08x "
|
||||
"BR1: 0x%08x OR1: 0x%08x\n",
|
||||
memctl->memc_br0, memctl->memc_or0,
|
||||
memctl->memc_br1, memctl->memc_or1);
|
||||
|
||||
/* Remap FLASH according to real size */
|
||||
memctl->memc_or0 = CFG_OR_TIMING_FLASH | (-size_b0 & OR_AM_MSK);
|
||||
memctl->memc_br0 = (CFG_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V;
|
||||
|
||||
debug ("## BR0: 0x%08x OR0: 0x%08x\n",
|
||||
memctl->memc_br0, memctl->memc_or0);
|
||||
|
||||
/* Re-do sizing to get full correct info */
|
||||
size_b0 = flash_get_size((vu_long *)CFG_FLASH_BASE, &flash_info[0]);
|
||||
|
||||
@@ -105,6 +122,9 @@ unsigned long flash_init (void)
|
||||
memctl->memc_br1 = ((CFG_FLASH_BASE + size_b0) & BR_BA_MSK) |
|
||||
BR_MS_GPCM | BR_V;
|
||||
|
||||
debug ("## BR1: 0x%08x OR1: 0x%08x\n",
|
||||
memctl->memc_br1, memctl->memc_or1);
|
||||
|
||||
/* Re-do sizing to get full correct info */
|
||||
size_b1 = flash_get_size((vu_long *)(CFG_FLASH_BASE + size_b0),
|
||||
&flash_info[1]);
|
||||
@@ -129,8 +149,14 @@ unsigned long flash_init (void)
|
||||
|
||||
flash_info[1].flash_id = FLASH_UNKNOWN;
|
||||
flash_info[1].sector_count = -1;
|
||||
flash_info[1].size = 0;
|
||||
|
||||
debug ("## DISABLE BR1: 0x%08x OR1: 0x%08x\n",
|
||||
memctl->memc_br1, memctl->memc_or1);
|
||||
}
|
||||
|
||||
debug ("## Final Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1);
|
||||
|
||||
flash_info[0].size = size_b0;
|
||||
flash_info[1].size = size_b1;
|
||||
|
||||
@@ -215,6 +241,8 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
|
||||
value = addr[0];
|
||||
|
||||
debug ("Manuf. ID @ 0x%08lx: 0x%08lx\n", (ulong)addr, value);
|
||||
|
||||
switch (value) {
|
||||
case AMD_MANUFACT:
|
||||
info->flash_id = FLASH_MAN_AMD;
|
||||
@@ -231,6 +259,8 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
|
||||
value = addr[1]; /* device ID */
|
||||
|
||||
debug ("Device ID @ 0x%08lx: 0x%08lx\n", (ulong)(&addr[1]), value);
|
||||
|
||||
switch (value) {
|
||||
case AMD_ID_LV400T:
|
||||
info->flash_id += FLASH_AM400T;
|
||||
@@ -278,6 +308,12 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
info->sector_count = 71;
|
||||
info->size = 0x00800000;
|
||||
break; /* => 8 MB */
|
||||
case AMD_ID_DL640:
|
||||
debug ("## oops - same ID used for AM29LV128ML/H mirror bit flash ???\n");
|
||||
info->flash_id += FLASH_AMDL640;
|
||||
info->sector_count = 142;
|
||||
info->size = 0x00800000;
|
||||
break;
|
||||
default:
|
||||
info->flash_id = FLASH_UNKNOWN;
|
||||
return (0); /* => no or unknown flash */
|
||||
@@ -368,6 +404,8 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
|
||||
int flag, prot, sect, l_sect;
|
||||
ulong start, now, last;
|
||||
|
||||
debug ("flash_erase: first: %d last: %d\n", s_first, s_last);
|
||||
|
||||
if ((s_first < 0) || (s_first > s_last)) {
|
||||
if (info->flash_id == FLASH_UNKNOWN) {
|
||||
printf ("- missing\n");
|
||||
|
||||
+387
-318
@@ -45,25 +45,19 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define FLASH_BANK_SIZE 0x200000
|
||||
#define FLASH_BANK_SIZE ((uint)(16 * 1024 * 1024)) /* max 16Mbyte */
|
||||
#define MAIN_SECT_SIZE 0x10000
|
||||
#define SECT_SIZE_32KB 0x8000
|
||||
#define SECT_SIZE_8KB 0x2000
|
||||
|
||||
flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
|
||||
flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
|
||||
|
||||
static int write_word (flash_info_t *info, ulong dest, ulong data);
|
||||
|
||||
static __inline__ unsigned long get_msr(void)
|
||||
{ unsigned long msr;
|
||||
__asm__ __volatile__ ("mfmsr %0" : "=r" (msr) :);
|
||||
return msr;
|
||||
}
|
||||
|
||||
static __inline__ void set_msr(unsigned long msr)
|
||||
{
|
||||
__asm__ __volatile__ ("mtmsr %0" : : "r" (msr));
|
||||
}
|
||||
static int write_word (flash_info_t * info, ulong dest, ulong data);
|
||||
#if 0
|
||||
static void write_via_fpu (vu_long * addr, ulong * data);
|
||||
#endif
|
||||
static __inline__ unsigned long get_msr (void);
|
||||
static __inline__ void set_msr (unsigned long msr);
|
||||
|
||||
/*flash command address offsets*/
|
||||
#define ADDR0 (0x555)
|
||||
@@ -77,285 +71,336 @@ static __inline__ void set_msr(unsigned long msr)
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
|
||||
unsigned long flash_init(void)
|
||||
unsigned long flash_init (void)
|
||||
{
|
||||
int i, j;
|
||||
ulong size = 0;
|
||||
int i; /* flash bank counter */
|
||||
int j; /* flash device sector counter */
|
||||
int k; /* flash size calculation loop counter */
|
||||
int N; /* pow(2,N) is flash size, but we don't have <math.h> */
|
||||
ulong total_size = 0, device_size = 1;
|
||||
unsigned char manuf_id, device_id;
|
||||
|
||||
for (i = 0; i < CFG_MAX_FLASH_BANKS; i++)
|
||||
{
|
||||
vu_char *addr = (vu_char *)(CFG_FLASH_BASE + i * FLASH_BANK_SIZE);
|
||||
for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
|
||||
vu_char *addr = (vu_char *) (CFG_FLASH_BASE + i * FLASH_BANK_SIZE);
|
||||
|
||||
addr[0x555] = 0xAA; /* 3 cycles to read device info. See */
|
||||
addr[0x2AA] = 0x55; /* AM29LV116D datasheet for list of */
|
||||
addr[0x555] = 0x90; /* available commands. */
|
||||
addr[0x555] = 0xAA; /* get manuf/device info command */
|
||||
addr[0x2AA] = 0x55; /* 3-cycle command */
|
||||
addr[0x555] = 0x90;
|
||||
|
||||
manuf_id = addr[0];
|
||||
device_id = addr[1];
|
||||
manuf_id = addr[0]; /* read back manuf/device info */
|
||||
device_id = addr[1];
|
||||
|
||||
addr[0x55] = 0x98; /* CFI command */
|
||||
N = addr[0x27]; /* read back device_size = pow(2,N) */
|
||||
|
||||
for (k = 0; k < N; k++) /* calculate device_size = pow(2,N) */
|
||||
device_size *= 2;
|
||||
|
||||
flash_info[i].size = device_size;
|
||||
flash_info[i].sector_count = CFG_MAX_FLASH_SECT;
|
||||
|
||||
#if defined DEBUG_FLASH
|
||||
printf("manuf_id = %x, device_id = %x\n", manuf_id, device_id);
|
||||
printf ("manuf_id = %x, device_id = %x\n", manuf_id, device_id);
|
||||
#endif
|
||||
/* find out what kind of flash we are using */
|
||||
if ((manuf_id == (uchar) (AMD_MANUFACT))
|
||||
&& (device_id == AMD_ID_LV033C)) {
|
||||
flash_info[i].flash_id =
|
||||
((FLASH_MAN_AMD & FLASH_VENDMASK) << 16) |
|
||||
(FLASH_AM033C & FLASH_TYPEMASK);
|
||||
|
||||
if ( (manuf_id == (uchar)(AMD_MANUFACT)) &&
|
||||
( device_id == AMD_ID_LV116DT))
|
||||
{
|
||||
flash_info[i].flash_id = ((FLASH_MAN_AMD & FLASH_VENDMASK) << 16) |
|
||||
(AMD_ID_LV116DT & FLASH_TYPEMASK);
|
||||
} else {
|
||||
flash_info[i].flash_id = FLASH_UNKNOWN;
|
||||
addr[0] = (long)0xFFFFFFFF;
|
||||
goto Done;
|
||||
/* set individual sector start addresses */
|
||||
for (j = 0; j < flash_info[i].sector_count; j++) {
|
||||
flash_info[i].start[j] =
|
||||
(CFG_FLASH_BASE + i * FLASH_BANK_SIZE +
|
||||
j * MAIN_SECT_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
else if ((manuf_id == (uchar) (AMD_MANUFACT)) &&
|
||||
(device_id == AMD_ID_LV116DT)) {
|
||||
flash_info[i].flash_id =
|
||||
((FLASH_MAN_AMD & FLASH_VENDMASK) << 16) |
|
||||
(FLASH_AM160T & FLASH_TYPEMASK);
|
||||
|
||||
/* set individual sector start addresses */
|
||||
for (j = 0; j < flash_info[i].sector_count; j++) {
|
||||
flash_info[i].start[j] =
|
||||
(CFG_FLASH_BASE + i * FLASH_BANK_SIZE +
|
||||
j * MAIN_SECT_SIZE);
|
||||
|
||||
if (j < (CFG_MAX_FLASH_SECT - 3)) {
|
||||
flash_info[i].start[j] =
|
||||
(CFG_FLASH_BASE + i * FLASH_BANK_SIZE +
|
||||
j * MAIN_SECT_SIZE);
|
||||
} else if (j == (CFG_MAX_FLASH_SECT - 3)) {
|
||||
flash_info[i].start[j] =
|
||||
(flash_info[i].start[j - 1] + SECT_SIZE_32KB);
|
||||
|
||||
} else {
|
||||
flash_info[i].start[j] =
|
||||
(flash_info[i].start[j - 1] + SECT_SIZE_8KB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
flash_info[i].flash_id = FLASH_UNKNOWN;
|
||||
addr[0] = 0xFF;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
#if defined DEBUG_FLASH
|
||||
printf ("flash_id = 0x%08lX\n", flash_info[i].flash_id);
|
||||
#endif
|
||||
|
||||
addr[0] = (long)0xFFFFFFFF;
|
||||
addr[0] = 0xFF;
|
||||
|
||||
flash_info[i].size = FLASH_BANK_SIZE;
|
||||
flash_info[i].sector_count = CFG_MAX_FLASH_SECT;
|
||||
memset(flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
|
||||
memset (flash_info[i].protect, 0, CFG_MAX_FLASH_SECT);
|
||||
|
||||
for (j = 0; j < flash_info[i].sector_count; j++)
|
||||
{
|
||||
total_size += flash_info[i].size;
|
||||
}
|
||||
|
||||
if (j < (CFG_MAX_FLASH_SECT - 3) )
|
||||
|
||||
flash_info[i].start[j] = CFG_FLASH_BASE + i * FLASH_BANK_SIZE +
|
||||
j * MAIN_SECT_SIZE;
|
||||
|
||||
else if (j == (CFG_MAX_FLASH_SECT - 3) )
|
||||
|
||||
flash_info[i].start[j] = flash_info[i].start[j-1] + SECT_SIZE_32KB;
|
||||
|
||||
|
||||
else
|
||||
|
||||
flash_info[i].start[j] = flash_info[i].start[j-1] + SECT_SIZE_8KB;
|
||||
|
||||
}
|
||||
|
||||
size += flash_info[i].size;
|
||||
}
|
||||
|
||||
/* Protect monitor and environment sectors
|
||||
*/
|
||||
/* Protect monitor and environment sectors
|
||||
*/
|
||||
#if CFG_MONITOR_BASE >= CFG_FLASH_BASE
|
||||
flash_protect(FLAG_PROTECT_SET, CFG_MONITOR_BASE,
|
||||
CFG_MONITOR_BASE + monitor_flash_len - 1, &flash_info[0]);
|
||||
flash_protect (FLAG_PROTECT_SET, CFG_MONITOR_BASE,
|
||||
CFG_MONITOR_BASE + monitor_flash_len - 1,
|
||||
&flash_info[0]);
|
||||
#endif
|
||||
|
||||
#if (CFG_ENV_IS_IN_FLASH == 1) && defined(CFG_ENV_ADDR)
|
||||
flash_protect(FLAG_PROTECT_SET, CFG_ENV_ADDR,
|
||||
CFG_ENV_ADDR + CFG_ENV_SIZE - 1, &flash_info[0]);
|
||||
flash_protect (FLAG_PROTECT_SET, CFG_ENV_ADDR,
|
||||
CFG_ENV_ADDR + CFG_ENV_SIZE - 1, &flash_info[0]);
|
||||
#endif
|
||||
|
||||
Done:
|
||||
return size;
|
||||
Done:
|
||||
return total_size;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
void flash_print_info(flash_info_t *info)
|
||||
void flash_print_info (flash_info_t * info)
|
||||
{
|
||||
static const char unk[] = "Unknown";
|
||||
const char *mfct = unk, *type = unk;
|
||||
unsigned int i;
|
||||
static const char unk[] = "Unknown";
|
||||
const char *mfct = unk, *type = unk;
|
||||
unsigned int i;
|
||||
|
||||
if(info->flash_id != FLASH_UNKNOWN)
|
||||
{
|
||||
switch(info->flash_id & FLASH_VENDMASK)
|
||||
{
|
||||
case FLASH_MAN_AMD: mfct = "AMD"; break;
|
||||
case FLASH_MAN_FUJ: mfct = "FUJITSU"; break;
|
||||
case FLASH_MAN_STM: mfct = "STM"; break;
|
||||
case FLASH_MAN_SST: mfct = "SST"; break;
|
||||
case FLASH_MAN_BM: mfct = "Bright Microelectonics"; break;
|
||||
case FLASH_MAN_INTEL: mfct = "Intel"; break;
|
||||
}
|
||||
if (info->flash_id != FLASH_UNKNOWN) {
|
||||
switch (info->flash_id & FLASH_VENDMASK) {
|
||||
case FLASH_MAN_AMD:
|
||||
mfct = "AMD";
|
||||
break;
|
||||
case FLASH_MAN_FUJ:
|
||||
mfct = "FUJITSU";
|
||||
break;
|
||||
case FLASH_MAN_STM:
|
||||
mfct = "STM";
|
||||
break;
|
||||
case FLASH_MAN_SST:
|
||||
mfct = "SST";
|
||||
break;
|
||||
case FLASH_MAN_BM:
|
||||
mfct = "Bright Microelectonics";
|
||||
break;
|
||||
case FLASH_MAN_INTEL:
|
||||
mfct = "Intel";
|
||||
break;
|
||||
}
|
||||
|
||||
switch(info->flash_id & FLASH_TYPEMASK)
|
||||
{
|
||||
case FLASH_AM040: type = "AM29F040B (512K * 8, uniform sector size)"; break;
|
||||
case FLASH_AM400B: type = "AM29LV400B (4 Mbit, bottom boot sect)"; break;
|
||||
case FLASH_AM400T: type = "AM29LV400T (4 Mbit, top boot sector)"; break;
|
||||
case FLASH_AM800B: type = "AM29LV800B (8 Mbit, bottom boot sect)"; break;
|
||||
case FLASH_AM800T: type = "AM29LV800T (8 Mbit, top boot sector)"; break;
|
||||
case FLASH_AM160T: type = "AM29LV160T (16 Mbit, top boot sector)"; break;
|
||||
case FLASH_AM320B: type = "AM29LV320B (32 Mbit, bottom boot sect)"; break;
|
||||
case FLASH_AM320T: type = "AM29LV320T (32 Mbit, top boot sector)"; break;
|
||||
case FLASH_STM800AB: type = "M29W800AB (8 Mbit, bottom boot sect)"; break;
|
||||
case FLASH_SST800A: type = "SST39LF/VF800 (8 Mbit, uniform sector size)"; break;
|
||||
case FLASH_SST160A: type = "SST39LF/VF160 (16 Mbit, uniform sector size)"; break;
|
||||
}
|
||||
}
|
||||
switch (info->flash_id & FLASH_TYPEMASK) {
|
||||
case FLASH_AM033C:
|
||||
type = "AM29LV033C (32 Mbit, uniform sector size)";
|
||||
break;
|
||||
case FLASH_AM160T:
|
||||
type = "AM29LV160T (16 Mbit, top boot sector)";
|
||||
break;
|
||||
case FLASH_AM040:
|
||||
type = "AM29F040B (512K * 8, uniform sector size)";
|
||||
break;
|
||||
case FLASH_AM400B:
|
||||
type = "AM29LV400B (4 Mbit, bottom boot sect)";
|
||||
break;
|
||||
case FLASH_AM400T:
|
||||
type = "AM29LV400T (4 Mbit, top boot sector)";
|
||||
break;
|
||||
case FLASH_AM800B:
|
||||
type = "AM29LV800B (8 Mbit, bottom boot sect)";
|
||||
break;
|
||||
case FLASH_AM800T:
|
||||
type = "AM29LV800T (8 Mbit, top boot sector)";
|
||||
break;
|
||||
case FLASH_AM320B:
|
||||
type = "AM29LV320B (32 Mbit, bottom boot sect)";
|
||||
break;
|
||||
case FLASH_AM320T:
|
||||
type = "AM29LV320T (32 Mbit, top boot sector)";
|
||||
break;
|
||||
case FLASH_STM800AB:
|
||||
type = "M29W800AB (8 Mbit, bottom boot sect)";
|
||||
break;
|
||||
case FLASH_SST800A:
|
||||
type = "SST39LF/VF800 (8 Mbit, uniform sector size)";
|
||||
break;
|
||||
case FLASH_SST160A:
|
||||
type = "SST39LF/VF160 (16 Mbit, uniform sector size)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf(
|
||||
"\n Brand: %s Type: %s\n"
|
||||
" Size: %lu KB in %d Sectors\n",
|
||||
mfct,
|
||||
type,
|
||||
info->size >> 10,
|
||||
info->sector_count
|
||||
);
|
||||
printf ("\n Brand: %s Type: %s\n"
|
||||
" Size: %lu KB in %d Sectors\n",
|
||||
mfct, type, info->size >> 10, info->sector_count);
|
||||
|
||||
printf (" Sector Start Addresses:");
|
||||
printf (" Sector Start Addresses:");
|
||||
|
||||
for (i = 0; i < info->sector_count; i++)
|
||||
{
|
||||
unsigned long size;
|
||||
unsigned int erased;
|
||||
unsigned long * flash = (unsigned long *) info->start[i];
|
||||
for (i = 0; i < info->sector_count; i++) {
|
||||
unsigned long size;
|
||||
unsigned int erased;
|
||||
unsigned long *flash = (unsigned long *) info->start[i];
|
||||
|
||||
/*
|
||||
* Check if whole sector is erased
|
||||
*/
|
||||
size =
|
||||
(i != (info->sector_count - 1)) ?
|
||||
(info->start[i + 1] - info->start[i]) >> 2 :
|
||||
(info->start[0] + info->size - info->start[i]) >> 2;
|
||||
/*
|
||||
* Check if whole sector is erased
|
||||
*/
|
||||
size = (i != (info->sector_count - 1)) ?
|
||||
(info->start[i + 1] - info->start[i]) >> 2 :
|
||||
(info->start[0] + info->size - info->start[i]) >> 2;
|
||||
|
||||
for(
|
||||
flash = (unsigned long *) info->start[i], erased = 1;
|
||||
(flash != (unsigned long *) info->start[i] + size) && erased;
|
||||
flash++
|
||||
)
|
||||
erased = *flash == ~0x0UL;
|
||||
for (flash = (unsigned long *) info->start[i], erased = 1;
|
||||
(flash != (unsigned long *) info->start[i] + size) && erased;
|
||||
flash++)
|
||||
erased = *flash == ~0x0UL;
|
||||
|
||||
printf(
|
||||
"%s %08lX %s %s",
|
||||
(i % 5) ? "" : "\n ",
|
||||
info->start[i],
|
||||
erased ? "E" : " ",
|
||||
info->protect[i] ? "RO" : " "
|
||||
);
|
||||
}
|
||||
printf ("%s %08lX %s %s",
|
||||
(i % 5) ? "" : "\n ",
|
||||
info->start[i],
|
||||
erased ? "E" : " ", info->protect[i] ? "RO" : " ");
|
||||
}
|
||||
|
||||
puts("\n");
|
||||
return;
|
||||
puts ("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
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 FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *)(info->start[0]);
|
||||
int flag, prot, sect, l_sect;
|
||||
ulong start, now, last;
|
||||
unsigned char sh8b;
|
||||
volatile FLASH_WORD_SIZE *addr = (FLASH_WORD_SIZE *) (info->start[0]);
|
||||
int flag, prot, sect, l_sect;
|
||||
ulong start, now, last;
|
||||
unsigned char sh8b;
|
||||
|
||||
if ((s_first < 0) || (s_first > s_last)) {
|
||||
if (info->flash_id == FLASH_UNKNOWN) {
|
||||
printf ("- missing\n");
|
||||
} else {
|
||||
printf ("- no sectors to erase\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if ((s_first < 0) || (s_first > s_last)) {
|
||||
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_MAN_STM | FLASH_AMD_COMP))) {
|
||||
printf ("Can't erase unknown flash type - aborted\n");
|
||||
return 1;
|
||||
}
|
||||
if ((info->flash_id == FLASH_UNKNOWN) ||
|
||||
(info->flash_id > (FLASH_MAN_STM | FLASH_AMD_COMP))) {
|
||||
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]) {
|
||||
prot++;
|
||||
}
|
||||
}
|
||||
prot = 0;
|
||||
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",
|
||||
prot);
|
||||
} else {
|
||||
printf ("\n");
|
||||
}
|
||||
if (prot) {
|
||||
printf ("- Warning: %d protected sectors will not be erased!\n",
|
||||
prot);
|
||||
} else {
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
l_sect = -1;
|
||||
l_sect = -1;
|
||||
|
||||
/* Check the ROM CS */
|
||||
if ((info->start[0] >= ROM_CS1_START) && (info->start[0] < ROM_CS0_START))
|
||||
sh8b = 3;
|
||||
else
|
||||
sh8b = 0;
|
||||
/* Check the ROM CS */
|
||||
if ((info->start[0] >= ROM_CS1_START)
|
||||
&& (info->start[0] < ROM_CS0_START))
|
||||
sh8b = 3;
|
||||
else
|
||||
sh8b = 0;
|
||||
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
flag = disable_interrupts ();
|
||||
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr[ADDR1 << sh8b] = (FLASH_WORD_SIZE)0x00550055;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE)0x00800080;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr[ADDR1 << sh8b] = (FLASH_WORD_SIZE)0x00550055;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE) 0x00AA00AA;
|
||||
addr[ADDR1 << sh8b] = (FLASH_WORD_SIZE) 0x00550055;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE) 0x00800080;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE) 0x00AA00AA;
|
||||
addr[ADDR1 << sh8b] = (FLASH_WORD_SIZE) 0x00550055;
|
||||
|
||||
/* Start erase on unprotected sectors */
|
||||
for (sect = s_first; sect<=s_last; sect++)
|
||||
{
|
||||
if (info->protect[sect] == 0)
|
||||
{ /* not protected */
|
||||
addr = (FLASH_WORD_SIZE *)(info->start[0] + (
|
||||
(info->start[sect] - info->start[0]) << sh8b));
|
||||
/* Start erase on unprotected sectors */
|
||||
for (sect = s_first; sect <= s_last; sect++) {
|
||||
if (info->protect[sect] == 0) { /* not protected */
|
||||
addr = (FLASH_WORD_SIZE *) (info->start[0] + ((info->
|
||||
start[sect] -
|
||||
info->
|
||||
start[0]) <<
|
||||
sh8b));
|
||||
|
||||
if (info->flash_id & FLASH_MAN_SST)
|
||||
{
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr[ADDR1 << sh8b] = (FLASH_WORD_SIZE)0x00550055;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE)0x00800080;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr[ADDR1 << sh8b] = (FLASH_WORD_SIZE)0x00550055;
|
||||
addr[0] = (FLASH_WORD_SIZE)0x00500050; /* block erase */
|
||||
udelay(30000); /* wait 30 ms */
|
||||
if (info->flash_id & FLASH_MAN_SST) {
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE) 0x00AA00AA;
|
||||
addr[ADDR1 << sh8b] = (FLASH_WORD_SIZE) 0x00550055;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE) 0x00800080;
|
||||
addr[ADDR0 << sh8b] = (FLASH_WORD_SIZE) 0x00AA00AA;
|
||||
addr[ADDR1 << sh8b] = (FLASH_WORD_SIZE) 0x00550055;
|
||||
addr[0] = (FLASH_WORD_SIZE) 0x00500050; /* block erase */
|
||||
udelay (30000); /* wait 30 ms */
|
||||
} else {
|
||||
addr[0] = (FLASH_WORD_SIZE) 0x00300030; /* sector erase */
|
||||
}
|
||||
|
||||
else
|
||||
addr[0] = (FLASH_WORD_SIZE)0x00300030; /* sector erase */
|
||||
|
||||
l_sect = sect;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag)
|
||||
enable_interrupts();
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag)
|
||||
enable_interrupts ();
|
||||
|
||||
/* wait at least 80us - let's wait 1 ms */
|
||||
udelay (1000);
|
||||
/* wait at least 80us - let's wait 1 ms */
|
||||
udelay (1000);
|
||||
|
||||
/*
|
||||
* We wait for the last triggered sector
|
||||
*/
|
||||
if (l_sect < 0)
|
||||
goto DONE;
|
||||
/*
|
||||
* We wait for the last triggered sector
|
||||
*/
|
||||
if (l_sect < 0)
|
||||
goto DONE;
|
||||
|
||||
start = get_timer (0);
|
||||
last = start;
|
||||
addr = (FLASH_WORD_SIZE *)(info->start[0] + (
|
||||
(info->start[l_sect] - info->start[0]) << sh8b));
|
||||
while ((addr[0] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080) {
|
||||
if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
|
||||
printf ("Timeout\n");
|
||||
return 1;
|
||||
}
|
||||
/* show that we're waiting */
|
||||
if ((now - last) > 1000) { /* every second */
|
||||
serial_putc ('.');
|
||||
last = now;
|
||||
}
|
||||
}
|
||||
start = get_timer (0);
|
||||
last = start;
|
||||
addr = (FLASH_WORD_SIZE *) (info->start[0] + ((info->start[l_sect] -
|
||||
info->
|
||||
start[0]) << sh8b));
|
||||
while ((addr[0] & (FLASH_WORD_SIZE) 0x00800080) !=
|
||||
(FLASH_WORD_SIZE) 0x00800080) {
|
||||
if ((now = get_timer (start)) > CFG_FLASH_ERASE_TOUT) {
|
||||
printf ("Timeout\n");
|
||||
return 1;
|
||||
}
|
||||
/* show that we're waiting */
|
||||
if ((now - last) > 1000) { /* every second */
|
||||
serial_putc ('.');
|
||||
last = now;
|
||||
}
|
||||
}
|
||||
|
||||
DONE:
|
||||
/* reset to read mode */
|
||||
addr = (FLASH_WORD_SIZE *)info->start[0];
|
||||
addr[0] = (FLASH_WORD_SIZE)0x00F000F0; /* reset bank */
|
||||
DONE:
|
||||
/* reset to read mode */
|
||||
addr = (FLASH_WORD_SIZE *) info->start[0];
|
||||
addr[0] = (FLASH_WORD_SIZE) 0x00F000F0; /* reset bank */
|
||||
|
||||
printf (" done\n");
|
||||
return 0;
|
||||
printf (" done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -366,68 +411,68 @@ 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;
|
||||
ulong cp, wp, data;
|
||||
int i, l, rc;
|
||||
|
||||
wp = (addr & ~3); /* get lower word aligned address */
|
||||
wp = (addr & ~3); /* get lower word aligned address */
|
||||
|
||||
/*
|
||||
* handle unaligned start bytes
|
||||
*/
|
||||
if ((l = addr - wp) != 0) {
|
||||
data = 0;
|
||||
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);
|
||||
}
|
||||
/*
|
||||
* handle unaligned start bytes
|
||||
*/
|
||||
if ((l = addr - wp) != 0) {
|
||||
data = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
}
|
||||
wp += 4;
|
||||
}
|
||||
if ((rc = write_word (info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
}
|
||||
wp += 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle word aligned part
|
||||
*/
|
||||
while (cnt >= 4) {
|
||||
data = 0;
|
||||
for (i=0; i<4; ++i) {
|
||||
data = (data << 8) | *src++;
|
||||
}
|
||||
if ((rc = write_word(info, wp, data)) != 0) {
|
||||
return (rc);
|
||||
}
|
||||
wp += 4;
|
||||
cnt -= 4;
|
||||
}
|
||||
/*
|
||||
* handle word aligned part
|
||||
*/
|
||||
while (cnt >= 4) {
|
||||
data = 0;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
data = (data << 8) | *src++;
|
||||
}
|
||||
if ((rc = write_word (info, wp, data)) != 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) {
|
||||
data = (data << 8) | *src++;
|
||||
--cnt;
|
||||
}
|
||||
for (; i<4; ++i, ++cp) {
|
||||
data = (data << 8) | (*(uchar *)cp);
|
||||
}
|
||||
/*
|
||||
* handle unaligned tail bytes
|
||||
*/
|
||||
data = 0;
|
||||
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);
|
||||
}
|
||||
|
||||
return (write_word(info, wp, data));
|
||||
return (write_word (info, wp, data));
|
||||
}
|
||||
|
||||
|
||||
@@ -437,55 +482,79 @@ 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 FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *)info->start[0];
|
||||
volatile FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *) info->start[0];
|
||||
volatile FLASH_WORD_SIZE *dest2;
|
||||
volatile FLASH_WORD_SIZE *data2 = (FLASH_WORD_SIZE *)&data;
|
||||
volatile FLASH_WORD_SIZE *data2 = (FLASH_WORD_SIZE *) & data;
|
||||
ulong start;
|
||||
int flag;
|
||||
int i;
|
||||
unsigned char sh8b;
|
||||
|
||||
/* Check the ROM CS */
|
||||
if ((info->start[0] >= ROM_CS1_START) && (info->start[0] < ROM_CS0_START))
|
||||
sh8b = 3;
|
||||
else
|
||||
sh8b = 0;
|
||||
/* Check the ROM CS */
|
||||
if ((info->start[0] >= ROM_CS1_START)
|
||||
&& (info->start[0] < ROM_CS0_START))
|
||||
sh8b = 3;
|
||||
else
|
||||
sh8b = 0;
|
||||
|
||||
dest2 = (FLASH_WORD_SIZE *)(((dest - info->start[0]) << sh8b) +
|
||||
info->start[0]);
|
||||
dest2 = (FLASH_WORD_SIZE *) (((dest - info->start[0]) << sh8b) +
|
||||
info->start[0]);
|
||||
|
||||
/* Check if Flash is (sufficiently) erased */
|
||||
if ((*dest2 & (FLASH_WORD_SIZE)data) != (FLASH_WORD_SIZE)data) {
|
||||
return (2);
|
||||
}
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
/* Check if Flash is (sufficiently) erased */
|
||||
if ((*dest2 & (FLASH_WORD_SIZE) data) != (FLASH_WORD_SIZE) data) {
|
||||
return (2);
|
||||
}
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts ();
|
||||
|
||||
for (i=0; i<4/sizeof(FLASH_WORD_SIZE); i++)
|
||||
{
|
||||
addr2[ADDR0 << sh8b] = (FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr2[ADDR1 << sh8b] = (FLASH_WORD_SIZE)0x00550055;
|
||||
addr2[ADDR0 << sh8b] = (FLASH_WORD_SIZE)0x00A000A0;
|
||||
for (i = 0; i < 4 / sizeof (FLASH_WORD_SIZE); i++) {
|
||||
addr2[ADDR0 << sh8b] = (FLASH_WORD_SIZE) 0x00AA00AA;
|
||||
addr2[ADDR1 << sh8b] = (FLASH_WORD_SIZE) 0x00550055;
|
||||
addr2[ADDR0 << sh8b] = (FLASH_WORD_SIZE) 0x00A000A0;
|
||||
|
||||
dest2[i << sh8b] = data2[i];
|
||||
dest2[i << sh8b] = data2[i];
|
||||
|
||||
/* 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 ((dest2[i << sh8b] & (FLASH_WORD_SIZE)0x00800080) !=
|
||||
(data2[i] & (FLASH_WORD_SIZE)0x00800080)) {
|
||||
if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* data polling for D7 */
|
||||
start = get_timer (0);
|
||||
while ((dest2[i << sh8b] & (FLASH_WORD_SIZE) 0x00800080) !=
|
||||
(data2[i] & (FLASH_WORD_SIZE) 0x00800080)) {
|
||||
if (get_timer (start) > CFG_FLASH_WRITE_TOUT) {
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
#if 0
|
||||
static void write_via_fpu (vu_long * addr, ulong * data)
|
||||
{
|
||||
__asm__ __volatile__ ("lfd 1, 0(%0)"::"r" (data));
|
||||
__asm__ __volatile__ ("stfd 1, 0(%0)"::"r" (addr));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
static __inline__ unsigned long get_msr (void)
|
||||
{
|
||||
unsigned long msr;
|
||||
|
||||
__asm__ __volatile__ ("mfmsr %0":"=r" (msr):);
|
||||
|
||||
return msr;
|
||||
}
|
||||
|
||||
static __inline__ void set_msr (unsigned long msr)
|
||||
{
|
||||
__asm__ __volatile__ ("mtmsr %0"::"r" (msr));
|
||||
}
|
||||
+24
-11
@@ -30,6 +30,7 @@
|
||||
#include <mpc824x.h>
|
||||
#include <asm/processor.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/mmu.h>
|
||||
#include <pci.h>
|
||||
|
||||
#define SAVE_SZ 32
|
||||
@@ -53,11 +54,18 @@ long int initdram(int board_type)
|
||||
volatile ulong *addr;
|
||||
ulong save[SAVE_SZ];
|
||||
ulong val, ret = 0;
|
||||
/*
|
||||
write_bat(IBAT1, ((CFG_MAX_RAM_SIZE/2) | BATU_BL_256M | BATU_VS | BATU_VP),
|
||||
( (CFG_MAX_RAM_SIZE/2)| BATL_PP_10 | BATL_MEMCOHERENCE));
|
||||
|
||||
for (i=0; i<SAVE_SZ; i++) {save[i] = 0;} /* clear table */
|
||||
write_bat(DBAT1, ((CFG_MAX_RAM_SIZE/2) | BATU_BL_256M | BATU_VS | BATU_VP),
|
||||
( (CFG_MAX_RAM_SIZE/2)| BATL_PP_10 | BATL_MEMCOHERENCE));
|
||||
*/
|
||||
for (i=0; i<SAVE_SZ; i++) {
|
||||
save[i] = 0; /* clear table */
|
||||
}
|
||||
|
||||
for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1)
|
||||
{
|
||||
for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
|
||||
addr = (volatile ulong *)base + cnt;
|
||||
save[i++] = *addr;
|
||||
*addr = ~cnt;
|
||||
@@ -67,19 +75,16 @@ long int initdram(int board_type)
|
||||
save[i] = *addr;
|
||||
*addr = 0;
|
||||
|
||||
if (*addr != 0)
|
||||
{
|
||||
if (*addr != 0) {
|
||||
*addr = save[i];
|
||||
goto Done;
|
||||
}
|
||||
|
||||
for (cnt = 1; cnt < CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1)
|
||||
{
|
||||
for (cnt = 1; cnt < CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1) {
|
||||
addr = (volatile ulong *)base + cnt;
|
||||
val = *addr;
|
||||
*addr = save[--i];
|
||||
if (val != ~cnt)
|
||||
{
|
||||
if (val != ~cnt) {
|
||||
ulong new_bank0_end = cnt * sizeof(long) - 1;
|
||||
ulong mear1 = mpc824x_mpc107_getreg(MEAR1);
|
||||
ulong emear1 = mpc824x_mpc107_getreg(EMEAR1);
|
||||
@@ -111,11 +116,11 @@ Done:
|
||||
|
||||
static struct pci_config_table pci_utx8245_config_table[] = {
|
||||
#ifndef CONFIG_PCI_PNP
|
||||
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
||||
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x0C, PCI_ANY_ID,
|
||||
pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
|
||||
PCI_ENET0_MEMADDR,
|
||||
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
|
||||
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
||||
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x0B, PCI_ANY_ID,
|
||||
pci_cfgfunc_config_device, { PCI_FIREWIRE_IOADDR,
|
||||
PCI_FIREWIRE_MEMADDR,
|
||||
PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
|
||||
@@ -133,6 +138,14 @@ static void pci_utx8245_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
|
||||
else if (PCI_DEV(dev) == 12)
|
||||
/* assign serial interrupt line 8 (int24) to Ethernet */
|
||||
pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, 24);
|
||||
|
||||
else if (PCI_DEV(dev) == 14)
|
||||
/* assign serial interrupt line 0 (int16) to PMC slot 0 */
|
||||
pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, 16);
|
||||
|
||||
else if (PCI_DEV(dev) == 15)
|
||||
/* assign serial interrupt line 1 (int17) to PMC slot 1 */
|
||||
pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, 17);
|
||||
}
|
||||
|
||||
static struct pci_controller utx8245_hose = {
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ COBJS = main.o altera.o bedbug.o \
|
||||
cmd_jffs2.o cmd_log.o cmd_mem.o cmd_mii.o cmd_misc.o \
|
||||
cmd_net.o cmd_nvedit.o env_common.o \
|
||||
env_flash.o env_eeprom.o env_nvram.o env_nowhere.o \
|
||||
cmd_pci.o cmd_pcmcia.o \
|
||||
cmd_pci.o cmd_pcmcia.o cmd_portio.o \
|
||||
cmd_reginfo.o cmd_scsi.o cmd_vfd.o cmd_usb.o \
|
||||
command.o console.o devices.o dlmalloc.o \
|
||||
docecc.o environment.o flash.o fpga.o \
|
||||
|
||||
+2
-1
@@ -31,7 +31,8 @@
|
||||
#include <command.h>
|
||||
#include <cmd_mem.h>
|
||||
|
||||
#if (CONFIG_COMMANDS & (CFG_CMD_MEMORY | CFG_CMD_PCI | CFG_CMD_I2C))
|
||||
#if (CONFIG_COMMANDS & (CFG_CMD_MEMORY | CFG_CMD_PCI | CFG_CMD_I2C\
|
||||
| CMD_CMD_PORTIO))
|
||||
int cmd_get_data_size(char* arg, int default_size)
|
||||
{
|
||||
/* Check for a size specification .b, .w or .l.
|
||||
|
||||
+297
-291
@@ -20,9 +20,9 @@
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
|
||||
|
||||
#include <linux/mtd/nftl.h>
|
||||
#include <linux/mtd/nand.h>
|
||||
#include <linux/mtd/nand_ids.h>
|
||||
#include <jffs2/jffs2.h>
|
||||
|
||||
/*
|
||||
* Definition of the out of band configuration structure
|
||||
@@ -33,14 +33,32 @@ struct nand_oob_config {
|
||||
int eccvalid_pos; /* position of ECC valid flag inside oob -1 = inactive */
|
||||
} oob_config = { {0}, 0, 0};
|
||||
|
||||
#define NAND_DEBUG
|
||||
#undef ECC_DEBUG
|
||||
#undef NAND_DEBUG
|
||||
#undef PSYCHO_DEBUG
|
||||
#undef NFTL_DEBUG
|
||||
|
||||
/* ****************** WARNING *********************
|
||||
* When ALLOW_ERASE_BAD_DEBUG is non-zero the erase command will
|
||||
* erase (or at least attempt to erase) blocks that are marked
|
||||
* bad. This can be very handy if you are _sure_ that the block
|
||||
* is OK, say because you marked a good block bad to test bad
|
||||
* block handling and you are done testing, or if you have
|
||||
* accidentally marked blocks bad.
|
||||
*
|
||||
* Erasing factory marked bad blocks is a _bad_ idea. If the
|
||||
* erase succeeds there is no reliable way to find them again,
|
||||
* and attempting to program or erase bad blocks can affect
|
||||
* the data in _other_ (good) blocks.
|
||||
*/
|
||||
#define ALLOW_ERASE_BAD_DEBUG 0
|
||||
|
||||
#define CONFIG_MTD_NAND_ECC /* enable ECC */
|
||||
/* #define CONFIG_MTD_NAND_ECC_JFFS2 */
|
||||
|
||||
/* bits for nand_rw() `cmd'; or together as needed */
|
||||
#define NANDRW_READ 0x01
|
||||
#define NANDRW_WRITE 0x00
|
||||
#define NANDRW_JFFS2 0x02
|
||||
|
||||
/*
|
||||
* Function Prototypes
|
||||
*/
|
||||
@@ -48,17 +66,22 @@ static void nand_print(struct nand_chip *nand);
|
||||
static int nand_rw (struct nand_chip* nand, int cmd,
|
||||
size_t start, size_t len,
|
||||
size_t * retlen, u_char * buf);
|
||||
static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len);
|
||||
static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len, int clean);
|
||||
static int nand_read_ecc(struct nand_chip *nand, size_t start, size_t len,
|
||||
size_t * retlen, u_char *buf, u_char *ecc_code);
|
||||
static int nand_write_ecc (struct nand_chip* nand, size_t to, size_t len,
|
||||
size_t * retlen, const u_char * buf, u_char * ecc_code);
|
||||
static void nand_print_bad(struct nand_chip *nand);
|
||||
static int nand_read_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
size_t * retlen, u_char * buf);
|
||||
static int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
size_t * retlen, const u_char * buf);
|
||||
#ifdef CONFIG_MTD_NAND_ECC
|
||||
static int nand_correct_data (u_char *dat, u_char *read_ecc, u_char *calc_ecc);
|
||||
static void nand_calculate_ecc (const u_char *dat, u_char *ecc_code);
|
||||
#endif
|
||||
|
||||
static struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE] = {{0}};
|
||||
struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE] = {{0}};
|
||||
|
||||
/* Current NAND Device */
|
||||
static int curr_device = -1;
|
||||
@@ -96,6 +119,16 @@ int do_nand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
printf ("\nDevice %d: ", curr_device);
|
||||
nand_print(&nand_dev_desc[curr_device]);
|
||||
return 0;
|
||||
|
||||
} else if (strcmp(argv[1],"bad") == 0) {
|
||||
if ((curr_device < 0) || (curr_device >= CFG_MAX_NAND_DEVICE)) {
|
||||
puts ("\nno devices available\n");
|
||||
return 1;
|
||||
}
|
||||
printf ("\nDevice %d bad blocks:\n", curr_device);
|
||||
nand_print_bad(&nand_dev_desc[curr_device]);
|
||||
return 0;
|
||||
|
||||
}
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
@@ -121,38 +154,86 @@ int do_nand (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if (strcmp(argv[1],"erase") == 0 && strcmp(argv[2], "clean") == 0) {
|
||||
struct nand_chip* nand = &nand_dev_desc[curr_device];
|
||||
ulong off = 0;
|
||||
ulong size = nand->totlen;
|
||||
int ret;
|
||||
|
||||
printf ("\nNAND erase: device %d offset %ld, size %ld ... ",
|
||||
curr_device, off, size);
|
||||
|
||||
ret = nand_erase (nand, off, size, 1);
|
||||
|
||||
printf("%s\n", ret ? "ERROR" : "OK");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
default:
|
||||
/* at least 4 args */
|
||||
|
||||
if (strcmp(argv[1],"read") == 0 || strcmp(argv[1],"write") == 0) {
|
||||
if (strncmp(argv[1], "read", 4) == 0 ||
|
||||
strncmp(argv[1], "write", 5) == 0) {
|
||||
ulong addr = simple_strtoul(argv[2], NULL, 16);
|
||||
ulong off = simple_strtoul(argv[3], NULL, 16);
|
||||
ulong size = simple_strtoul(argv[4], NULL, 16);
|
||||
int cmd = (strcmp(argv[1],"read") == 0);
|
||||
int cmd = (strncmp(argv[1], "read", 4) == 0) ?
|
||||
NANDRW_READ : NANDRW_WRITE;
|
||||
int ret, total;
|
||||
char* cmdtail = strchr(argv[1], '.');
|
||||
|
||||
if (cmdtail && !strncmp(cmdtail, ".oob", 2)) {
|
||||
/* read out-of-band data */
|
||||
if (cmd & NANDRW_READ) {
|
||||
ret = nand_read_oob(nand_dev_desc + curr_device,
|
||||
off, size, &total,
|
||||
(u_char*)addr);
|
||||
}
|
||||
else {
|
||||
ret = nand_write_oob(nand_dev_desc + curr_device,
|
||||
off, size, &total,
|
||||
(u_char*)addr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
else if (cmdtail && !strncmp(cmdtail, ".jffs2", 2))
|
||||
cmd |= NANDRW_JFFS2; /* skip bad blocks */
|
||||
#ifdef SXNI855T
|
||||
/* need ".e" same as ".j" for compatibility with older units */
|
||||
else if (cmdtail && !strcmp(cmdtail, ".e"))
|
||||
cmd |= NANDRW_JFFS2; /* skip bad blocks */
|
||||
#endif
|
||||
else if (cmdtail) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf ("\nNAND %s: device %d offset %ld, size %ld ... ",
|
||||
cmd ? "read" : "write", curr_device, off, size);
|
||||
(cmd & NANDRW_READ) ? "read" : "write",
|
||||
curr_device, off, size);
|
||||
|
||||
ret = nand_rw(nand_dev_desc + curr_device, cmd, off, size,
|
||||
&total, (u_char*)addr);
|
||||
|
||||
printf ("%d bytes %s: %s\n", total, cmd ? "read" : "write",
|
||||
printf ("%d bytes %s: %s\n", total,
|
||||
(cmd & NANDRW_READ) ? "read" : "write",
|
||||
ret ? "ERROR" : "OK");
|
||||
|
||||
return ret;
|
||||
} else if (strcmp(argv[1],"erase") == 0) {
|
||||
ulong off = simple_strtoul(argv[2], NULL, 16);
|
||||
ulong size = simple_strtoul(argv[3], NULL, 16);
|
||||
} else if (strcmp(argv[1],"erase") == 0 &&
|
||||
(argc == 4 || strcmp("clean", argv[2]) == 0)) {
|
||||
int clean = argc == 5;
|
||||
ulong off = simple_strtoul(argv[2 + clean], NULL, 16);
|
||||
ulong size = simple_strtoul(argv[3 + clean], NULL, 16);
|
||||
int ret;
|
||||
|
||||
printf ("\nNAND erase: device %d offset %ld, size %ld ... ",
|
||||
curr_device, off, size);
|
||||
|
||||
ret = nand_erase (nand_dev_desc + curr_device, off, size);
|
||||
ret = nand_erase (nand_dev_desc + curr_device, off, size, clean);
|
||||
|
||||
printf("%s\n", ret ? "ERROR" : "OK");
|
||||
|
||||
@@ -215,11 +296,11 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf ("\nLoading from device %d: %s at 0x%lX (offset 0x%lX)\n",
|
||||
printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
|
||||
dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
|
||||
offset);
|
||||
|
||||
if (nand_rw (nand_dev_desc + dev, 1, offset,
|
||||
if (nand_rw (nand_dev_desc + dev, NANDRW_READ, offset,
|
||||
SECTORSIZE, NULL, (u_char *)addr)) {
|
||||
printf ("** Read error on %d\n", dev);
|
||||
SHOW_BOOT_PROGRESS (-1);
|
||||
@@ -240,7 +321,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (nand_rw (nand_dev_desc + dev, 1, offset + SECTORSIZE, cnt,
|
||||
if (nand_rw (nand_dev_desc + dev, NANDRW_READ, offset + SECTORSIZE, cnt,
|
||||
NULL, (u_char *)(addr+SECTORSIZE))) {
|
||||
printf ("** Read error on %d\n", dev);
|
||||
SHOW_BOOT_PROGRESS (-1);
|
||||
@@ -259,7 +340,7 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
local_args[0] = argv[0];
|
||||
local_args[1] = NULL;
|
||||
|
||||
printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
|
||||
printf ("Automatic boot of image at addr 0x%08lx ...\n", addr);
|
||||
|
||||
do_bootm (cmdtp, 0, 1, local_args);
|
||||
rcode = 1;
|
||||
@@ -267,23 +348,103 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
return rcode;
|
||||
}
|
||||
|
||||
/* returns 0 if block containing pos is OK:
|
||||
* valid erase block and
|
||||
* not marked bad, or no bad mark position is specified
|
||||
* returns 1 if marked bad or otherwise invalid
|
||||
*/
|
||||
int check_block(struct nand_chip* nand, unsigned long pos)
|
||||
{
|
||||
int retlen;
|
||||
uint8_t oob_data;
|
||||
int page0 = pos & (-nand->erasesize);
|
||||
int page1 = page0 + nand->oobblock;
|
||||
int badpos = oob_config.badblock_pos;
|
||||
|
||||
if (pos >= nand->totlen)
|
||||
return 1;
|
||||
|
||||
if (badpos < 0)
|
||||
return 0; /* no way to check, assume OK */
|
||||
|
||||
/* Note - bad block marker can be on first or second page */
|
||||
if (nand_read_oob(nand, page0 + badpos, 1, &retlen, &oob_data) ||
|
||||
oob_data != 0xff ||
|
||||
nand_read_oob(nand, page1 + badpos, 1, &retlen, &oob_data) ||
|
||||
oob_data != 0xff)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* print bad blocks in NAND flash */
|
||||
static void nand_print_bad(struct nand_chip* nand)
|
||||
{
|
||||
unsigned long pos;
|
||||
|
||||
for (pos = 0; pos < nand->totlen; pos += nand->erasesize) {
|
||||
if (check_block(nand, pos))
|
||||
printf(" 0x%8.8lx\n", pos);
|
||||
}
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
/* cmd: 0: NANDRW_WRITE write, fail on bad block
|
||||
* 1: NANDRW_READ read, fail on bad block
|
||||
* 2: NANDRW_WRITE | NANDRW_JFFS2 write, skip bad blocks
|
||||
* 3: NANDRW_READ | NANDRW_JFFS2 read, data all 0xff for bad blocks
|
||||
*/
|
||||
static int nand_rw (struct nand_chip* nand, int cmd,
|
||||
size_t start, size_t len,
|
||||
size_t * retlen, u_char * buf)
|
||||
{
|
||||
int noecc, ret = 0, n, total = 0;
|
||||
char eccbuf[6];
|
||||
/* eblk (once set) is the start of the erase block containing the
|
||||
* data being processed.
|
||||
*/
|
||||
unsigned long eblk = ~0; /* force mismatch on first pass */
|
||||
unsigned long erasesize = nand->erasesize;
|
||||
|
||||
while(len) {
|
||||
while (len) {
|
||||
if ((start & (-erasesize)) != eblk) {
|
||||
/* have crossed into new erase block, deal with
|
||||
* it if it is sure marked bad.
|
||||
*/
|
||||
eblk = start & (-erasesize); /* start of block */
|
||||
if (check_block(nand, eblk)) {
|
||||
if (cmd == (NANDRW_READ | NANDRW_JFFS2)) {
|
||||
while (len > 0 &&
|
||||
start - eblk < erasesize) {
|
||||
*(buf++) = 0xff;
|
||||
++start;
|
||||
++total;
|
||||
--len;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (cmd == (NANDRW_WRITE | NANDRW_JFFS2)) {
|
||||
/* skip bad block */
|
||||
start += erasesize;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* The ECC will not be calculated correctly if
|
||||
less than 512 is written or read */
|
||||
noecc = (start != (start | 0x1ff) + 1) || (len < 0x200);
|
||||
if (cmd)
|
||||
ret = nand_read_ecc(nand, start, len,
|
||||
if (cmd & NANDRW_READ)
|
||||
ret = nand_read_ecc(nand, start,
|
||||
min(len, eblk + erasesize - start),
|
||||
&n, (u_char*)buf,
|
||||
noecc ? NULL : eccbuf);
|
||||
else
|
||||
ret = nand_write_ecc(nand, start, len,
|
||||
ret = nand_write_ecc(nand, start,
|
||||
min(len, eblk + erasesize - start),
|
||||
&n, (u_char*)buf,
|
||||
noecc ? NULL : eccbuf);
|
||||
|
||||
@@ -303,30 +464,18 @@ static int nand_rw (struct nand_chip* nand, int cmd,
|
||||
|
||||
static void nand_print(struct nand_chip *nand)
|
||||
{
|
||||
printf("%s at 0x%lX,\n"
|
||||
"\t %d chip%s %s, size %d MB, \n"
|
||||
"\t total size %ld MB, sector size %ld kB\n",
|
||||
nand->name, nand->IO_ADDR, nand->numchips,
|
||||
nand->numchips>1 ? "s" : "", nand->chips_name,
|
||||
1 << (nand->chipshift - 20),
|
||||
nand->totlen >> 20, nand->erasesize >> 10);
|
||||
|
||||
if (nand->nftl_found) {
|
||||
struct NFTLrecord *nftl = &nand->nftl;
|
||||
unsigned long bin_size, flash_size;
|
||||
|
||||
bin_size = nftl->nb_boot_blocks * nand->erasesize;
|
||||
flash_size = (nftl->nb_blocks - nftl->nb_boot_blocks) * nand->erasesize;
|
||||
|
||||
printf("\t NFTL boot record:\n"
|
||||
"\t Binary partition: size %ld%s\n"
|
||||
"\t Flash disk partition: size %ld%s, offset 0x%lx\n",
|
||||
bin_size > (1 << 20) ? bin_size >> 20 : bin_size >> 10,
|
||||
bin_size > (1 << 20) ? "MB" : "kB",
|
||||
flash_size > (1 << 20) ? flash_size >> 20 : flash_size >> 10,
|
||||
flash_size > (1 << 20) ? "MB" : "kB", bin_size);
|
||||
} else {
|
||||
puts ("\t No NFTL boot record found.\n");
|
||||
if (nand->numchips > 1) {
|
||||
printf("%s at 0x%lx,\n"
|
||||
"\t %d chips %s, size %d MB, \n"
|
||||
"\t total size %ld MB, sector size %ld kB\n",
|
||||
nand->name, nand->IO_ADDR, nand->numchips,
|
||||
nand->chips_name, 1 << (nand->chipshift - 20),
|
||||
nand->totlen >> 20, nand->erasesize >> 10);
|
||||
}
|
||||
else {
|
||||
printf("%s at 0x%lx (", nand->chips_name, nand->IO_ADDR);
|
||||
print_size(nand->totlen, ", ");
|
||||
print_size(nand->erasesize, " sector)\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,6 +633,7 @@ static int NanD_IdentChip(struct nand_chip *nand, int floor, int chip)
|
||||
nand->chipshift =
|
||||
nand_flash_ids[i].chipshift;
|
||||
nand->page256 = nand_flash_ids[i].page256;
|
||||
nand->eccsize = 256;
|
||||
if (nand->page256) {
|
||||
nand->oobblock = 256;
|
||||
nand->oobsize = 8;
|
||||
@@ -579,41 +729,12 @@ static void NanD_ScanChips(struct nand_chip *nand)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTD_NAND_ECC
|
||||
/* we need to be fast here, 1 us per read translates to 1 second per meg */
|
||||
static void nand_fast_copy (unsigned char *source, unsigned char *dest, long cntr)
|
||||
static void NanD_ReadBuf(struct nand_chip *nand, u_char *data_buf, int cntr)
|
||||
{
|
||||
while (cntr > 16) {
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
*dest++ = *source++;
|
||||
cntr -= 16;
|
||||
}
|
||||
unsigned long nandptr = nand->IO_ADDR;
|
||||
|
||||
while (cntr > 0) {
|
||||
*dest++ = *source++;
|
||||
cntr--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* we need to be fast here, 1 us per read translates to 1 second per meg */
|
||||
static void nand_fast_read(unsigned char *data_buf, int cntr, unsigned long nandptr)
|
||||
{
|
||||
while (cntr > 16) {
|
||||
while (cntr >= 16) {
|
||||
*data_buf++ = READ_NAND(nandptr);
|
||||
*data_buf++ = READ_NAND(nandptr);
|
||||
*data_buf++ = READ_NAND(nandptr);
|
||||
@@ -639,14 +760,6 @@ static void nand_fast_read(unsigned char *data_buf, int cntr, unsigned long nand
|
||||
}
|
||||
}
|
||||
|
||||
/* This routine is made available to other mtd code via
|
||||
* inter_module_register. It must only be accessed through
|
||||
* inter_module_get which will bump the use count of this module. The
|
||||
* addresses passed back in mtd are valid as long as the use count of
|
||||
* this module is non-zero, i.e. between inter_module_get and
|
||||
* inter_module_put. Keith Owens <kaos@ocs.com.au> 29 Oct 2000.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NAND read with ECC
|
||||
*/
|
||||
@@ -661,7 +774,6 @@ static int nand_read_ecc(struct nand_chip *nand, size_t start, size_t len,
|
||||
u_char *data_poi;
|
||||
u_char ecc_calc[6];
|
||||
#endif
|
||||
unsigned long nandptr = nand->IO_ADDR;
|
||||
|
||||
/* Do not allow reads past end of device */
|
||||
if ((start + len) > nand->totlen) {
|
||||
@@ -696,7 +808,7 @@ static int nand_read_ecc(struct nand_chip *nand, size_t start, size_t len,
|
||||
NanD_Command(nand, NAND_CMD_READ0);
|
||||
NanD_Address(nand, ADDR_COLUMN_PAGE, (page << nand->page_shift) + col);
|
||||
/* Read in a page + oob data */
|
||||
nand_fast_read(nand->data_buf, nand->oobblock + nand->oobsize, nandptr);
|
||||
NanD_ReadBuf(nand, nand->data_buf, nand->oobblock + nand->oobsize);
|
||||
|
||||
/* copy data into cache, for read out of cache and if ecc fails */
|
||||
if (nand->data_cache)
|
||||
@@ -719,7 +831,8 @@ static int nand_read_ecc(struct nand_chip *nand, size_t start, size_t len,
|
||||
break;
|
||||
case 1:
|
||||
case 2: /* transfer ECC corrected data to cache */
|
||||
memcpy (nand->data_cache, nand->data_buf, 256);
|
||||
if (nand->data_cache)
|
||||
memcpy (nand->data_cache, nand->data_buf, 256);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -745,10 +858,10 @@ readdata:
|
||||
data_poi = (nand->data_cache) ? nand->data_cache : nand->data_buf;
|
||||
data_poi += col;
|
||||
if ((*retlen + (nand->oobblock - col)) >= len) {
|
||||
nand_fast_copy (data_poi, buf + *retlen, len - *retlen);
|
||||
memcpy (buf + *retlen, data_poi, len - *retlen);
|
||||
*retlen = len;
|
||||
} else {
|
||||
nand_fast_copy (data_poi, buf + *retlen, nand->oobblock - col);
|
||||
memcpy (buf + *retlen, data_poi, nand->oobblock - col);
|
||||
*retlen += nand->oobblock - col;
|
||||
}
|
||||
/* Set cache page address, invalidate, if ecc_failed */
|
||||
@@ -763,12 +876,12 @@ readdata:
|
||||
NanD_Address(nand, ADDR_COLUMN_PAGE, (page << nand->page_shift) + col);
|
||||
/* Read the data directly into the return buffer */
|
||||
if ((*retlen + (nand->oobblock - col)) >= len) {
|
||||
nand_fast_read(buf + *retlen, len - *retlen, nandptr);
|
||||
NanD_ReadBuf(nand, buf + *retlen, len - *retlen);
|
||||
*retlen = len;
|
||||
/* We're done */
|
||||
continue;
|
||||
} else {
|
||||
nand_fast_read(buf + *retlen, nand->oobblock - col, nandptr);
|
||||
NanD_ReadBuf(nand, buf + *retlen, nand->oobblock - col);
|
||||
*retlen += nand->oobblock - col;
|
||||
}
|
||||
#endif
|
||||
@@ -847,6 +960,7 @@ static int nand_write_page (struct nand_chip *nand,
|
||||
nand->data_buf[i] = 0xff;
|
||||
|
||||
/* Send command to begin auto page programming */
|
||||
NanD_Command(nand, NAND_CMD_READ0);
|
||||
NanD_Command(nand, NAND_CMD_SEQIN);
|
||||
NanD_Address(nand, ADDR_COLUMN_PAGE, (page << nand->page_shift) + col);
|
||||
|
||||
@@ -982,180 +1096,17 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0 /* not used */
|
||||
/* Read a buffer from NanD */
|
||||
static void NanD_ReadBuf(struct nand_chip *nand, u_char * buf, int len)
|
||||
{
|
||||
unsigned long nandptr;
|
||||
|
||||
nandptr = nand->IO_ADDR;
|
||||
|
||||
for (; len > 0; len--)
|
||||
*buf++ = READ_NAND(nandptr);
|
||||
|
||||
}
|
||||
/* Write a buffer to NanD */
|
||||
static void NanD_WriteBuf(struct nand_chip *nand, const u_char * buf, int len)
|
||||
{
|
||||
unsigned long nandptr;
|
||||
int i;
|
||||
|
||||
nandptr = nand->IO_ADDR;
|
||||
|
||||
if (len <= 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
WRITE_NAND(buf[i], nandptr);
|
||||
|
||||
}
|
||||
|
||||
/* find_boot_record: Find the NFTL Media Header and its Spare copy which contains the
|
||||
* various device information of the NFTL partition and Bad Unit Table. Update
|
||||
* the ReplUnitTable[] table accroding to the Bad Unit Table. ReplUnitTable[]
|
||||
* is used for management of Erase Unit in other routines in nftl.c and nftlmount.c
|
||||
/* read from the 16 bytes of oob data that correspond to a 512 byte
|
||||
* page or 2 256-byte pages.
|
||||
*/
|
||||
static int find_boot_record(struct NFTLrecord *nftl)
|
||||
{
|
||||
struct nftl_uci1 h1;
|
||||
struct nftl_oob oob;
|
||||
unsigned int block, boot_record_count = 0;
|
||||
int retlen;
|
||||
u8 buf[SECTORSIZE];
|
||||
struct NFTLMediaHeader *mh = &nftl->MediaHdr;
|
||||
unsigned int i;
|
||||
|
||||
nftl->MediaUnit = BLOCK_NIL;
|
||||
nftl->SpareMediaUnit = BLOCK_NIL;
|
||||
|
||||
/* search for a valid boot record */
|
||||
for (block = 0; block < nftl->nb_blocks; block++) {
|
||||
int ret;
|
||||
|
||||
/* Check for ANAND header first. Then can whinge if it's found but later
|
||||
checks fail */
|
||||
if ((ret = nand_read_ecc(nftl->mtd, block * nftl->EraseSize, SECTORSIZE,
|
||||
&retlen, buf, NULL))) {
|
||||
static int warncount = 5;
|
||||
|
||||
if (warncount) {
|
||||
printf("Block read at 0x%x failed\n", block * nftl->EraseSize);
|
||||
if (!--warncount)
|
||||
puts ("Further failures for this block will not be printed\n");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (retlen < 6 || memcmp(buf, "ANAND", 6)) {
|
||||
/* ANAND\0 not found. Continue */
|
||||
#ifdef PSYCHO_DEBUG
|
||||
printf("ANAND header not found at 0x%x\n", block * nftl->EraseSize);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef NFTL_DEBUG
|
||||
printf("ANAND header found at 0x%x\n", block * nftl->EraseSize);
|
||||
#endif
|
||||
|
||||
/* To be safer with BIOS, also use erase mark as discriminant */
|
||||
if ((ret = nand_read_oob(nftl->mtd, block * nftl->EraseSize + SECTORSIZE + 8,
|
||||
8, &retlen, (char *)&h1) < 0)) {
|
||||
#ifdef NFTL_DEBUG
|
||||
printf("ANAND header found at 0x%x, but OOB data read failed\n",
|
||||
block * nftl->EraseSize);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
/* OK, we like it. */
|
||||
|
||||
if (boot_record_count) {
|
||||
/* We've already processed one. So we just check if
|
||||
this one is the same as the first one we found */
|
||||
if (memcmp(mh, buf, sizeof(struct NFTLMediaHeader))) {
|
||||
#ifdef NFTL_DEBUG
|
||||
printf("NFTL Media Headers at 0x%x and 0x%x disagree.\n",
|
||||
nftl->MediaUnit * nftl->EraseSize, block * nftl->EraseSize);
|
||||
#endif
|
||||
/* if (debug) Print both side by side */
|
||||
return -1;
|
||||
}
|
||||
if (boot_record_count == 1)
|
||||
nftl->SpareMediaUnit = block;
|
||||
|
||||
boot_record_count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* This is the first we've seen. Copy the media header structure into place */
|
||||
memcpy(mh, buf, sizeof(struct NFTLMediaHeader));
|
||||
|
||||
/* Do some sanity checks on it */
|
||||
if (mh->UnitSizeFactor != 0xff) {
|
||||
puts ("Sorry, we don't support UnitSizeFactor "
|
||||
"of != 1 yet.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
nftl->nb_boot_blocks = le16_to_cpu(mh->FirstPhysicalEUN);
|
||||
if ((nftl->nb_boot_blocks + 2) >= nftl->nb_blocks) {
|
||||
printf ("NFTL Media Header sanity check failed:\n"
|
||||
"nb_boot_blocks (%d) + 2 > nb_blocks (%d)\n",
|
||||
nftl->nb_boot_blocks, nftl->nb_blocks);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nftl->numvunits = le32_to_cpu(mh->FormattedSize) / nftl->EraseSize;
|
||||
if (nftl->numvunits > (nftl->nb_blocks - nftl->nb_boot_blocks - 2)) {
|
||||
printf ("NFTL Media Header sanity check failed:\n"
|
||||
"numvunits (%d) > nb_blocks (%d) - nb_boot_blocks(%d) - 2\n",
|
||||
nftl->numvunits,
|
||||
nftl->nb_blocks,
|
||||
nftl->nb_boot_blocks);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nftl->nr_sects = nftl->numvunits * (nftl->EraseSize / SECTORSIZE);
|
||||
|
||||
/* If we're not using the last sectors in the device for some reason,
|
||||
reduce nb_blocks accordingly so we forget they're there */
|
||||
nftl->nb_blocks = le16_to_cpu(mh->NumEraseUnits) + le16_to_cpu(mh->FirstPhysicalEUN);
|
||||
|
||||
/* read the Bad Erase Unit Table and modify ReplUnitTable[] accordingly */
|
||||
for (i = 0; i < nftl->nb_blocks; i++) {
|
||||
if ((i & (SECTORSIZE - 1)) == 0) {
|
||||
/* read one sector for every SECTORSIZE of blocks */
|
||||
if ((ret = nand_read_ecc(nftl->mtd, block * nftl->EraseSize +
|
||||
i + SECTORSIZE, SECTORSIZE,
|
||||
&retlen, buf, (char *)&oob)) < 0) {
|
||||
puts ("Read of bad sector table failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* mark the Bad Erase Unit as RESERVED in ReplUnitTable */
|
||||
if (buf[i & (SECTORSIZE - 1)] != 0xff)
|
||||
nftl->ReplUnitTable[i] = BLOCK_RESERVED;
|
||||
}
|
||||
|
||||
nftl->MediaUnit = block;
|
||||
boot_record_count++;
|
||||
|
||||
} /* foreach (block) */
|
||||
|
||||
return boot_record_count?0:-1;
|
||||
}
|
||||
static int nand_read_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
size_t * retlen, u_char * buf)
|
||||
size_t * retlen, u_char * buf)
|
||||
{
|
||||
int len256 = 0, ret;
|
||||
unsigned long nandptr;
|
||||
int len256 = 0;
|
||||
struct Nand *mychip;
|
||||
int ret = 0;
|
||||
|
||||
nandptr = nand->IO_ADDR;
|
||||
|
||||
mychip = &nand->chips[shr(ofs, nand->chipshift)];
|
||||
mychip = &nand->chips[ofs >> nand->chipshift];
|
||||
|
||||
/* update address for 2M x 8bit devices. OOB starts on the second */
|
||||
/* page to maintain compatibility with nand_read_ecc. */
|
||||
@@ -1166,6 +1117,7 @@ static int nand_read_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
ofs -= 0x8;
|
||||
}
|
||||
|
||||
NAND_ENABLE_CE(nand); /* set pin low */
|
||||
NanD_Command(nand, NAND_CMD_READOOB);
|
||||
NanD_Address(nand, ADDR_COLUMN_PAGE, ofs);
|
||||
|
||||
@@ -1188,14 +1140,20 @@ static int nand_read_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
* to wait until ready 11.4.1 and Toshiba TC58256FT nands */
|
||||
|
||||
ret = NanD_WaitReady(nand);
|
||||
NAND_DISABLE_CE(nand); /* set pin high */
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/* write to the 16 bytes of oob data that correspond to a 512 byte
|
||||
* page or 2 256-byte pages.
|
||||
*/
|
||||
static int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
size_t * retlen, const u_char * buf)
|
||||
{
|
||||
int len256 = 0;
|
||||
int i;
|
||||
unsigned long nandptr = nand->IO_ADDR;
|
||||
|
||||
#ifdef PSYCHO_DEBUG
|
||||
@@ -1204,6 +1162,8 @@ static int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
buf[8], buf[9], buf[14],buf[15]);
|
||||
#endif
|
||||
|
||||
NAND_ENABLE_CE(nand); /* set pin low to enable chip */
|
||||
|
||||
/* Reset the chip */
|
||||
NanD_Command(nand, NAND_CMD_RESET);
|
||||
|
||||
@@ -1229,7 +1189,8 @@ static int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
/* next OOB block, but it didn't work here. mf. */
|
||||
if (nand->page256 && ofs + len > (ofs | 0x7) + 1) {
|
||||
len256 = (ofs | 0x7) + 1 - ofs;
|
||||
NanD_WriteBuf(nand, buf, len256);
|
||||
for (i = 0; i < len256; i++)
|
||||
WRITE_NAND(buf[i], nandptr);
|
||||
|
||||
NanD_Command(nand, NAND_CMD_PAGEPROG);
|
||||
NanD_Command(nand, NAND_CMD_STATUS);
|
||||
@@ -1238,6 +1199,7 @@ static int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
if (READ_NAND(nandptr) & 1) {
|
||||
puts ("Error programming oob data\n");
|
||||
/* There was an error */
|
||||
NAND_DISABLE_CE(nand); /* set pin high */
|
||||
*retlen = 0;
|
||||
return -1;
|
||||
}
|
||||
@@ -1245,7 +1207,8 @@ static int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
NanD_Address(nand, ADDR_COLUMN_PAGE, ofs & (~0x1ff));
|
||||
}
|
||||
|
||||
NanD_WriteBuf(nand, &buf[len256], len - len256);
|
||||
for (i = len256; i < len; i++)
|
||||
WRITE_NAND(buf[i], nandptr);
|
||||
|
||||
NanD_Command(nand, NAND_CMD_PAGEPROG);
|
||||
NanD_Command(nand, NAND_CMD_STATUS);
|
||||
@@ -1254,18 +1217,27 @@ static int nand_write_oob(struct nand_chip* nand, size_t ofs, size_t len,
|
||||
if (READ_NAND(nandptr) & 1) {
|
||||
puts ("Error programming oob data\n");
|
||||
/* There was an error */
|
||||
NAND_DISABLE_CE(nand); /* set pin high */
|
||||
*retlen = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
NAND_DISABLE_CE(nand); /* set pin high */
|
||||
*retlen = len;
|
||||
return 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len)
|
||||
static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len, int clean)
|
||||
{
|
||||
/* This is defined as a structure so it will work on any system
|
||||
* using native endian jffs2 (the default).
|
||||
*/
|
||||
static struct jffs2_unknown_node clean_marker = {
|
||||
JFFS2_MAGIC_BITMASK,
|
||||
JFFS2_NODETYPE_CLEANMARKER,
|
||||
8 /* 8 bytes in this node */
|
||||
};
|
||||
unsigned long nandptr;
|
||||
struct Nand *mychip;
|
||||
int ret = 0;
|
||||
@@ -1289,9 +1261,6 @@ static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Select the NAND device */
|
||||
NAND_ENABLE_CE(nand); /* set pin low */
|
||||
|
||||
/* Check the WP bit */
|
||||
NanD_Command(nand, NAND_CMD_STATUS);
|
||||
if (!(READ_NAND(nand->IO_ADDR) & 0x80)) {
|
||||
@@ -1305,18 +1274,49 @@ static int nand_erase(struct nand_chip* nand, size_t ofs, size_t len)
|
||||
/*mychip = &nand->chips[shr(ofs, nand->chipshift)];*/
|
||||
mychip = &nand->chips[ofs >> nand->chipshift];
|
||||
|
||||
NanD_Command(nand, NAND_CMD_ERASE1);
|
||||
NanD_Address(nand, ADDR_PAGE, ofs);
|
||||
NanD_Command(nand, NAND_CMD_ERASE2);
|
||||
/* always check for bad block first, genuine bad blocks
|
||||
* should _never_ be erased.
|
||||
*/
|
||||
if (ALLOW_ERASE_BAD_DEBUG || !check_block(nand, ofs)) {
|
||||
/* Select the NAND device */
|
||||
NAND_ENABLE_CE(nand); /* set pin low */
|
||||
|
||||
NanD_Command(nand, NAND_CMD_STATUS);
|
||||
NanD_Command(nand, NAND_CMD_ERASE1);
|
||||
NanD_Address(nand, ADDR_PAGE, ofs);
|
||||
NanD_Command(nand, NAND_CMD_ERASE2);
|
||||
|
||||
if (READ_NAND(nandptr) & 1) {
|
||||
printf ("%s: Error erasing at 0x%lx\n",
|
||||
__FUNCTION__, (long)ofs);
|
||||
/* There was an error */
|
||||
ret = -1;
|
||||
goto out;
|
||||
NanD_Command(nand, NAND_CMD_STATUS);
|
||||
|
||||
if (READ_NAND(nandptr) & 1) {
|
||||
printf ("%s: Error erasing at 0x%lx\n",
|
||||
__FUNCTION__, (long)ofs);
|
||||
/* There was an error */
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
if (clean) {
|
||||
int n; /* return value not used */
|
||||
int p, l;
|
||||
|
||||
/* clean marker position and size depend
|
||||
* on the page size, since 256 byte pages
|
||||
* only have 8 bytes of oob data
|
||||
*/
|
||||
if (nand->page256) {
|
||||
p = NAND_JFFS2_OOB8_FSDAPOS;
|
||||
l = NAND_JFFS2_OOB8_FSDALEN;
|
||||
}
|
||||
else {
|
||||
p = NAND_JFFS2_OOB16_FSDAPOS;
|
||||
l = NAND_JFFS2_OOB16_FSDALEN;
|
||||
}
|
||||
|
||||
ret = nand_write_oob(nand, ofs + p, l, &n,
|
||||
(u_char *)&clean_marker);
|
||||
/* quit here if write failed */
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
ofs += nand->erasesize;
|
||||
len -= nand->erasesize;
|
||||
@@ -1346,7 +1346,6 @@ void nand_probe(unsigned long physadr)
|
||||
oob_config.ecc_pos[3] = NAND_JFFS2_OOB_ECCPOS3;
|
||||
oob_config.ecc_pos[4] = NAND_JFFS2_OOB_ECCPOS4;
|
||||
oob_config.ecc_pos[5] = NAND_JFFS2_OOB_ECCPOS5;
|
||||
oob_config.badblock_pos = 5;
|
||||
oob_config.eccvalid_pos = 4;
|
||||
#else
|
||||
oob_config.ecc_pos[0] = NAND_NOOB_ECCPOS0;
|
||||
@@ -1355,9 +1354,9 @@ void nand_probe(unsigned long physadr)
|
||||
oob_config.ecc_pos[3] = NAND_NOOB_ECCPOS3;
|
||||
oob_config.ecc_pos[4] = NAND_NOOB_ECCPOS4;
|
||||
oob_config.ecc_pos[5] = NAND_NOOB_ECCPOS5;
|
||||
oob_config.badblock_pos = NAND_NOOB_BADBPOS;
|
||||
oob_config.eccvalid_pos = NAND_NOOB_ECCVPOS;
|
||||
#endif
|
||||
oob_config.badblock_pos = 5;
|
||||
|
||||
for (i=0; i<CFG_MAX_NAND_DEVICE; i++) {
|
||||
if (nand_dev_desc[i].ChipID == NAND_ChipID_UNKNOWN) {
|
||||
@@ -1366,15 +1365,23 @@ void nand_probe(unsigned long physadr)
|
||||
}
|
||||
}
|
||||
|
||||
memset((char *)nand, 0, sizeof(struct nand_chip));
|
||||
|
||||
nand->IO_ADDR = physadr;
|
||||
nand->cache_page = -1; /* init the cache page */
|
||||
NanD_ScanChips(nand);
|
||||
|
||||
if (nand->totlen == 0) {
|
||||
/* no chips found, clean up and quit */
|
||||
memset((char *)nand, 0, sizeof(struct nand_chip));
|
||||
nand->ChipID = NAND_ChipID_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
nand->ChipID = ChipID;
|
||||
if (curr_device == -1)
|
||||
curr_device = i;
|
||||
|
||||
memset((char *)nand, 0, sizeof(struct nand_chip));
|
||||
|
||||
nand->cache_page = -1; /* init the cache page */
|
||||
nand->IO_ADDR = physadr;
|
||||
nand->ChipID = ChipID;
|
||||
NanD_ScanChips(nand);
|
||||
nand->data_buf = malloc (nand->oobblock + nand->oobsize);
|
||||
if (!nand->data_buf) {
|
||||
puts ("Cannot allocate memory for data structures.\n");
|
||||
@@ -1451,11 +1458,11 @@ static void nand_trans_result(u_char reg2, u_char reg3,
|
||||
*/
|
||||
static void nand_calculate_ecc (const u_char *dat, u_char *ecc_code)
|
||||
{
|
||||
u_char idx, reg1, reg2, reg3;
|
||||
u_char idx, reg1, reg3;
|
||||
int j;
|
||||
|
||||
/* Initialize variables */
|
||||
reg1 = reg2 = reg3 = 0;
|
||||
reg1 = reg3 = 0;
|
||||
ecc_code[0] = ecc_code[1] = ecc_code[2] = 0;
|
||||
|
||||
/* Build up column parity */
|
||||
@@ -1463,17 +1470,16 @@ static void nand_calculate_ecc (const u_char *dat, u_char *ecc_code)
|
||||
|
||||
/* Get CP0 - CP5 from table */
|
||||
idx = nand_ecc_precalc_table[dat[j]];
|
||||
reg1 ^= (idx & 0x3f);
|
||||
reg1 ^= idx;
|
||||
|
||||
/* All bit XOR = 1 ? */
|
||||
if (idx & 0x40) {
|
||||
reg3 ^= (u_char) j;
|
||||
reg2 ^= ~((u_char) j);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create non-inverted ECC code from line parity */
|
||||
nand_trans_result(reg2, reg3, ecc_code);
|
||||
nand_trans_result((reg1 & 0x40) ? ~reg3 : reg3, reg3, ecc_code);
|
||||
|
||||
/* Calculate final ECC code */
|
||||
ecc_code[0] = ~ecc_code[0];
|
||||
|
||||
@@ -95,6 +95,10 @@ static void netboot_update_env(void)
|
||||
ip_to_string (NetOurDNSIP, tmp);
|
||||
setenv("dnsip", tmp);
|
||||
}
|
||||
|
||||
if (NetOurNISDomain[0])
|
||||
setenv("domain", NetOurNISDomain);
|
||||
|
||||
}
|
||||
static int
|
||||
netboot_common (int proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||
@@ -165,4 +169,27 @@ netboot_common (int proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||
return rcode;
|
||||
}
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_PING)
|
||||
int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2)
|
||||
return -1;
|
||||
|
||||
NetPingIP = string_to_ip(argv[1]);
|
||||
if (NetPingIP == 0) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (NetLoop(PING) < 0) {
|
||||
printf("ping failed; host %s is not alive\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("host %s is alive\n", argv[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CFG_CMD_PING */
|
||||
|
||||
#endif /* CFG_CMD_NET */
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* (C) Copyright 2003
|
||||
* Marc Singer, elf@buici.com
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Port I/O Functions
|
||||
*
|
||||
* Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <cmd_portio.h>
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_PORTIO)
|
||||
|
||||
extern int cmd_get_data_size (char *arg, int default_size);
|
||||
|
||||
/* Display values from last command.
|
||||
* Memory modify remembered values are different from display memory.
|
||||
*/
|
||||
static uint in_last_addr, in_last_size;
|
||||
static uint out_last_addr, out_last_size, out_last_value;
|
||||
|
||||
|
||||
int do_portio_out (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
uint addr = out_last_addr;
|
||||
uint size = out_last_size;
|
||||
uint value = out_last_value;
|
||||
|
||||
if (argc != 3) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((flag & CMD_FLAG_REPEAT) == 0) {
|
||||
/* New command specified. Check for a size specification.
|
||||
* Defaults to long if no or incorrect specification.
|
||||
*/
|
||||
size = cmd_get_data_size (argv[0], 1);
|
||||
addr = simple_strtoul (argv[1], NULL, 16);
|
||||
value = simple_strtoul (argv[2], NULL, 16);
|
||||
}
|
||||
#if defined (CONFIG_X86)
|
||||
|
||||
{
|
||||
unsigned short port = addr;
|
||||
|
||||
switch (size) {
|
||||
default:
|
||||
case 1:
|
||||
{
|
||||
unsigned char ch = value;
|
||||
__asm__ volatile ("out %0, %%dx"::"a" (ch), "d" (port));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
unsigned short w = value;
|
||||
__asm__ volatile ("out %0, %%dx"::"a" (w), "d" (port));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
__asm__ volatile ("out %0, %%dx"::"a" (value), "d" (port));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_X86 */
|
||||
|
||||
out_last_addr = addr;
|
||||
out_last_size = size;
|
||||
out_last_value = value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_portio_in (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
uint addr = in_last_addr;
|
||||
uint size = in_last_size;
|
||||
|
||||
if (argc != 2) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((flag & CMD_FLAG_REPEAT) == 0) {
|
||||
/* New command specified. Check for a size specification.
|
||||
* Defaults to long if no or incorrect specification.
|
||||
*/
|
||||
size = cmd_get_data_size (argv[0], 1);
|
||||
addr = simple_strtoul (argv[1], NULL, 16);
|
||||
}
|
||||
#if defined (CONFIG_X86)
|
||||
|
||||
{
|
||||
unsigned short port = addr;
|
||||
|
||||
switch (size) {
|
||||
default:
|
||||
case 1:
|
||||
{
|
||||
unsigned char ch;
|
||||
__asm__ volatile ("in %%dx, %0":"=a" (ch):"d" (port));
|
||||
|
||||
printf (" %02x\n", ch);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
unsigned short w;
|
||||
__asm__ volatile ("in %%dx, %0":"=a" (w):"d" (port));
|
||||
|
||||
printf (" %04x\n", w);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
{
|
||||
unsigned long l;
|
||||
__asm__ volatile ("in %%dx, %0":"=a" (l):"d" (port));
|
||||
|
||||
printf (" %08lx\n", l);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_X86 */
|
||||
|
||||
in_last_addr = addr;
|
||||
in_last_size = size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* CFG_CMD_PORTIO */
|
||||
@@ -73,6 +73,7 @@
|
||||
#include <cmd_log.h>
|
||||
#include <cmd_fdos.h>
|
||||
#include <cmd_bmp.h>
|
||||
#include <cmd_portio.h>
|
||||
|
||||
#ifdef CONFIG_AMIGAONEG3SE
|
||||
#include <cmd_menu.h>
|
||||
@@ -284,6 +285,7 @@ cmd_tbl_t cmd_tbl[] = {
|
||||
CMD_TBL_IMM
|
||||
CMD_TBL_INM
|
||||
CMD_TBL_IMW
|
||||
CMD_TBL_PORTIO_IN
|
||||
CMD_TBL_ICRC
|
||||
CMD_TBL_IPROBE
|
||||
CMD_TBL_ILOOP
|
||||
@@ -314,6 +316,8 @@ cmd_tbl_t cmd_tbl[] = {
|
||||
CMD_TBL_NANDBOOT
|
||||
CMD_TBL_NEXT
|
||||
CMD_TBL_NM
|
||||
CMD_TBL_PING
|
||||
CMD_TBL_PORTIO_OUT
|
||||
CMD_TBL_PCI
|
||||
CMD_TBL_PRINTENV
|
||||
CMD_TBL_PROTECT
|
||||
|
||||
+2
-2
@@ -185,8 +185,8 @@ int devices_init (void)
|
||||
#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
|
||||
drv_video_init ();
|
||||
#endif
|
||||
#ifdef CONFIG_WL_4PPM_KEYBOARD
|
||||
drv_wlkbd_init ();
|
||||
#ifdef CONFIG_KEYBOARD
|
||||
drv_keyboard_init ();
|
||||
#endif
|
||||
#ifdef CONFIG_LOGBUFFER
|
||||
drv_logbuff_init ();
|
||||
|
||||
@@ -750,7 +750,7 @@ trap_init:
|
||||
lwz r7, GOT(_start)
|
||||
lwz r8, GOT(_end_of_vectors)
|
||||
|
||||
rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */
|
||||
li r9, 0x100 /* reset vector always at 0x100 */
|
||||
|
||||
cmplw 0, r7, r8
|
||||
bgelr /* return if r7>=r8 - just in case */
|
||||
|
||||
+7
-6
@@ -26,17 +26,18 @@ include $(TOPDIR)/config.mk
|
||||
LIB = lib$(CPU).a
|
||||
|
||||
START = start.o start16.o reset.o
|
||||
OBJS = serial.o interrupts.o cpu.o timer.o
|
||||
|
||||
COBJS = serial.o interrupts.o cpu.o timer.o sc520.o
|
||||
AOBJS = sc520_asm.o
|
||||
|
||||
all: .depend $(START) $(LIB)
|
||||
|
||||
$(LIB): $(OBJS)
|
||||
$(AR) crv $@ $(OBJS)
|
||||
$(LIB): $(COBJS) $(AOBJS)
|
||||
$(AR) crv $@ $(COBJS) $(AOBJS)
|
||||
|
||||
#########################################################################
|
||||
|
||||
.depend: Makefile $(START:.o=.S) $(OBJS:.o=.c)
|
||||
$(CC) -M $(CFLAGS) $(START:.o=.S) $(OBJS:.o=.c) > $@
|
||||
.depend: Makefile $(START:.o=.S) $(COBJS:.o=.c) $(AOBJS:.o=.S)
|
||||
$(CC) -M $(CFLAGS) $(START:.o=.S) $(COBJS:.o=.c) $(AOBJS:.o=.S) > $@
|
||||
|
||||
sinclude .depend
|
||||
|
||||
|
||||
+2
-2
@@ -21,6 +21,6 @@
|
||||
# MA 02111-1307 USA
|
||||
#
|
||||
|
||||
PLATFORM_RELFLAGS += # -pipe -mpreferred-stack-boundary=2 -fno-builtin -nostdinc -nostdlib
|
||||
PLATFORM_RELFLAGS +=
|
||||
|
||||
PLATFORM_CPPFLAGS += -march=i386
|
||||
PLATFORM_CPPFLAGS += -march=i386 -Werror
|
||||
@@ -38,6 +38,13 @@
|
||||
|
||||
int cpu_init(void)
|
||||
{
|
||||
/* initialize FPU, reset EM, set MP and NE */
|
||||
asm ("fninit\n" \
|
||||
"movl %cr0, %eax\n" \
|
||||
"andl $~0x4, %eax\n" \
|
||||
"orl $0x22, %eax\n" \
|
||||
"movl %eax, %cr0\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+19
-48
@@ -29,22 +29,6 @@
|
||||
#include <asm/ibmpc.h>
|
||||
|
||||
|
||||
#if 0
|
||||
/* done */
|
||||
int interrupt_init (void);
|
||||
void irq_install_handler(int, interrupt_handler_t *, void *);
|
||||
void irq_free_handler (int);
|
||||
void enable_interrupts (void);
|
||||
int disable_interrupts (void);
|
||||
|
||||
/* todo */
|
||||
void timer_interrupt (struct pt_regs *);
|
||||
void external_interrupt (struct pt_regs *);
|
||||
void reset_timer (void);
|
||||
ulong get_timer (ulong base);
|
||||
void set_timer (ulong t);
|
||||
|
||||
#endif
|
||||
|
||||
struct idt_entry {
|
||||
u16 base_low;
|
||||
@@ -76,43 +60,30 @@ typedef struct {
|
||||
static irq_desc_t irq_table[MAX_IRQ];
|
||||
|
||||
|
||||
/* syscall stuff, very untested
|
||||
* the current approach which includes copying
|
||||
* part of the stack will work badly for
|
||||
* varargs functions.
|
||||
* if we were to store the top three words on the
|
||||
* stack (eip, ss, eflags) somwhere and add 14 to
|
||||
* %esp ....
|
||||
*/
|
||||
|
||||
asm(".globl syscall_entry\n" \
|
||||
"syscall_entry:\n" \
|
||||
"movl 12(%esp), %eax\n" \
|
||||
"movl %esp, %ebx\n" \
|
||||
"addl $16, %ebx\n" \
|
||||
"pushl %ebx\n" \
|
||||
"pushl %eax\n" \
|
||||
"call do_syscall\n" \
|
||||
"addl $8, %esp\n" \
|
||||
"iret\n");
|
||||
"popl %ebx\n" /* throw away the return address, flags */ \
|
||||
"popl %ebx\n" /* and segment that the INT instruction pushed */ \
|
||||
"popl %ebx\n" /* on to the stack */ \
|
||||
"movl %eax, %ecx\n" /* load the syscall nr argument*/ \
|
||||
"movl syscall_tbl, %eax\n" /* load start of syscall table */ \
|
||||
"cmpl $(11-1), %ecx\n" /* FixMe: find a way to use NR_SYSCALLS macro here */ \
|
||||
"ja bad_syscall\n" \
|
||||
"movl (%eax, %ecx, 4), %eax\n" /* load the handler of the syscall*/ \
|
||||
"test %eax, %eax\n" /* test for null */ \
|
||||
"je bad_syscall\n" \
|
||||
"popl %ecx\n" \
|
||||
"popl %ebx\n" \
|
||||
"sti \n" \
|
||||
"jmp *%eax\n" \
|
||||
"bad_syscall: movl $0xffffffff, %eax\n" \
|
||||
"popl %ecx\n" \
|
||||
"popl %ebx\n" \
|
||||
"ret");
|
||||
|
||||
void __attribute__ ((regparm(0))) syscall_entry(void);
|
||||
|
||||
int __attribute__ ((regparm(0))) do_syscall(u32 nr, u32 *stack)
|
||||
{
|
||||
if (nr<NR_SYSCALLS) {
|
||||
/* We copy 8 args of the syscall,
|
||||
* this will be a problem with the
|
||||
* printf syscall .... */
|
||||
int (*fp)(u32, u32, u32, u32,
|
||||
u32, u32, u32, u32);
|
||||
fp = syscall_tbl[nr];
|
||||
return fp(stack[0], stack[1], stack[2], stack[3],
|
||||
stack[4], stack[5], stack[6], stack[7]);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
asm ("irq_return:\n"
|
||||
" addl $4, %esp\n"
|
||||
|
||||
@@ -24,10 +24,14 @@
|
||||
/* stuff specific for the sc520,
|
||||
* but idependent of implementation */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef CONFIG_SC520
|
||||
|
||||
#include <common.h>
|
||||
#include <config.h>
|
||||
#include <pci.h>
|
||||
#include <ssi.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/pci.h>
|
||||
#include <asm/ic/sc520.h>
|
||||
@@ -235,6 +239,91 @@ unsigned long init_sc520_dram(void)
|
||||
#ifdef CONFIG_PCI
|
||||
|
||||
|
||||
static struct {
|
||||
u8 priority;
|
||||
u16 level_reg;
|
||||
u8 level_bit;
|
||||
} sc520_irq[] = {
|
||||
{ SC520_IRQ0, SC520_MPICMODE, 0x01 },
|
||||
{ SC520_IRQ1, SC520_MPICMODE, 0x02 },
|
||||
{ SC520_IRQ2, SC520_SL1PICMODE, 0x02 },
|
||||
{ SC520_IRQ3, SC520_MPICMODE, 0x08 },
|
||||
{ SC520_IRQ4, SC520_MPICMODE, 0x10 },
|
||||
{ SC520_IRQ5, SC520_MPICMODE, 0x20 },
|
||||
{ SC520_IRQ6, SC520_MPICMODE, 0x40 },
|
||||
{ SC520_IRQ7, SC520_MPICMODE, 0x80 },
|
||||
|
||||
{ SC520_IRQ8, SC520_SL1PICMODE, 0x01 },
|
||||
{ SC520_IRQ9, SC520_SL1PICMODE, 0x02 },
|
||||
{ SC520_IRQ10, SC520_SL1PICMODE, 0x04 },
|
||||
{ SC520_IRQ11, SC520_SL1PICMODE, 0x08 },
|
||||
{ SC520_IRQ12, SC520_SL1PICMODE, 0x10 },
|
||||
{ SC520_IRQ13, SC520_SL1PICMODE, 0x20 },
|
||||
{ SC520_IRQ14, SC520_SL1PICMODE, 0x40 },
|
||||
{ SC520_IRQ15, SC520_SL1PICMODE, 0x80 }
|
||||
};
|
||||
|
||||
|
||||
/* The interrupt used for PCI INTA-INTD */
|
||||
int sc520_pci_ints[15] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
|
||||
/* utility function to configure a pci interrupt */
|
||||
int pci_sc520_set_irq(int pci_pin, int irq)
|
||||
{
|
||||
int i;
|
||||
|
||||
# if 0
|
||||
printf("set_irq(): map INT%c to IRQ%d\n", pci_pin + 'A', irq);
|
||||
#endif
|
||||
if (irq < 0 || irq > 15) {
|
||||
return -1; /* illegal irq */
|
||||
}
|
||||
|
||||
if (pci_pin < 0 || pci_pin > 15) {
|
||||
return -1; /* illegal pci int pin */
|
||||
}
|
||||
|
||||
/* first disable any non-pci interrupt source that use
|
||||
* this level */
|
||||
for (i=SC520_GPTMR0MAP;i<=SC520_GP10IMAP;i++) {
|
||||
if (i>=SC520_PCIINTAMAP&&i<=SC520_PCIINTDMAP) {
|
||||
continue;
|
||||
}
|
||||
if (read_mmcr_byte(i) == sc520_irq[irq].priority) {
|
||||
write_mmcr_byte(i, SC520_IRQ_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the trigger to level */
|
||||
write_mmcr_byte(sc520_irq[irq].level_reg,
|
||||
read_mmcr_byte(sc520_irq[irq].level_reg) | sc520_irq[irq].level_bit);
|
||||
|
||||
|
||||
if (pci_pin < 4) {
|
||||
/* PCI INTA-INTD */
|
||||
/* route the interrupt */
|
||||
write_mmcr_byte(SC520_PCIINTAMAP + pci_pin, sc520_irq[irq].priority);
|
||||
|
||||
|
||||
} else {
|
||||
/* GPIRQ0-GPIRQ10 used for additional PCI INTS */
|
||||
write_mmcr_byte(SC520_GP0IMAP + pci_pin - 4, sc520_irq[irq].priority);
|
||||
|
||||
/* also set the polarity in this case */
|
||||
write_mmcr_word(SC520_INTPINPOL,
|
||||
read_mmcr_word(SC520_INTPINPOL) | (1 << (pci_pin-4)));
|
||||
|
||||
}
|
||||
|
||||
/* register the pin */
|
||||
sc520_pci_ints[pci_pin] = irq;
|
||||
|
||||
|
||||
return 0; /* OK */
|
||||
}
|
||||
|
||||
void pci_sc520_init(struct pci_controller *hose)
|
||||
{
|
||||
@@ -293,6 +382,7 @@ void pci_sc520_init(struct pci_controller *hose)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CFG_TIMER_SC520
|
||||
@@ -345,4 +435,68 @@ void udelay(unsigned long usec)
|
||||
|
||||
#endif
|
||||
|
||||
int ssi_set_interface(int freq, int lsb_first, int inv_clock, int inv_phase)
|
||||
{
|
||||
u8 temp=0;
|
||||
|
||||
if (freq >= 8192) {
|
||||
temp |= CTL_CLK_SEL_4;
|
||||
} else if (freq >= 4096) {
|
||||
temp |= CTL_CLK_SEL_8;
|
||||
} else if (freq >= 2048) {
|
||||
temp |= CTL_CLK_SEL_16;
|
||||
} else if (freq >= 1024) {
|
||||
temp |= CTL_CLK_SEL_32;
|
||||
} else if (freq >= 512) {
|
||||
temp |= CTL_CLK_SEL_64;
|
||||
} else if (freq >= 256) {
|
||||
temp |= CTL_CLK_SEL_128;
|
||||
} else if (freq >= 128) {
|
||||
temp |= CTL_CLK_SEL_256;
|
||||
} else {
|
||||
temp |= CTL_CLK_SEL_512;
|
||||
}
|
||||
|
||||
if (!lsb_first) {
|
||||
temp |= MSBF_ENB;
|
||||
}
|
||||
|
||||
if (inv_clock) {
|
||||
temp |= CLK_INV_ENB;
|
||||
}
|
||||
|
||||
if (inv_phase) {
|
||||
temp |= PHS_INV_ENB;
|
||||
}
|
||||
|
||||
write_mmcr_byte(SC520_SSICTL, temp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 ssi_txrx_byte(u8 data)
|
||||
{
|
||||
write_mmcr_byte(SC520_SSIXMIT, data);
|
||||
while ((read_mmcr_byte(SC520_SSISTA)) & SSISTA_BSY);
|
||||
write_mmcr_byte(SC520_SSICMD, SSICMD_CMD_SEL_XMITRCV);
|
||||
while ((read_mmcr_byte(SC520_SSISTA)) & SSISTA_BSY);
|
||||
return read_mmcr_byte(SC520_SSIRCV);
|
||||
}
|
||||
|
||||
|
||||
void ssi_tx_byte(u8 data)
|
||||
{
|
||||
write_mmcr_byte(SC520_SSIXMIT, data);
|
||||
while ((read_mmcr_byte(SC520_SSISTA)) & SSISTA_BSY);
|
||||
write_mmcr_byte(SC520_SSICMD, SSICMD_CMD_SEL_XMIT);
|
||||
}
|
||||
|
||||
u8 ssi_rx_byte(void)
|
||||
{
|
||||
while ((read_mmcr_byte(SC520_SSISTA)) & SSISTA_BSY);
|
||||
write_mmcr_byte(SC520_SSICMD, SSICMD_CMD_SEL_RCV);
|
||||
while ((read_mmcr_byte(SC520_SSISTA)) & SSISTA_BSY);
|
||||
return read_mmcr_byte(SC520_SSIRCV);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SC520 */
|
||||
@@ -104,6 +104,9 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#ifdef CONFIG_SC520
|
||||
|
||||
.section .text
|
||||
.equ DRCCTL, 0x0fffef010 /* DRAM control register */
|
||||
.equ DRCTMCTL, 0x0fffef012 /* DRAM timing control register */
|
||||
@@ -140,34 +143,34 @@
|
||||
mem_init:
|
||||
xorw %ax,%ax
|
||||
movl $DBCTL, %edi
|
||||
fs movb %al, (%edi) /* disable write buffer */
|
||||
movb %al, (%edi) /* disable write buffer */
|
||||
|
||||
movl $ECCCTL, %edi
|
||||
fs movb %al, (%edi) /* disable ECC */
|
||||
movb %al, (%edi) /* disable ECC */
|
||||
|
||||
movl $DRCTMCTL, %edi
|
||||
movb $0x1E,%al /* Set SDRAM timing for slowest */
|
||||
fs movb %al, (%edi)
|
||||
movb %al, (%edi)
|
||||
|
||||
/*
|
||||
* setup loop to do 4 external banks starting with bank 3
|
||||
*/
|
||||
movl $0xff000000,%eax /* enable last bank and setup */
|
||||
movl $DRCBENDADR, %edi /* ending address register */
|
||||
fs movl %eax, (%edi)
|
||||
movl %eax, (%edi)
|
||||
|
||||
movl $DRCCFG, %edi /* setup */
|
||||
movw $0xbbbb,%ax /* dram config register for */
|
||||
fs movw %ax, (%edi)
|
||||
movw %ax, (%edi)
|
||||
|
||||
/*
|
||||
* issue a NOP to all DRAMs
|
||||
*/
|
||||
movl $DRCCTL, %edi /* setup DRAM control register with */
|
||||
movb $0x1,%al /* Disable refresh,disable write buffer */
|
||||
fs movb %al, (%edi)
|
||||
movb %al, (%edi)
|
||||
movl $CACHELINESZ, %esi /* just a dummy address to write for */
|
||||
fs movw %ax, (%esi)
|
||||
movw %ax, (%esi)
|
||||
/*
|
||||
* delay for 100 usec? 200?
|
||||
* ******this is a cludge for now *************
|
||||
@@ -181,41 +184,41 @@ sizdelay:
|
||||
* issue all banks precharge
|
||||
*/
|
||||
movb $0x2,%al /* All banks precharge */
|
||||
fs movb %al, (%edi)
|
||||
fs movw %ax, (%esi)
|
||||
movb %al, (%edi)
|
||||
movw %ax, (%esi)
|
||||
|
||||
/*
|
||||
* issue 2 auto refreshes to all banks
|
||||
*/
|
||||
movb $0x4,%al /* Auto refresh cmd */
|
||||
fs movb %al, (%edi)
|
||||
movb %al, (%edi)
|
||||
movw $2,%cx
|
||||
refresh1:
|
||||
fs movw %ax, (%esi)
|
||||
movw %ax, (%esi)
|
||||
loop refresh1
|
||||
|
||||
/*
|
||||
* issue LOAD MODE REGISTER command
|
||||
*/
|
||||
movb $0x3,%al /* Load mode register cmd */
|
||||
fs movb %al, (%edi)
|
||||
fs movw %ax, (%esi)
|
||||
movb %al, (%edi)
|
||||
movw %ax, (%esi)
|
||||
|
||||
/*
|
||||
* issue 8 more auto refreshes to all banks
|
||||
*/
|
||||
movb $0x4,%al /* Auto refresh cmd */
|
||||
fs movb %al, (%edi)
|
||||
movb %al, (%edi)
|
||||
movw $8,%cx
|
||||
refresh2:
|
||||
fs movw %ax, (%esi)
|
||||
movw %ax, (%esi)
|
||||
loop refresh2
|
||||
|
||||
/*
|
||||
* set control register to NORMAL mode
|
||||
*/
|
||||
movb $0x0,%al /* Normal mode value */
|
||||
fs movb %al, (%edi)
|
||||
movb %al, (%edi)
|
||||
|
||||
/*
|
||||
* size dram starting with external bank 3 moving to external bank 0
|
||||
@@ -229,8 +232,8 @@ nextbank:
|
||||
*/
|
||||
movl $COL11_ADR, %esi /* set address to max col (11) wrap addr */
|
||||
movl $COL11_DATA, %eax /* pattern for max supported columns(11) */
|
||||
fs movl %eax, (%esi) /* write max col pattern at max col adr */
|
||||
fs movl (%esi), %ebx /* optional read */
|
||||
movl %eax, (%esi) /* write max col pattern at max col adr */
|
||||
movl (%esi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -239,8 +242,8 @@ fs movl (%esi), %ebx /* optional read */
|
||||
|
||||
movl $COL10_ADR, %esi /* set address to 10 col wrap address */
|
||||
movl $COL10_DATA, %eax /* pattern for 10 col wrap */
|
||||
fs movl %eax, (%esi) /* write 10 col pattern @ 10 col wrap adr */
|
||||
fs movl (%esi), %ebx /* optional read */
|
||||
movl %eax, (%esi) /* write 10 col pattern @ 10 col wrap adr */
|
||||
movl (%esi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -248,8 +251,8 @@ fs movl (%esi), %ebx /* optional read */
|
||||
*/
|
||||
movl $COL09_ADR, %esi /* set address to 9 col wrap address */
|
||||
movl $COL09_DATA, %eax /* pattern for 9 col wrap */
|
||||
fs movl %eax, (%esi) /* write 9 col pattern @ 9 col wrap adr */
|
||||
fs movl (%esi), %ebx /* optional read */
|
||||
movl %eax, (%esi) /* write 9 col pattern @ 9 col wrap adr */
|
||||
movl (%esi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -257,8 +260,8 @@ fs movl (%esi), %ebx /* optional read */
|
||||
*/
|
||||
movl $COL08_ADR, %esi /* set address to min(8) col wrap address */
|
||||
movl $COL08_DATA, %eax /* pattern for min (8) col wrap */
|
||||
fs movl %eax, (%esi) /* write min col pattern @ min col adr */
|
||||
fs movl (%esi), %ebx /* optional read */
|
||||
movl %eax, (%esi) /* write min col pattern @ min col adr */
|
||||
movl (%esi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -266,8 +269,8 @@ fs movl (%esi), %ebx /* optional read */
|
||||
*/
|
||||
movl $ROW14_ADR, %esi /* set address to max row (14) wrap addr */
|
||||
movl $ROW14_DATA, %eax /* pattern for max supported rows(14) */
|
||||
fs movl %eax, (%esi) /* write max row pattern at max row adr */
|
||||
fs movl (%esi), %ebx /* optional read */
|
||||
movl %eax, (%esi) /* write max row pattern at max row adr */
|
||||
movl (%esi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -275,8 +278,8 @@ fs movl (%esi), %ebx /* optional read */
|
||||
*/
|
||||
movl $ROW13_ADR, %esi /* set address to 13 row wrap address */
|
||||
movl $ROW13_DATA, %eax /* pattern for 13 row wrap */
|
||||
fs movl %eax, (%esi) /* write 13 row pattern @ 13 row wrap adr */
|
||||
fs movl (%esi), %ebx /* optional read */
|
||||
movl %eax, (%esi) /* write 13 row pattern @ 13 row wrap adr */
|
||||
movl (%esi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -284,8 +287,8 @@ fs movl (%esi), %ebx /* optional read */
|
||||
*/
|
||||
movl $ROW12_ADR, %esi /* set address to 12 row wrap address */
|
||||
movl $ROW12_DATA, %eax /* pattern for 12 row wrap */
|
||||
fs movl %eax, (%esi) /* write 12 row pattern @ 12 row wrap adr */
|
||||
fs movl (%esi), %ebx /* optional read */
|
||||
movl %eax, (%esi) /* write 12 row pattern @ 12 row wrap adr */
|
||||
movl (%esi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -293,8 +296,8 @@ fs movl (%esi), %ebx /* optional read */
|
||||
*/
|
||||
movl $ROW11_ADR, %edi /* set address to 11 row wrap address */
|
||||
movl $ROW11_DATA, %eax /* pattern for 11 row wrap */
|
||||
fs movl %eax, (%edi) /* write 11 row pattern @ 11 row wrap adr */
|
||||
fs movl (%edi), %ebx /* optional read */
|
||||
movl %eax, (%edi) /* write 11 row pattern @ 11 row wrap adr */
|
||||
movl (%edi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -302,8 +305,8 @@ fs movl (%edi), %ebx /* optional read */
|
||||
*/
|
||||
movl $ROW10_ADR, %edi /* set address to 10 row wrap address */
|
||||
movl $ROW10_DATA, %eax /* pattern for 10 row wrap (AA) */
|
||||
fs movl %eax, (%edi) /* write 10 row pattern @ 10 row wrap adr */
|
||||
fs movl (%edi), %ebx /* optional read */
|
||||
movl %eax, (%edi) /* write 10 row pattern @ 10 row wrap adr */
|
||||
movl (%edi), %ebx /* optional read */
|
||||
cmpl %ebx,%eax /* to verify write */
|
||||
jnz bad_ram /* this ram is bad */
|
||||
/*
|
||||
@@ -314,7 +317,7 @@ fs movl (%edi), %ebx /* optional read */
|
||||
* if data @ row 12 wrap == 11 or 12, we have 4 banks,
|
||||
*/
|
||||
xorw %di,%di /* value for 2 banks in DI */
|
||||
fs movl (%esi), %ebx /* read from 12 row wrap to check banks
|
||||
movl (%esi), %ebx /* read from 12 row wrap to check banks
|
||||
* (esi is setup from the write to row 12 wrap) */
|
||||
cmpl %ebx,%eax /* check for AA pattern (eax holds the aa pattern) */
|
||||
jz only2 /* if pattern == AA, we only have 2 banks */
|
||||
@@ -333,7 +336,7 @@ only2:
|
||||
* validate row mask
|
||||
*/
|
||||
movl $ROW14_ADR, %esi /* set address back to max row wrap addr */
|
||||
fs movl (%esi), %eax /* read actual number of rows @ row14 adr */
|
||||
movl (%esi), %eax /* read actual number of rows @ row14 adr */
|
||||
|
||||
cmpl $ROW11_DATA, %eax /* row must be greater than 11 pattern */
|
||||
jb bad_ram
|
||||
@@ -351,7 +354,7 @@ fs movl (%esi), %eax /* read actual number of rows @ row14 a
|
||||
* read col 11 wrap adr for real column data value
|
||||
*/
|
||||
movl $COL11_ADR, %esi /* set address to max col (11) wrap addr */
|
||||
fs movl (%esi), %eax /* read real col number at max col adr */
|
||||
movl (%esi), %eax /* read real col number at max col adr */
|
||||
/*
|
||||
* validate column data
|
||||
*/
|
||||
@@ -389,9 +392,9 @@ fs movl (%esi), %eax /* read real col number at max col adr
|
||||
bad_reint:
|
||||
movl $DRCCTL, %esi /* setup DRAM control register with */
|
||||
movb $0x2,%al /* All banks precharge */
|
||||
fs movb %al, (%esi)
|
||||
movb %al, (%esi)
|
||||
movl $CACHELINESZ, %esi /* address to init read buffer */
|
||||
fs movw %ax, (%esi)
|
||||
movw %ax, (%esi)
|
||||
|
||||
/*
|
||||
* update ENDING ADDRESS REGISTER
|
||||
@@ -399,7 +402,7 @@ fs movw %ax, (%esi)
|
||||
movl $DRCBENDADR, %edi /* DRAM ending address register */
|
||||
movl %ecx,%ebx
|
||||
addl %ebx, %edi
|
||||
fs movb %dh, (%edi)
|
||||
movb %dh, (%edi)
|
||||
/*
|
||||
* update CONFIG REGISTER
|
||||
*/
|
||||
@@ -413,10 +416,10 @@ fs movb %dh, (%edi)
|
||||
notw %bx
|
||||
xchgw %cx,%ax
|
||||
movl $DRCCFG, %edi
|
||||
fs mov (%edi), %ax
|
||||
mov (%edi), %ax
|
||||
andw %bx,%ax
|
||||
orw %dx,%ax
|
||||
fs movw %ax, (%edi)
|
||||
movw %ax, (%edi)
|
||||
jcxz cleanup
|
||||
|
||||
decw %cx
|
||||
@@ -424,15 +427,15 @@ fs movw %ax, (%edi)
|
||||
movl $DRCBENDADR, %edi /* DRAM ending address register */
|
||||
movb $0xff,%al
|
||||
addl %ebx, %edi
|
||||
fs movb %al, (%edi)
|
||||
movb %al, (%edi)
|
||||
/*
|
||||
* set control register to NORMAL mode
|
||||
*/
|
||||
movl $DRCCTL, %esi /* setup DRAM control register with */
|
||||
movb $0x0,%al /* Normal mode value */
|
||||
fs movb %al, (%esi)
|
||||
movb %al, (%esi)
|
||||
movl $CACHELINESZ, %esi /* address to init read buffer */
|
||||
fs movw %ax, (%esi)
|
||||
movw %ax, (%esi)
|
||||
jmp nextbank
|
||||
|
||||
cleanup:
|
||||
@@ -440,7 +443,7 @@ cleanup:
|
||||
movw $4,%cx
|
||||
xorw %ax,%ax
|
||||
cleanuplp:
|
||||
fs movb (%edi), %al
|
||||
movb (%edi), %al
|
||||
orb %al,%al
|
||||
jz emptybank
|
||||
|
||||
@@ -451,7 +454,7 @@ fs movb (%edi), %al
|
||||
nottoomuch:
|
||||
movb %al,%ah
|
||||
orb $0x80,%al
|
||||
fs movb %al, (%edi)
|
||||
movb %al, (%edi)
|
||||
emptybank:
|
||||
incl %edi
|
||||
loop cleanuplp
|
||||
@@ -471,13 +474,13 @@ emptybank:
|
||||
#endif
|
||||
movl $DRCCTL, %edi /* DRAM Control register */
|
||||
movb $0x3,%al /* Load mode register cmd */
|
||||
fs movb %al, (%edi)
|
||||
fs movw %ax, (%esi)
|
||||
movb %al, (%edi)
|
||||
movw %ax, (%esi)
|
||||
|
||||
|
||||
movl $DRCCTL, %edi /* DRAM Control register */
|
||||
movb $0x18,%al /* Enable refresh and NORMAL mode */
|
||||
fs movb %al, (%edi)
|
||||
movb %al, (%edi)
|
||||
|
||||
jmp dram_done
|
||||
|
||||
@@ -528,3 +531,6 @@ bank0: movl (%edi), %eax
|
||||
done: movl %ebx, %eax
|
||||
|
||||
jmp *%ebp
|
||||
|
||||
|
||||
#endif /* CONFIG_SC520 */
|
||||
+102
-51
@@ -24,6 +24,7 @@
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
/*------------------------------------------------------------------------------+ */
|
||||
|
||||
/*
|
||||
* This source code has been made available to you by IBM on an AS-IS
|
||||
* basis. Anyone receiving this source is licensed under IBM
|
||||
@@ -89,13 +90,15 @@ typedef struct {
|
||||
char *rx_buffer;
|
||||
ulong rx_put;
|
||||
ulong rx_get;
|
||||
int cts;
|
||||
} serial_buffer_t;
|
||||
|
||||
volatile static serial_buffer_t buf_info;
|
||||
volatile serial_buffer_t buf_info;
|
||||
static int serial_buffer_active=0;
|
||||
#endif
|
||||
|
||||
|
||||
static int serial_div (int baudrate )
|
||||
static int serial_div(int baudrate)
|
||||
{
|
||||
|
||||
switch (baudrate) {
|
||||
@@ -112,7 +115,8 @@ static int serial_div (int baudrate )
|
||||
case 115200:
|
||||
return 1;
|
||||
}
|
||||
hang ();
|
||||
|
||||
return 12;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +125,7 @@ static int serial_div (int baudrate )
|
||||
* as serial console interface.
|
||||
*/
|
||||
|
||||
int serial_init (void)
|
||||
int serial_init(void)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -134,24 +138,24 @@ int serial_init (void)
|
||||
outb(bdiv, UART0_BASE + UART_DLL); /* set baudrate divisor */
|
||||
outb(bdiv >> 8, UART0_BASE + UART_DLM);/* set baudrate divisor */
|
||||
outb(0x03, UART0_BASE + UART_LCR); /* clear DLAB; set 8 bits, no parity */
|
||||
outb(0x00, UART0_BASE + UART_FCR); /* disable FIFO */
|
||||
outb(0x00, UART0_BASE + UART_MCR); /* no modem control DTR RTS */
|
||||
outb(0x01, UART0_BASE + UART_FCR); /* enable FIFO */
|
||||
outb(0x0b, UART0_BASE + UART_MCR); /* Set DTR and RTS active */
|
||||
val = inb(UART0_BASE + UART_LSR); /* clear line status */
|
||||
val = inb(UART0_BASE + UART_RBR); /* read receive buffer */
|
||||
outb(0x00, UART0_BASE + UART_SCR); /* set scratchpad */
|
||||
outb(0x00, UART0_BASE + UART_IER); /* set interrupt enable reg */
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void serial_setbrg (void)
|
||||
void serial_setbrg(void)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
unsigned short bdiv;
|
||||
|
||||
bdiv = serial_div (gd->baudrate);
|
||||
bdiv = serial_div(gd->baudrate);
|
||||
|
||||
outb(0x80, UART0_BASE + UART_LCR); /* set DLAB bit */
|
||||
outb(bdiv&0xff, UART0_BASE + UART_DLL); /* set baudrate divisor */
|
||||
@@ -160,7 +164,7 @@ void serial_setbrg (void)
|
||||
}
|
||||
|
||||
|
||||
void serial_putc (const char c)
|
||||
void serial_putc(const char c)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -169,31 +173,38 @@ void serial_putc (const char c)
|
||||
|
||||
/* check THRE bit, wait for transmiter available */
|
||||
for (i = 1; i < 3500; i++) {
|
||||
if ((inb (UART0_BASE + UART_LSR) & 0x20) == 0x20)
|
||||
if ((inb (UART0_BASE + UART_LSR) & 0x20) == 0x20) {
|
||||
break;
|
||||
udelay (100);
|
||||
}
|
||||
udelay(100);
|
||||
}
|
||||
outb(c, UART0_BASE + UART_THR); /* put character out */
|
||||
}
|
||||
|
||||
|
||||
void serial_puts (const char *s)
|
||||
void serial_puts(const char *s)
|
||||
{
|
||||
while (*s) {
|
||||
serial_putc (*s++);
|
||||
serial_putc(*s++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int serial_getc ()
|
||||
int serial_getc(void)
|
||||
{
|
||||
unsigned char status = 0;
|
||||
|
||||
#if CONFIG_SERIAL_SOFTWARE_FIFO
|
||||
if (serial_buffer_active) {
|
||||
return serial_buffered_getc();
|
||||
}
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
#if defined(CONFIG_HW_WATCHDOG)
|
||||
WATCHDOG_RESET (); /* Reset HW Watchdog, if needed */
|
||||
WATCHDOG_RESET(); /* Reset HW Watchdog, if needed */
|
||||
#endif /* CONFIG_HW_WATCHDOG */
|
||||
status = inb (UART0_BASE + UART_LSR);
|
||||
status = inb(UART0_BASE + UART_LSR);
|
||||
if ((status & asyncLSRDataReady1) != 0x0) {
|
||||
break;
|
||||
}
|
||||
@@ -211,11 +222,17 @@ int serial_getc ()
|
||||
}
|
||||
|
||||
|
||||
int serial_tstc ()
|
||||
int serial_tstc(void)
|
||||
{
|
||||
unsigned char status;
|
||||
|
||||
status = inb (UART0_BASE + UART_LSR);
|
||||
#if CONFIG_SERIAL_SOFTWARE_FIFO
|
||||
if (serial_buffer_active) {
|
||||
return serial_buffered_tstc();
|
||||
}
|
||||
#endif
|
||||
|
||||
status = inb(UART0_BASE + UART_LSR);
|
||||
if ((status & asyncLSRDataReady1) != 0x0) {
|
||||
return (1);
|
||||
}
|
||||
@@ -234,36 +251,50 @@ int serial_tstc ()
|
||||
|
||||
#if CONFIG_SERIAL_SOFTWARE_FIFO
|
||||
|
||||
void serial_isr (void *arg)
|
||||
void serial_isr(void *arg)
|
||||
{
|
||||
int space;
|
||||
int c;
|
||||
const int rx_get = buf_info.rx_get;
|
||||
int rx_put = buf_info.rx_put;
|
||||
|
||||
if (rx_get <= rx_put) {
|
||||
space = CONFIG_SERIAL_SOFTWARE_FIFO - (rx_put - rx_get);
|
||||
if (buf_info.rx_get <= rx_put) {
|
||||
space = CONFIG_SERIAL_SOFTWARE_FIFO - (rx_put - buf_info.rx_get);
|
||||
} else {
|
||||
space = rx_get - rx_put;
|
||||
space = buf_info.rx_get - rx_put;
|
||||
}
|
||||
while (serial_tstc ()) {
|
||||
c = serial_getc ();
|
||||
|
||||
while (inb(UART0_BASE + UART_LSR) & 1) {
|
||||
c = inb(UART0_BASE);
|
||||
if (space) {
|
||||
buf_info.rx_buffer[rx_put++] = c;
|
||||
space--;
|
||||
|
||||
if (rx_put == buf_info.rx_get) {
|
||||
buf_info.rx_get++;
|
||||
if (rx_put == CONFIG_SERIAL_SOFTWARE_FIFO) {
|
||||
buf_info.rx_get = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (rx_put == CONFIG_SERIAL_SOFTWARE_FIFO) {
|
||||
rx_put = 0;
|
||||
if (0 == buf_info.rx_get) {
|
||||
buf_info.rx_get = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (rx_put == CONFIG_SERIAL_SOFTWARE_FIFO)
|
||||
rx_put = 0;
|
||||
if (space < CONFIG_SERIAL_SOFTWARE_FIFO / 4) {
|
||||
/* Stop flow by setting RTS inactive */
|
||||
outb(inb (UART0_BASE + UART_MCR) & (0xFF ^ 0x02),
|
||||
outb(inb(UART0_BASE + UART_MCR) & (0xFF ^ 0x02),
|
||||
UART0_BASE + UART_MCR);
|
||||
}
|
||||
}
|
||||
buf_info.rx_put = rx_put;
|
||||
}
|
||||
|
||||
void serial_buffered_init (void)
|
||||
void serial_buffered_init(void)
|
||||
{
|
||||
serial_puts ("Switching to interrupt driven serial input mode.\n");
|
||||
buf_info.rx_buffer = malloc (CONFIG_SERIAL_SOFTWARE_FIFO);
|
||||
@@ -272,8 +303,10 @@ void serial_buffered_init (void)
|
||||
|
||||
if (inb (UART0_BASE + UART_MSR) & 0x10) {
|
||||
serial_puts ("Check CTS signal present on serial port: OK.\n");
|
||||
buf_info.cts = 1;
|
||||
} else {
|
||||
serial_puts ("WARNING: CTS signal not present on serial port.\n");
|
||||
buf_info.cts = 0;
|
||||
}
|
||||
|
||||
irq_install_handler ( VECNUM_U0 /*UART0 *//*int vec */ ,
|
||||
@@ -283,32 +316,49 @@ void serial_buffered_init (void)
|
||||
/* Enable "RX Data Available" Interrupt on UART */
|
||||
/* outb(inb(UART0_BASE + UART_IER) |0x01, UART0_BASE + UART_IER); */
|
||||
outb(0x01, UART0_BASE + UART_IER);
|
||||
/* Set DTR active */
|
||||
outb(inb (UART0_BASE + UART_MCR) | 0x01, UART0_BASE + UART_MCR);
|
||||
/* Start flow by setting RTS active */
|
||||
outb(inb (UART0_BASE + UART_MCR) | 0x02, UART0_BASE + UART_MCR);
|
||||
/* Setup UART FIFO: RX trigger level: 4 byte, Enable FIFO */
|
||||
outb((1 << 6) | 1, UART0_BASE + UART_FCR);
|
||||
|
||||
/* Set DTR and RTS active, enable interrupts */
|
||||
outb(inb (UART0_BASE + UART_MCR) | 0x0b, UART0_BASE + UART_MCR);
|
||||
|
||||
/* Setup UART FIFO: RX trigger level: 1 byte, Enable FIFO */
|
||||
outb( /*(1 << 6) |*/ 1, UART0_BASE + UART_FCR);
|
||||
|
||||
serial_buffer_active = 1;
|
||||
}
|
||||
|
||||
void serial_buffered_putc (const char c)
|
||||
{
|
||||
int i;
|
||||
/* Wait for CTS */
|
||||
#if defined(CONFIG_HW_WATCHDOG)
|
||||
while (!(inb (UART0_BASE + UART_MSR) & 0x10))
|
||||
WATCHDOG_RESET ();
|
||||
#else
|
||||
while (!(inb (UART0_BASE + UART_MSR) & 0x10));
|
||||
if (buf_info.cts) {
|
||||
for (i=0;i<1000;i++) {
|
||||
if ((inb (UART0_BASE + UART_MSR) & 0x10)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i!=1000) {
|
||||
buf_info.cts = 0;
|
||||
}
|
||||
} else {
|
||||
if ((inb (UART0_BASE + UART_MSR) & 0x10)) {
|
||||
buf_info.cts = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
serial_putc (c);
|
||||
}
|
||||
|
||||
void serial_buffered_puts (const char *s)
|
||||
void serial_buffered_puts(const char *s)
|
||||
{
|
||||
serial_puts (s);
|
||||
}
|
||||
|
||||
int serial_buffered_getc (void)
|
||||
int serial_buffered_getc(void)
|
||||
{
|
||||
int space;
|
||||
int c;
|
||||
@@ -322,8 +372,9 @@ int serial_buffered_getc (void)
|
||||
while (rx_get == buf_info.rx_put);
|
||||
#endif
|
||||
c = buf_info.rx_buffer[rx_get++];
|
||||
if (rx_get == CONFIG_SERIAL_SOFTWARE_FIFO)
|
||||
if (rx_get == CONFIG_SERIAL_SOFTWARE_FIFO) {
|
||||
rx_get = 0;
|
||||
}
|
||||
buf_info.rx_get = rx_get;
|
||||
|
||||
rx_put = buf_info.rx_put;
|
||||
@@ -340,7 +391,7 @@ int serial_buffered_getc (void)
|
||||
return c;
|
||||
}
|
||||
|
||||
int serial_buffered_tstc (void)
|
||||
int serial_buffered_tstc(void)
|
||||
{
|
||||
return (buf_info.rx_get != buf_info.rx_put) ? 1 : 0;
|
||||
}
|
||||
@@ -358,7 +409,7 @@ int serial_buffered_tstc (void)
|
||||
configure port 1 for serial I/O with rate = CONFIG_KGDB_BAUDRATE
|
||||
*/
|
||||
#if (CONFIG_KGDB_SER_INDEX & 2)
|
||||
void kgdb_serial_init (void)
|
||||
void kgdb_serial_init(void)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
@@ -381,7 +432,7 @@ void kgdb_serial_init (void)
|
||||
}
|
||||
|
||||
|
||||
void putDebugChar (const char c)
|
||||
void putDebugChar(const char c)
|
||||
{
|
||||
if (c == '\n')
|
||||
serial_putc ('\r');
|
||||
@@ -393,7 +444,7 @@ void putDebugChar (const char c)
|
||||
}
|
||||
|
||||
|
||||
void putDebugStr (const char *s)
|
||||
void putDebugStr(const char *s)
|
||||
{
|
||||
while (*s) {
|
||||
serial_putc(*s++);
|
||||
@@ -401,7 +452,7 @@ void putDebugStr (const char *s)
|
||||
}
|
||||
|
||||
|
||||
int getDebugChar (void)
|
||||
int getDebugChar(void)
|
||||
{
|
||||
unsigned char status = 0;
|
||||
|
||||
@@ -424,34 +475,34 @@ int getDebugChar (void)
|
||||
}
|
||||
|
||||
|
||||
void kgdb_interruptible (int yes)
|
||||
void kgdb_interruptible(int yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#else /* ! (CONFIG_KGDB_SER_INDEX & 2) */
|
||||
|
||||
void kgdb_serial_init (void)
|
||||
void kgdb_serial_init(void)
|
||||
{
|
||||
serial_printf ("[on serial] ");
|
||||
}
|
||||
|
||||
void putDebugChar (int c)
|
||||
void putDebugChar(int c)
|
||||
{
|
||||
serial_putc (c);
|
||||
}
|
||||
|
||||
void putDebugStr (const char *str)
|
||||
void putDebugStr(const char *str)
|
||||
{
|
||||
serial_puts (str);
|
||||
}
|
||||
|
||||
int getDebugChar (void)
|
||||
int getDebugChar(void)
|
||||
{
|
||||
return serial_getc ();
|
||||
}
|
||||
|
||||
void kgdb_interruptible (int yes)
|
||||
void kgdb_interruptible(int yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* U-boot - i386 Startup Code
|
||||
*
|
||||
* Copyright (c) 2002 Omicron Ceti AB, Daniel Engström <denaiel@omicron.se>
|
||||
* Copyright (c) 2002, 2003 Omicron Ceti AB, Daniel Engström <denaiel@omicron.se>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
@@ -40,7 +40,7 @@ board_init16_ret:
|
||||
|
||||
/* Turn of cache (this might require a 486-class CPU) */
|
||||
movl %cr0, %eax
|
||||
orl $060000000,%eax
|
||||
orl $0x60000000,%eax
|
||||
movl %eax, %cr0
|
||||
wbinvd
|
||||
|
||||
|
||||
+1
-1
@@ -556,7 +556,7 @@ trap_init:
|
||||
lwz r7, GOT(_start)
|
||||
lwz r8, GOT(_end_of_vectors)
|
||||
|
||||
rlwinm r9, r7, 0, 22, 31 /* _start & 0x3FF */
|
||||
li r9, 0x100 /* reset vector always at 0x100 */
|
||||
|
||||
cmplw 0, r7, r8
|
||||
bgelr /* return if r7>=r8 - just in case */
|
||||
|
||||
+2
-2
@@ -543,7 +543,7 @@ relocate_code:
|
||||
mr r10, r5 /* Save copy of Destination Address */
|
||||
|
||||
mr r3, r5 /* Destination Address */
|
||||
#ifdef DEBUG
|
||||
#ifdef CFG_RAMBOOT
|
||||
lis r4, CFG_SDRAM_BASE@h /* Source Address */
|
||||
ori r4, r4, CFG_SDRAM_BASE@l
|
||||
#else
|
||||
@@ -695,7 +695,7 @@ trap_init:
|
||||
lwz r7, GOT(_start)
|
||||
lwz r8, GOT(_end_of_vectors)
|
||||
|
||||
rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */
|
||||
li r9, 0x100 /* reset vector always at 0x100 */
|
||||
|
||||
cmplw 0, r7, r8
|
||||
bgelr /* return if r7>=r8 - just in case */
|
||||
|
||||
+12
-6
@@ -170,7 +170,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef CFG_PCI_MSTR_MEMIO_SIZE
|
||||
#define PCI_MSTR_MEMIO_SIZE 0x20000000 /* 512MB */
|
||||
#define PCI_MSTR_MEMIO_SIZE 0x10000000 /* 256 MB */
|
||||
#else
|
||||
#define PCI_MSTR_MEMIO_SIZE CFG_PCI_MSTR_MEMIO_SIZE
|
||||
#endif
|
||||
@@ -353,6 +353,12 @@ void pci_mpc8250_init(struct pci_controller *hose)
|
||||
pci_hose_write_config_word(hose, host_devno, PCI_COMMAND,
|
||||
tempShort | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
|
||||
|
||||
#ifdef CONFIG_MPC8266ADS
|
||||
/* do some bridge init, should be done on all 8260 based bridges */
|
||||
pci_hose_write_config_byte(hose, host_devno, PCI_CACHE_LINE_SIZE, 0x08);
|
||||
pci_hose_write_config_byte(hose, host_devno, PCI_LATENCY_TIMER, 0xF8);
|
||||
#endif
|
||||
|
||||
hose->first_busno = 0;
|
||||
hose->last_busno = 0xff;
|
||||
|
||||
@@ -373,11 +379,11 @@ void pci_mpc8250_init(struct pci_controller *hose)
|
||||
|
||||
/* PCI memory space */
|
||||
#ifdef CONFIG_MPC8266ADS
|
||||
pci_set_region(hose->regions + 0,
|
||||
PCI_SLV_MEM_BUS,
|
||||
PCI_SLV_MEM_LOCAL,
|
||||
gd->ram_size,
|
||||
PCI_REGION_MEM | PCI_REGION_MEMORY);
|
||||
pci_set_region(hose->regions + 1,
|
||||
PCI_MSTR_MEMIO_BUS,
|
||||
PCI_MSTR_MEMIO_LOCAL,
|
||||
PCI_MSTR_MEMIO_SIZE,
|
||||
PCI_REGION_MEM);
|
||||
#else
|
||||
pci_set_region(hose->regions + 1,
|
||||
PCI_MSTR_MEM_BUS,
|
||||
|
||||
+1
-1
@@ -1028,7 +1028,7 @@ trap_init:
|
||||
lwz r7, GOT(_start)
|
||||
lwz r8, GOT(_end_of_vectors)
|
||||
|
||||
rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */
|
||||
li r9, 0x100 /* reset vector always at 0x100 */
|
||||
|
||||
cmplw 0, r7, r8
|
||||
bgelr /* return if r7>=r8 - just in case */
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ START = start.o kgdb.o
|
||||
OBJS = bedbug_860.o commproc.o cpu.o cpu_init.o \
|
||||
fec.o i2c.o interrupts.o lcd.o scc.o \
|
||||
serial.o speed.o spi.o status_led.o\
|
||||
traps.o upatch.o video.o wlkbd.o
|
||||
traps.o upatch.o video.o
|
||||
|
||||
all: .depend $(START) $(LIB)
|
||||
|
||||
|
||||
+74
-17
@@ -36,7 +36,7 @@
|
||||
#if defined(CONFIG_POST)
|
||||
#include <post.h>
|
||||
#endif
|
||||
|
||||
#include <lcd.h>
|
||||
|
||||
#ifdef CONFIG_LCD
|
||||
|
||||
@@ -134,6 +134,19 @@ static vidinfo_t panel_info = {
|
||||
#endif /* CONFIG_KYOCERA_KCS057QV1AJ */
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#ifdef CONFIG_HITACHI_SP19X001_Z1A
|
||||
/*
|
||||
* Hitachi SP19X001-. Active, color, single scan.
|
||||
*/
|
||||
static vidinfo_t panel_info = {
|
||||
640, 480, 154, 116, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH, CFG_HIGH,
|
||||
LCD_COLOR8, 1, 0, 1, 0, 0, 0, 0, 0
|
||||
/* wbl, vpw, lcdac, wbf */
|
||||
};
|
||||
#endif /* CONFIG_HITACHI_SP19X001_Z1A */
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#ifdef CONFIG_NEC_NL6648AC33
|
||||
/*
|
||||
@@ -307,7 +320,7 @@ static int lcd_line_length;
|
||||
static int lcd_color_fg;
|
||||
static int lcd_color_bg;
|
||||
|
||||
static char lcd_is_enabled = 0; /* Indicate that LCD is enabled */
|
||||
char lcd_is_enabled = 0; /* Indicate that LCD is enabled */
|
||||
|
||||
/*
|
||||
* Frame buffer memory information
|
||||
@@ -395,7 +408,8 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);
|
||||
static inline void lcd_puts_xy (ushort x, ushort y, uchar *s);
|
||||
static inline void lcd_putc_xy (ushort x, ushort y, uchar c);
|
||||
|
||||
static int lcd_init (void *lcdbase);
|
||||
int lcd_init (void *lcdbase);
|
||||
|
||||
static void lcd_ctrl_init (void *lcdbase);
|
||||
static void lcd_enable (void);
|
||||
static void *lcd_logo (void);
|
||||
@@ -410,8 +424,11 @@ static int lcd_getbgcolor (void);
|
||||
static void lcd_setfgcolor (int color);
|
||||
static void lcd_setbgcolor (int color);
|
||||
|
||||
#if defined(CONFIG_RBC823)
|
||||
void lcd_disable (void);
|
||||
#endif
|
||||
|
||||
#ifdef NOT_USED_SO_FAR
|
||||
static void lcd_disable (void);
|
||||
static void lcd_getcolreg (ushort regno,
|
||||
ushort *red, ushort *green, ushort *blue);
|
||||
static int lcd_getfgcolor (void);
|
||||
@@ -675,7 +692,7 @@ int drv_lcd_init (void)
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
static int lcd_init (void *lcdbase)
|
||||
int lcd_init (void *lcdbase)
|
||||
{
|
||||
/* Initialize the lcd controller */
|
||||
debug ("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
|
||||
@@ -778,6 +795,7 @@ static void lcd_ctrl_init (void *lcdbase)
|
||||
volatile lcd823_t *lcdp = &immr->im_lcd;
|
||||
|
||||
uint lccrtmp;
|
||||
uint lchcr_hpc_tmp;
|
||||
|
||||
/* Initialize the LCD control register according to the LCD
|
||||
* parameters defined. We do everything here but enable
|
||||
@@ -808,6 +826,9 @@ static void lcd_ctrl_init (void *lcdbase)
|
||||
|
||||
/* Initialize LCD controller bus priorities.
|
||||
*/
|
||||
#ifdef CONFIG_RBC823
|
||||
immr->im_siu_conf.sc_sdcr = (immr->im_siu_conf.sc_sdcr & ~0x0f) | 1; /* RAID = 01, LAID = 00 */
|
||||
#else
|
||||
immr->im_siu_conf.sc_sdcr &= ~0x0f; /* RAID = LAID = 0 */
|
||||
|
||||
/* set SHFT/CLOCK division factor 4
|
||||
@@ -821,7 +842,21 @@ static void lcd_ctrl_init (void *lcdbase)
|
||||
immr->im_clkrst.car_sccr &= ~0x1F;
|
||||
immr->im_clkrst.car_sccr |= LCD_DF; /* was 8 */
|
||||
|
||||
#ifndef CONFIG_EDT32F10
|
||||
#endif /* CONFIG_RBC823 */
|
||||
|
||||
#if defined(CONFIG_RBC823)
|
||||
/* Enable LCD on port D.
|
||||
*/
|
||||
immr->im_ioport.iop_pddat &= 0x0300;
|
||||
immr->im_ioport.iop_pdpar |= 0x1CFF;
|
||||
immr->im_ioport.iop_pddir |= 0x1CFF;
|
||||
|
||||
/* Configure LCD_ON, VEE_ON, CCFL_ON on port B.
|
||||
*/
|
||||
immr->im_cpm.cp_pbdat &= ~0x00005001;
|
||||
immr->im_cpm.cp_pbpar &= ~0x00005001;
|
||||
immr->im_cpm.cp_pbdir |= 0x00005001;
|
||||
#elif !defined(CONFIG_EDT32F10)
|
||||
/* Enable LCD on port D.
|
||||
*/
|
||||
immr->im_ioport.iop_pdpar |= 0x1FFF;
|
||||
@@ -850,18 +885,22 @@ static void lcd_ctrl_init (void *lcdbase)
|
||||
|
||||
/* MORE HACKS...This must be updated according to 823 manual
|
||||
* for different panels.
|
||||
* Udi Finkelstein - done - see below:
|
||||
* Note: You better not try unsupported combinations such as
|
||||
* 4-bit wide passive dual scan LCD at 4/8 Bit color.
|
||||
*/
|
||||
#ifndef CONFIG_EDT32F10
|
||||
lchcr_hpc_tmp =
|
||||
(panel_info.vl_col *
|
||||
(panel_info.vl_tft ? 8 :
|
||||
(((2 - panel_info.vl_lbw) << /* 4 bit=2, 8-bit = 1 */
|
||||
/* use << to mult by: single scan = 1, dual scan = 2 */
|
||||
panel_info.vl_splt) *
|
||||
(panel_info.vl_bpix | 1)))) >> 3; /* 2/4 BPP = 1, 8/16 BPP = 3 */
|
||||
|
||||
lcdp->lcd_lchcr = LCHCR_BO |
|
||||
LCDBIT (LCHCR_AT_BIT, 4) |
|
||||
LCDBIT (LCHCR_HPC_BIT, panel_info.vl_col) |
|
||||
LCDBIT (LCHCR_HPC_BIT, lchcr_hpc_tmp) |
|
||||
panel_info.vl_wbl;
|
||||
#else
|
||||
lcdp->lcd_lchcr = LCHCR_BO |
|
||||
LCDBIT (LCHCR_AT_BIT, 4) |
|
||||
LCDBIT (LCHCR_HPC_BIT, panel_info.vl_col/4) |
|
||||
panel_info.vl_wbl;
|
||||
#endif
|
||||
|
||||
lcdp->lcd_lcvcr = LCDBIT (LCVCR_VPW_BIT, panel_info.vl_vpw) |
|
||||
LCDBIT (LCVCR_LCD_AC_BIT, panel_info.vl_lcdac) |
|
||||
@@ -975,13 +1014,18 @@ static void lcd_enable (void)
|
||||
volatile lcd823_t *lcdp = &immr->im_lcd;
|
||||
|
||||
/* Enable the LCD panel */
|
||||
#ifndef CONFIG_RBC823
|
||||
immr->im_siu_conf.sc_sdcr |= (1 << (31 - 25)); /* LAM = 1 */
|
||||
#endif
|
||||
lcdp->lcd_lccr |= LCCR_PON;
|
||||
|
||||
#ifdef CONFIG_V37
|
||||
/* Turn on display backlight */
|
||||
immr->im_cpm.cp_pbpar |= 0x00008000;
|
||||
immr->im_cpm.cp_pbdir |= 0x00008000;
|
||||
#elif defined(CONFIG_RBC823)
|
||||
/* Turn on display backlight */
|
||||
immr->im_cpm.cp_pbdat |= 0x00004000;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_LWMON)
|
||||
@@ -1005,12 +1049,20 @@ static void lcd_enable (void)
|
||||
r360_i2c_lcd_write(0x47, 0xFF);
|
||||
}
|
||||
#endif /* CONFIG_R360MPI */
|
||||
#ifdef CONFIG_RBC823
|
||||
udelay(200000); /* wait 200ms */
|
||||
/* Turn VEE_ON first */
|
||||
immr->im_cpm.cp_pbdat |= 0x00000001;
|
||||
udelay(200000); /* wait 200ms */
|
||||
/* Now turn on LCD_ON */
|
||||
immr->im_cpm.cp_pbdat |= 0x00001000;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#ifdef NOT_USED_SO_FAR
|
||||
static void lcd_disable (void)
|
||||
#if defined (CONFIG_RBC823)
|
||||
void lcd_disable (void)
|
||||
{
|
||||
volatile immap_t *immr = (immap_t *) CFG_IMMR;
|
||||
volatile lcd823_t *lcdp = &immr->im_lcd;
|
||||
@@ -1032,9 +1084,14 @@ static void lcd_disable (void)
|
||||
#endif /* CONFIG_LWMON */
|
||||
/* Disable the LCD panel */
|
||||
lcdp->lcd_lccr &= ~LCCR_PON;
|
||||
#ifdef CONFIG_RBC823
|
||||
/* Turn off display backlight, VEE and LCD_ON */
|
||||
immr->im_cpm.cp_pbdat &= ~0x00005001;
|
||||
#else
|
||||
immr->im_siu_conf.sc_sdcr &= ~(1 << (31 - 25)); /* LAM = 0 */
|
||||
#endif /* CONFIG_RBC823 */
|
||||
}
|
||||
#endif /* NOT_USED_SO_FAR */
|
||||
#endif /* NOT_USED_SO_FAR || CONFIG_RBC823 */
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
+1
-1
@@ -723,7 +723,7 @@ trap_init:
|
||||
lwz r7, GOT(_start)
|
||||
lwz r8, GOT(_end_of_vectors)
|
||||
|
||||
rlwinm r9, r7, 0, 22, 31 /* _start & 0x3FF */
|
||||
li r9, 0x100 /* reset vector always at 0x100 */
|
||||
|
||||
cmplw 0, r7, r8
|
||||
bgelr /* return if r7>=r8 - just in case */
|
||||
|
||||
+54
-13
@@ -173,17 +173,16 @@ static bd_t *bis_save = NULL; /* for eth_init upon mal error */
|
||||
static int is_receiving = 0; /* sync with eth interrupt */
|
||||
static int print_speed = 1; /* print speed message upon start */
|
||||
|
||||
static void enet_rcv (unsigned long malisr);
|
||||
|
||||
/*-----------------------------------------------------------------------------+
|
||||
* Prototypes and externals.
|
||||
*-----------------------------------------------------------------------------*/
|
||||
void mal_err (unsigned long isr, unsigned long uic, unsigned long mal_def,
|
||||
static void enet_rcv (unsigned long malisr);
|
||||
static int enetInt(void);
|
||||
static void mal_err (unsigned long isr, unsigned long uic, unsigned long mal_def,
|
||||
unsigned long mal_errr);
|
||||
void emac_err (unsigned long isr);
|
||||
static void emac_err (unsigned long isr);
|
||||
|
||||
|
||||
void eth_halt (void)
|
||||
static void ppc_4xx_eth_halt (struct eth_device *dev)
|
||||
{
|
||||
mtdcr (malier, 0x00000000); /* disable mal interrupts */
|
||||
out32 (EMAC_IER, 0x00000000); /* disable emac interrupts */
|
||||
@@ -202,7 +201,7 @@ void eth_halt (void)
|
||||
}
|
||||
|
||||
|
||||
int eth_init (bd_t * bis)
|
||||
static int ppc_4xx_eth_init (struct eth_device *dev, bd_t * bis)
|
||||
{
|
||||
int i;
|
||||
unsigned long reg;
|
||||
@@ -478,11 +477,11 @@ int eth_init (bd_t * bis)
|
||||
bis_save = bis;
|
||||
first_init = 1;
|
||||
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
int eth_send (volatile void *ptr, int len)
|
||||
static int ppc_4xx_eth_send (struct eth_device *dev, volatile void *ptr, int len)
|
||||
{
|
||||
struct enet_frame *ef_ptr;
|
||||
ulong time_start, time_now;
|
||||
@@ -539,7 +538,7 @@ int eth_send (volatile void *ptr, int len)
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
return (0);
|
||||
return (len);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -696,7 +695,7 @@ int enetInt ()
|
||||
/*-----------------------------------------------------------------------------+
|
||||
* MAL Error Routine
|
||||
*-----------------------------------------------------------------------------*/
|
||||
void mal_err (unsigned long isr, unsigned long uic, unsigned long maldef,
|
||||
static void mal_err (unsigned long isr, unsigned long uic, unsigned long maldef,
|
||||
unsigned long mal_errr)
|
||||
{
|
||||
mtdcr (malesr, isr); /* clear interrupt */
|
||||
@@ -724,7 +723,7 @@ void mal_err (unsigned long isr, unsigned long uic, unsigned long maldef,
|
||||
/*-----------------------------------------------------------------------------+
|
||||
* EMAC Error Routine
|
||||
*-----------------------------------------------------------------------------*/
|
||||
void emac_err (unsigned long isr)
|
||||
static void emac_err (unsigned long isr)
|
||||
{
|
||||
printf ("EMAC error occured.... ISR = %lx\n", isr);
|
||||
out32 (EMAC_ISR, isr);
|
||||
@@ -816,7 +815,7 @@ static void enet_rcv (unsigned long malisr)
|
||||
}
|
||||
|
||||
|
||||
int eth_rx (void)
|
||||
static int ppc_4xx_eth_rx (struct eth_device *dev)
|
||||
{
|
||||
int length;
|
||||
int user_index;
|
||||
@@ -864,4 +863,46 @@ int eth_rx (void)
|
||||
return length;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NET_MULTI)
|
||||
int ppc_4xx_eth_initialize(bd_t *bis)
|
||||
{
|
||||
struct eth_device *dev;
|
||||
int eth_num = 0;
|
||||
|
||||
dev = malloc (sizeof *dev);
|
||||
if (dev == NULL) {
|
||||
printf(__FUNCTION__ ": Cannot allocate eth_device\n");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
sprintf(dev->name, "ppc_4xx_eth%d", eth_num);
|
||||
dev->priv = (void *) eth_num;
|
||||
dev->init = ppc_4xx_eth_init;
|
||||
dev->halt = ppc_4xx_eth_halt;
|
||||
dev->send = ppc_4xx_eth_send;
|
||||
dev->recv = ppc_4xx_eth_rx;
|
||||
|
||||
eth_register (dev);
|
||||
}
|
||||
#else /* !defined(CONFIG_NET_MULTI) */
|
||||
void eth_halt (void)
|
||||
{
|
||||
ppc_4xx_eth_halt(NULL);
|
||||
}
|
||||
|
||||
int eth_init (bd_t *bis)
|
||||
{
|
||||
return (ppc_4xx_eth_init(NULL, bis));
|
||||
}
|
||||
int eth_send(volatile void *packet, int length)
|
||||
{
|
||||
return (ppc_4xx_eth_send(NULL, packet, length));
|
||||
}
|
||||
|
||||
int eth_rx(void)
|
||||
{
|
||||
return (ppc_4xx_eth_rx(NULL));
|
||||
}
|
||||
#endif /* !defined(CONFIG_NET_MULTI) */
|
||||
|
||||
#endif /* CONFIG_405GP */
|
||||
@@ -177,7 +177,7 @@ void pci_405gp_init(struct pci_controller *hose)
|
||||
* PLB address 0x80000000-0xBFFFFFFF ==> PCI address 0x80000000-0xBFFFFFFF
|
||||
* Use byte reversed out routines to handle endianess.
|
||||
*--------------------------------------------------------------------------*/
|
||||
out32r(PMM0MA, pmmma[0]); /* ensure disabled b4 setting PMM0LA */
|
||||
out32r(PMM0MA, (pmmma[0]&~0x1)); /* disable, configure PMMxLA, PMMxPCILA first */
|
||||
out32r(PMM0LA, pmmla[0]);
|
||||
out32r(PMM0PCILA, pmmpcila[0]);
|
||||
out32r(PMM0PCIHA, pmmpciha[0]);
|
||||
@@ -186,7 +186,7 @@ void pci_405gp_init(struct pci_controller *hose)
|
||||
/*--------------------------------------------------------------------------+
|
||||
* PMM1 is not used. Initialize them to zero.
|
||||
*--------------------------------------------------------------------------*/
|
||||
out32r(PMM1MA, pmmma[1]); /* ensure disabled b4 setting PMM2LA */
|
||||
out32r(PMM1MA, (pmmma[1]&~0x1));
|
||||
out32r(PMM1LA, pmmla[1]);
|
||||
out32r(PMM1PCILA, pmmpcila[1]);
|
||||
out32r(PMM1PCIHA, pmmpciha[1]);
|
||||
@@ -195,7 +195,7 @@ void pci_405gp_init(struct pci_controller *hose)
|
||||
/*--------------------------------------------------------------------------+
|
||||
* PMM2 is not used. Initialize them to zero.
|
||||
*--------------------------------------------------------------------------*/
|
||||
out32r(PMM2MA, pmmma[2]); /* ensure disabled b4 setting PMM2LA */
|
||||
out32r(PMM2MA, (pmmma[2]&~0x1));
|
||||
out32r(PMM2LA, pmmla[2]);
|
||||
out32r(PMM2PCILA, pmmpcila[2]);
|
||||
out32r(PMM2PCIHA, pmmpciha[2]);
|
||||
|
||||
+92
-7
@@ -30,6 +30,73 @@
|
||||
|
||||
#define mtebc(reg, data) mtdcr(ebccfga,reg);mtdcr(ebccfgd,data)
|
||||
|
||||
#ifdef CFG_INIT_DCACHE_CS
|
||||
# if (CFG_INIT_DCACHE_CS == 0)
|
||||
# define PBxAP pb0ap
|
||||
# define PBxCR pb0cr
|
||||
# if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
|
||||
# define PBxAP_VAL CFG_EBC_PB0AP
|
||||
# define PBxCR_VAL CFG_EBC_PB0CR
|
||||
# endif
|
||||
# endif
|
||||
# if (CFG_INIT_DCACHE_CS == 1)
|
||||
# define PBxAP pb1ap
|
||||
# define PBxCR pb1cr
|
||||
# if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR))
|
||||
# define PBxAP_VAL CFG_EBC_PB1AP
|
||||
# define PBxCR_VAL CFG_EBC_PB1CR
|
||||
# endif
|
||||
# endif
|
||||
# if (CFG_INIT_DCACHE_CS == 2)
|
||||
# define PBxAP pb2ap
|
||||
# define PBxCR pb2cr
|
||||
# if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR))
|
||||
# define PBxAP_VAL CFG_EBC_PB2AP
|
||||
# define PBxCR_VAL CFG_EBC_PB2CR
|
||||
# endif
|
||||
# endif
|
||||
# if (CFG_INIT_DCACHE_CS == 3)
|
||||
# define PBxAP pb3ap
|
||||
# define PBxCR pb3cr
|
||||
# if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR))
|
||||
# define PBxAP_VAL CFG_EBC_PB3AP
|
||||
# define PBxCR_VAL CFG_EBC_PB3CR
|
||||
# endif
|
||||
# endif
|
||||
# if (CFG_INIT_DCACHE_CS == 4)
|
||||
# define PBxAP pb4ap
|
||||
# define PBxCR pb4cr
|
||||
# if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR))
|
||||
# define PBxAP_VAL CFG_EBC_PB4AP
|
||||
# define PBxCR_VAL CFG_EBC_PB4CR
|
||||
# endif
|
||||
# endif
|
||||
# if (CFG_INIT_DCACHE_CS == 5)
|
||||
# define PBxAP pb5ap
|
||||
# define PBxCR pb5cr
|
||||
# if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR))
|
||||
# define PBxAP_VAL CFG_EBC_PB5AP
|
||||
# define PBxCR_VAL CFG_EBC_PB5CR
|
||||
# endif
|
||||
# endif
|
||||
# if (CFG_INIT_DCACHE_CS == 6)
|
||||
# define PBxAP pb6ap
|
||||
# define PBxCR pb6cr
|
||||
# if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR))
|
||||
# define PBxAP_VAL CFG_EBC_PB6AP
|
||||
# define PBxCR_VAL CFG_EBC_PB6CR
|
||||
# endif
|
||||
# endif
|
||||
# if (CFG_INIT_DCACHE_CS == 7)
|
||||
# define PBxAP pb7ap
|
||||
# define PBxCR pb7cr
|
||||
# if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR))
|
||||
# define PBxAP_VAL CFG_EBC_PB7AP
|
||||
# define PBxCR_VAL CFG_EBC_PB7CR
|
||||
# endif
|
||||
# endif
|
||||
#endif /* CFG_INIT_DCACHE_CS */
|
||||
|
||||
|
||||
/*
|
||||
* Breath some life into the CPU...
|
||||
@@ -82,37 +149,37 @@ cpu_init_f (void)
|
||||
mtebc(pb0cr, CFG_EBC_PB0CR);
|
||||
#endif
|
||||
|
||||
#if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR))
|
||||
#if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR) && !(CFG_INIT_DCACHE_CS == 1))
|
||||
mtebc(pb1ap, CFG_EBC_PB1AP);
|
||||
mtebc(pb1cr, CFG_EBC_PB1CR);
|
||||
#endif
|
||||
|
||||
#if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR))
|
||||
#if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR) && !(CFG_INIT_DCACHE_CS == 2))
|
||||
mtebc(pb2ap, CFG_EBC_PB2AP);
|
||||
mtebc(pb2cr, CFG_EBC_PB2CR);
|
||||
#endif
|
||||
|
||||
#if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR))
|
||||
#if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR) && !(CFG_INIT_DCACHE_CS == 3))
|
||||
mtebc(pb3ap, CFG_EBC_PB3AP);
|
||||
mtebc(pb3cr, CFG_EBC_PB3CR);
|
||||
#endif
|
||||
|
||||
#if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR))
|
||||
#if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR) && !(CFG_INIT_DCACHE_CS == 4))
|
||||
mtebc(pb4ap, CFG_EBC_PB4AP);
|
||||
mtebc(pb4cr, CFG_EBC_PB4CR);
|
||||
#endif
|
||||
|
||||
#if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR))
|
||||
#if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR) && !(CFG_INIT_DCACHE_CS == 5))
|
||||
mtebc(pb5ap, CFG_EBC_PB5AP);
|
||||
mtebc(pb5cr, CFG_EBC_PB5CR);
|
||||
#endif
|
||||
|
||||
#if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR))
|
||||
#if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR) && !(CFG_INIT_DCACHE_CS == 6))
|
||||
mtebc(pb6ap, CFG_EBC_PB6AP);
|
||||
mtebc(pb6cr, CFG_EBC_PB6CR);
|
||||
#endif
|
||||
|
||||
#if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR))
|
||||
#if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR) && !(CFG_INIT_DCACHE_CS == 7))
|
||||
mtebc(pb7ap, CFG_EBC_PB7AP);
|
||||
mtebc(pb7cr, CFG_EBC_PB7CR);
|
||||
#endif
|
||||
@@ -146,6 +213,24 @@ int cpu_init_r (void)
|
||||
uint pvr = get_pvr();
|
||||
#endif
|
||||
|
||||
#ifdef CFG_INIT_DCACHE_CS
|
||||
/*
|
||||
* Flush and invalidate dcache, then disable CS for temporary stack.
|
||||
* Afterwards, this CS can be used for other purposes
|
||||
*/
|
||||
dcache_disable(); /* flush and invalidate dcache */
|
||||
mtebc(PBxAP, 0);
|
||||
mtebc(PBxCR, 0); /* disable CS for temporary stack */
|
||||
|
||||
#if (defined(PBxAP_VAL) && defined(PBxCR_VAL))
|
||||
/*
|
||||
* Write new value into CS register
|
||||
*/
|
||||
mtebc(PBxAP, PBxAP_VAL);
|
||||
mtebc(PBxCR, PBxCR_VAL);
|
||||
#endif
|
||||
#endif /* CFG_INIT_DCACHE_CS */
|
||||
|
||||
/*
|
||||
* Write Ethernetaddress into on-chip register
|
||||
*/
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/* Copyright MontaVista Software Incorporated, 2000 */
|
||||
|
||||
|
||||
#include <config.h>
|
||||
.section .resetvec,"ax"
|
||||
#if defined(CONFIG_440)
|
||||
b _start_440
|
||||
#else
|
||||
#if defined(CONFIG_BOOT_PCI) && defined(CONFIG_MIP405)
|
||||
b _start_pci
|
||||
#else
|
||||
b _start
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -1381,7 +1381,7 @@ trap_init:
|
||||
lwz r7, GOT(_start)
|
||||
lwz r8, GOT(_end_of_vectors)
|
||||
|
||||
rlwinm r9, r7, 0, 18, 31 /* _start & 0x3FFF */
|
||||
li r9, 0x100 /* reset vector always at 0x100 */
|
||||
|
||||
cmplw 0, r7, r8
|
||||
bgelr /* return if r7>=r8 - just in case */
|
||||
|
||||
@@ -69,6 +69,8 @@ mm 2
|
||||
mtest 5
|
||||
muxinfo 3
|
||||
mw 2
|
||||
nand 3
|
||||
nboot 4
|
||||
next 4
|
||||
nm 2
|
||||
pciinfo 3
|
||||
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
NAND FLASH commands and notes
|
||||
|
||||
# (C) Copyright 2003
|
||||
# Dave Ellis, SIXNET, dge@sixnetio.com
|
||||
#
|
||||
# See file CREDITS for list of people who contributed to this
|
||||
# project.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License as
|
||||
# published by the Free Software Foundation; either version 2 of
|
||||
# the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
# MA 02111-1307 USA
|
||||
|
||||
Commands:
|
||||
|
||||
nand bad
|
||||
Print a list of all of the bad blocks in the current device.
|
||||
|
||||
nand device
|
||||
Print information about the current NAND device.
|
||||
|
||||
nand device num
|
||||
Make device `num' the current device and print information about it.
|
||||
|
||||
nand erase off size
|
||||
nand erase clean [off size]
|
||||
Erase `size' bytes starting at offset `off'. Only complete erase
|
||||
blocks can be erased.
|
||||
|
||||
If `clean' is specified, a JFFS2-style clean marker is written to
|
||||
each block after it is erased. If `clean' is specified without an
|
||||
offset or size, the entire flash is erased.
|
||||
|
||||
This command will not erase blocks that are marked bad. There is
|
||||
a debug option in cmd_nand.c to allow bad blocks to be erased.
|
||||
Please read the warning there before using it, as blocks marked
|
||||
bad by the manufacturer must _NEVER_ be erased.
|
||||
|
||||
nand info
|
||||
Print information about all of the NAND devices found.
|
||||
|
||||
nand read addr ofs size
|
||||
Read `size' bytes from `ofs' in NAND flash to `addr'. If a page
|
||||
cannot be read because it is marked bad or an uncorrectable data
|
||||
error is found the command stops with an error.
|
||||
|
||||
nand read.jffs2 addr ofs size
|
||||
Like `read', but the data for blocks that are marked bad is read as
|
||||
0xff. This gives a readable JFFS2 image that can be processed by
|
||||
the JFFS2 commands such as ls and fsload.
|
||||
|
||||
nand read.oob addr ofs size
|
||||
Read `size' bytes from the out-of-band data area corresponding to
|
||||
`ofs' in NAND flash to `addr'. This is limited to the 16 bytes of
|
||||
data for one 512-byte page or 2 256-byte pages. There is no check
|
||||
for bad blocks or ECC errors.
|
||||
|
||||
nand write addr ofs size
|
||||
Write `size' bytes from `addr' to `ofs' in NAND flash. If a page
|
||||
cannot be written because it is marked bad or the write fails the
|
||||
command stops with an error.
|
||||
|
||||
nand write.jffs2 addr ofs size
|
||||
Like `write', but blocks that are marked bad are skipped and the
|
||||
is written to the next block instead. This allows writing writing
|
||||
a JFFS2 image, as long as the image is short enough to fit even
|
||||
after skipping the bad blocks. Compact images, such as those
|
||||
produced by mkfs.jffs2 should work well, but loading an image copied
|
||||
from another flash is going to be trouble if there are any bad blocks.
|
||||
|
||||
nand write.oob addr ofs size
|
||||
Write `size' bytes from `addr' to the out-of-band data area
|
||||
corresponding to `ofs' in NAND flash. This is limited to the 16 bytes
|
||||
of data for one 512-byte page or 2 256-byte pages. There is no check
|
||||
for bad blocks.
|
||||
|
||||
Configuration Options:
|
||||
|
||||
CFG_CMD_NAND
|
||||
A good one to add to CONFIG_COMMANDS since it enables NAND support.
|
||||
|
||||
CONFIG_MTD_NAND_ECC_JFFS2
|
||||
Define this if you want the Error Correction Code information in
|
||||
the out-of-band data to be formatted to match the JFFS2 file system.
|
||||
CONFIG_MTD_NAND_ECC_YAFFS would be another useful choice for
|
||||
someone to implement.
|
||||
|
||||
CFG_MAX_NAND_DEVICE
|
||||
The maximum number of NAND devices you want to support.
|
||||
|
||||
NAND Interface:
|
||||
|
||||
#define NAND_WAIT_READY(nand)
|
||||
Wait until the NAND flash is ready. Typically this would be a
|
||||
loop waiting for the READY/BUSY line from the flash to indicate it
|
||||
it is ready.
|
||||
|
||||
#define WRITE_NAND_COMMAND(d, adr)
|
||||
Write the command byte `d' to the flash at `adr' with the
|
||||
CLE (command latch enable) line true. If your board uses writes to
|
||||
different addresses to control CLE and ALE, you can modify `adr'
|
||||
to be the appropriate address here. If your board uses I/O registers
|
||||
to control them, it is probably better to let NAND_CTL_SETCLE()
|
||||
and company do it.
|
||||
|
||||
#define WRITE_NAND_ADDRESS(d, adr)
|
||||
Write the address byte `d' to the flash at `adr' with the
|
||||
ALE (address latch enable) line true. If your board uses writes to
|
||||
different addresses to control CLE and ALE, you can modify `adr'
|
||||
to be the appropriate address here. If your board uses I/O registers
|
||||
to control them, it is probably better to let NAND_CTL_SETALE()
|
||||
and company do it.
|
||||
|
||||
#define WRITE_NAND(d, adr)
|
||||
Write the data byte `d' to the flash at `adr' with the
|
||||
ALE and CLE lines false. If your board uses writes to
|
||||
different addresses to control CLE and ALE, you can modify `adr'
|
||||
to be the appropriate address here. If your board uses I/O registers
|
||||
to control them, it is probably better to let NAND_CTL_CLRALE()
|
||||
and company do it.
|
||||
|
||||
#define READ_NAND(adr)
|
||||
Read a data byte from the flash at `adr' with the
|
||||
ALE and CLE lines false. If your board uses reads from
|
||||
different addresses to control CLE and ALE, you can modify `adr'
|
||||
to be the appropriate address here. If your board uses I/O registers
|
||||
to control them, it is probably better to let NAND_CTL_CLRALE()
|
||||
and company do it.
|
||||
|
||||
#define NAND_DISABLE_CE(nand)
|
||||
Set CE (Chip Enable) low to enable the NAND flash.
|
||||
|
||||
#define NAND_ENABLE_CE(nand)
|
||||
Set CE (Chip Enable) high to disable the NAND flash.
|
||||
|
||||
#define NAND_CTL_CLRALE(nandptr)
|
||||
Set ALE (address latch enable) low. If ALE control is handled by
|
||||
WRITE_NAND_ADDRESS() this can be empty.
|
||||
|
||||
#define NAND_CTL_SETALE(nandptr)
|
||||
Set ALE (address latch enable) high. If ALE control is handled by
|
||||
WRITE_NAND_ADDRESS() this can be empty.
|
||||
|
||||
#define NAND_CTL_CLRCLE(nandptr)
|
||||
Set CLE (command latch enable) low. If CLE control is handled by
|
||||
WRITE_NAND_ADDRESS() this can be empty.
|
||||
|
||||
#define NAND_CTL_SETCLE(nandptr)
|
||||
Set CLE (command latch enable) high. If CLE control is handled by
|
||||
WRITE_NAND_ADDRESS() this can be empty.
|
||||
|
||||
More Definitions:
|
||||
|
||||
These definitions are needed in the board configuration for now, but
|
||||
may really belong in a header file.
|
||||
TODO: Figure which ones are truly configuration settings and rename
|
||||
them to CFG_NAND_... and move the rest somewhere appropriate.
|
||||
|
||||
#define SECTORSIZE 512
|
||||
#define ADDR_COLUMN 1
|
||||
#define ADDR_PAGE 2
|
||||
#define ADDR_COLUMN_PAGE 3
|
||||
#define NAND_ChipID_UNKNOWN 0x00
|
||||
#define NAND_MAX_FLOORS 1
|
||||
#define NAND_MAX_CHIPS 1
|
||||
|
||||
+1
-11
@@ -4,8 +4,6 @@ i386 port missing features:
|
||||
* setup the BIOS data area and BIOS equipment word to reflect machine config.
|
||||
* Make reset work (from Linux and from the boot prompt)
|
||||
* DMA, FDC, RTC, KBC initialization
|
||||
* video card support (call BIOS to initialize, use helper routrine in BSP to shadow
|
||||
video rom if on pci) and PC keyboard
|
||||
* split of part of cpu/i386/interrupt.c to cpu/i385/entry.c?
|
||||
* re-entry of protected mode from real mode, should be added to realmode_switch.S
|
||||
(and used by INT 10h and INT 16h handlers for console I/O during early
|
||||
@@ -13,8 +11,6 @@ i386 port missing features:
|
||||
* missing functions in lib_i386 and cpu/i386
|
||||
* speaker beep interface
|
||||
|
||||
i386 port bugs:
|
||||
* IDE does not work
|
||||
|
||||
SC520 missing features:
|
||||
* Watchdog
|
||||
@@ -24,16 +20,10 @@ SC520 missing features:
|
||||
* SC520 MMCR reset
|
||||
|
||||
SC520 CDP board support missing features:
|
||||
* Synchronius serial port and seriel EEPROM
|
||||
* environment in SEEP
|
||||
* environment in flash
|
||||
* environment in sram
|
||||
* status LED ?
|
||||
* flash driver
|
||||
|
||||
SC520 CDP board support bugs:
|
||||
* SPI EEPROM support does not work
|
||||
* 0x680 LEDS dos not work for me
|
||||
* is it possible to make both the internal serial ports and the
|
||||
ports on the sio work at the same time?
|
||||
* ali sio cio lines?
|
||||
* On-borad ethernet does not work from Linux
|
||||
+15
-7
@@ -27,16 +27,24 @@ include $(TOPDIR)/config.mk
|
||||
|
||||
LIB = libdrivers.a
|
||||
|
||||
OBJS = 3c589.o 5701rls.o at91rm9200_ether.o \
|
||||
bcm570x.o bcm570x_autoneg.o \
|
||||
cfb_console.o cs8900.o ct69000.o dc2114x.o \
|
||||
eepro100.o i8042.o i82365.o inca-ip_sw.o \
|
||||
lan91c96.o natsemi.o ns16550.o ns8382x.o ns87308.o \
|
||||
OBJS = 3c589.o 5701rls.o ali512x.o at91rm9200_ether.o \
|
||||
bcm570x.o bcm570x_autoneg.o cfb_console.o \
|
||||
cs8900.o ct69000.o dc2114x.o \
|
||||
e1000.o eepro100.o \
|
||||
i8042.o i82365.o inca-ip_sw.o \
|
||||
lan91c96.o natsemi.o \
|
||||
ns16550.o ns8382x.o ns87308.o \
|
||||
pci.o pci_auto.o pci_indirect.o \
|
||||
pcnet.o plb2800_eth.o \
|
||||
s3c24x0_i2c.o sed13806.o serial.o \
|
||||
smc91111.o smiLynxEM.o sym53c8xx.o \
|
||||
tigon3.o w83c553f.o
|
||||
smc91111.o smiLynxEM.o sym53c8xx.o \
|
||||
ti_pci1410a.o tigon3.o w83c553f.o
|
||||
|
||||
## Disabled for now:
|
||||
## cs8900.o ct69000.o dc2114x.o ds1722.o \
|
||||
## lan91c96.o mw_eeprom.o natsemi.o \
|
||||
## smc91111.o smiLynxEM.o spi_eeprom.o sym53c8xx.o \
|
||||
##
|
||||
|
||||
all: $(LIB)
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef CONFIG_ALI152X
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/ic/ali512x.h>
|
||||
@@ -60,19 +64,21 @@ static void ali_write(u8 index, u8 value)
|
||||
outb(value, ALI_DATA);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int ali_read(u8 index)
|
||||
{
|
||||
outb(index, ALI_INDEX);
|
||||
return inb(ALI_DATA);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ALI_OPEN() \
|
||||
outb(0x51, ALI_DATA); \
|
||||
outb(0x23, ALI_DATA)
|
||||
outb(0x51, ALI_INDEX); \
|
||||
outb(0x23, ALI_INDEX)
|
||||
|
||||
|
||||
#define ALI_CLOSE() \
|
||||
outb(0xbb, ALI_DATA)
|
||||
outb(0xbb, ALI_INDEX)
|
||||
|
||||
/* Select a logical device */
|
||||
#define ALI_SELDEV(dev) \
|
||||
@@ -246,22 +252,22 @@ void ali512x_set_kbc(int enabled, u8 kbc_irq, u8 mouse_irq)
|
||||
* CIO36 ALT_MDAT Alternative Mouse Data
|
||||
* CIO37 ALT_KBC Alternative KBC select
|
||||
*
|
||||
* The CIO use a double indirect address scheme.
|
||||
* The CIO use an indirect address scheme.
|
||||
*
|
||||
* Reigster 3 in the SIO is used to selectg where the CIO
|
||||
* I/O registers show up under function 8. Note that these
|
||||
* registers clash with the CIO function select regsters,
|
||||
* below.
|
||||
* Reigster 3 in the SIO is used to select the index and data
|
||||
* port addresses where the CIO I/O registers show up.
|
||||
* The function selection registers are accessible under
|
||||
* function SIO 8.
|
||||
*
|
||||
* SIO reigster 3 (CIO Address Selection) bit definitions:
|
||||
* bit 7 CIO data register enabled
|
||||
* bit 1-0 CIO indirect registers select
|
||||
* bit 7 CIO index and data registers enabled
|
||||
* bit 1-0 CIO indirect registers port address select
|
||||
* 0 index = 0xE0 data = 0xE1
|
||||
* 1 index = 0xE2 data = 0xE3
|
||||
* 2 index = 0xE4 data = 0xE5
|
||||
* 3 index = 0xEA data = 0xEB
|
||||
*
|
||||
* There are three CIO I/O register accessed via CIO index and CIO data
|
||||
* There are three CIO I/O register accessed via CIO index port and CIO data port
|
||||
* 0x01 CIO 10-17 data
|
||||
* 0x02 CIO 20-25 data (bits 7-6 unused)
|
||||
* 0x03 CIO 30-37 data
|
||||
@@ -305,50 +311,61 @@ void ali512x_set_kbc(int enabled, u8 kbc_irq, u8 mouse_irq)
|
||||
*
|
||||
*/
|
||||
|
||||
#define ALI_CIO_PORT_SEL 0x83
|
||||
#define ALI_CIO_INDEX 0xea
|
||||
#define ALI_CIO_DATA 0xeb
|
||||
|
||||
void ali512x_set_cio(int enabled)
|
||||
{
|
||||
int i;
|
||||
|
||||
ALI_OPEN();
|
||||
ali_write(0x3, 3); /* Disable CIO data register */
|
||||
|
||||
if (enabled) {
|
||||
ali_write(0x3, ALI_CIO_PORT_SEL); /* Enable CIO data register */
|
||||
} else {
|
||||
ali_write(0x3, ALI_CIO_PORT_SEL & ~0x80);
|
||||
}
|
||||
|
||||
ALI_SELDEV(8);
|
||||
|
||||
ali_write(0x30, enabled?1:0);
|
||||
|
||||
/* set all pins to input to start with */
|
||||
for (i=0xe0;i<0xee;i++) {
|
||||
ali_write(i, 1);
|
||||
}
|
||||
|
||||
for (i=0xf5;i<0xfe;i++) {
|
||||
ali_write(i, 1);
|
||||
}
|
||||
|
||||
|
||||
ALI_CLOSE();
|
||||
}
|
||||
|
||||
|
||||
void ali512x_cio_function(int pin, int special, int inv, int input)
|
||||
{
|
||||
u8 data;
|
||||
u8 addr;
|
||||
|
||||
|
||||
/* valid pins are 10-17, 20-25 and 30-37 */
|
||||
if (pin >= 10 && pin <= 17) {
|
||||
addr = 0xe0+(pin-10);
|
||||
addr = 0xe0+(pin&7);
|
||||
} else if (pin >= 20 && pin <= 25) {
|
||||
addr = 0xe8+(pin-20);
|
||||
addr = 0xe8+(pin&7);
|
||||
} else if (pin >= 30 && pin <= 37) {
|
||||
addr = 0xf5+(pin-30);
|
||||
addr = 0xf5+(pin&7);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
ALI_OPEN();
|
||||
|
||||
ALI_SELDEV(8);
|
||||
|
||||
ali_write(0x03, 0x03); /* Disable CIO data register */
|
||||
|
||||
data=0;
|
||||
data=0xf4;
|
||||
if (special) {
|
||||
data |= 0x08;
|
||||
} else {
|
||||
@@ -371,37 +388,18 @@ void ali512x_cio_out(int pin, int value)
|
||||
u8 data;
|
||||
u8 bit;
|
||||
|
||||
/* valid pins are 10-17, 20-25 and 30-37 */
|
||||
if (pin >= 10 && pin <= 17) {
|
||||
reg = 1;
|
||||
pin -= 10;
|
||||
} else if (pin >= 20 && pin <= 25) {
|
||||
reg = 2;
|
||||
pin -= 20;
|
||||
} else if (pin >= 30 && pin <= 37) {
|
||||
reg = 3;
|
||||
pin -= 30;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
bit = 1 << pin;
|
||||
reg = pin/10;
|
||||
bit = 1 << (pin%10);
|
||||
|
||||
ALI_OPEN();
|
||||
ALI_SELDEV(8);
|
||||
|
||||
ali_write(0x03, 0x83); /* Enable CIO data register, use data port at 0xea */
|
||||
|
||||
ali_write(0xea, reg); /* select I/O register */
|
||||
data = ali_read(0xeb);
|
||||
|
||||
outb(reg, ALI_CIO_INDEX); /* select I/O register */
|
||||
data = inb(ALI_CIO_DATA);
|
||||
if (value) {
|
||||
data |= bit;
|
||||
} else {
|
||||
data &= ~bit;
|
||||
}
|
||||
ali_write(0xeb, data);
|
||||
ali_write(0xea, 0); /* select register 0 */
|
||||
ali_write(0x03, 0x03); /* Disable CIO data register */
|
||||
ALI_CLOSE();
|
||||
outb(data, ALI_CIO_DATA);
|
||||
}
|
||||
|
||||
int ali512x_cio_in(int pin)
|
||||
@@ -409,34 +407,17 @@ int ali512x_cio_in(int pin)
|
||||
u8 reg;
|
||||
u8 data;
|
||||
u8 bit;
|
||||
|
||||
|
||||
/* valid pins are 10-17, 20-25 and 30-37 */
|
||||
if (pin >= 10 && pin <= 17) {
|
||||
reg = 1;
|
||||
pin -= 10;
|
||||
} else if (pin >= 20 && pin <= 25) {
|
||||
reg = 2;
|
||||
pin -= 20;
|
||||
} else if (pin >= 30 && pin <= 37) {
|
||||
reg = 3;
|
||||
pin -= 30;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
bit = 1 << pin;
|
||||
reg = pin/10;
|
||||
bit = 1 << (pin%10);
|
||||
|
||||
ALI_OPEN();
|
||||
ALI_SELDEV(8);
|
||||
|
||||
ali_write(0x03, 0x83); /* Enable CIO data register, use data port at 0xea */
|
||||
|
||||
ali_write(0xea, reg); /* select I/O register */
|
||||
data = ali_read(0xeb);
|
||||
ali_write(0xea, 0); /* select register 0 */
|
||||
ali_write(0x03, 0x03); /* Disable CIO data register */
|
||||
ALI_CLOSE();
|
||||
outb(reg, ALI_CIO_INDEX); /* select I/O register */
|
||||
data = inb(ALI_CIO_DATA);
|
||||
|
||||
return data & bit;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,142 @@
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#include <ssi.h>
|
||||
|
||||
#ifdef CONFIG_DS1722
|
||||
|
||||
static void ds1722_select(int dev)
|
||||
{
|
||||
ssi_set_interface(4096, 0, 0, 0);
|
||||
ssi_chip_select(0);
|
||||
udelay(1);
|
||||
ssi_chip_select(dev);
|
||||
udelay(1);
|
||||
}
|
||||
|
||||
|
||||
u8 ds1722_read(int dev, int addr)
|
||||
{
|
||||
u8 res;
|
||||
|
||||
ds1722_select(dev);
|
||||
|
||||
ssi_tx_byte(addr);
|
||||
res = ssi_rx_byte();
|
||||
|
||||
ssi_chip_select(0);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void ds1722_write(int dev, int addr, u8 data)
|
||||
{
|
||||
ds1722_select(dev);
|
||||
|
||||
ssi_tx_byte(0x80|addr);
|
||||
ssi_tx_byte(data);
|
||||
|
||||
ssi_chip_select(0);
|
||||
}
|
||||
|
||||
|
||||
u16 ds1722_temp(int dev, int resolution)
|
||||
{
|
||||
static int useconds[] = {
|
||||
75000, 150000, 300000, 600000, 1200000
|
||||
};
|
||||
char temp;
|
||||
u16 res;
|
||||
|
||||
|
||||
/* set up the desired resulotion ... */
|
||||
ds1722_write(dev, 0, 0xe0 | (resolution << 1));
|
||||
|
||||
/* wait while the chip measures the tremperature */
|
||||
udelay(useconds[resolution]);
|
||||
|
||||
res = (temp = ds1722_read(dev, 2)) << 8;
|
||||
|
||||
if (temp < 0) {
|
||||
temp = (16 - (ds1722_read(dev, 1) >> 4)) & 0x0f;
|
||||
} else {
|
||||
temp = (ds1722_read(dev, 1) >> 4);
|
||||
}
|
||||
|
||||
switch (temp) {
|
||||
case 0:
|
||||
/* .0000 */
|
||||
break;
|
||||
case 1:
|
||||
/* .0625 */
|
||||
res |=1;
|
||||
break;
|
||||
case 2:
|
||||
/* .1250 */
|
||||
res |=1;
|
||||
break;
|
||||
case 3:
|
||||
/* .1875 */
|
||||
res |=2;
|
||||
break;
|
||||
case 4:
|
||||
/* .2500 */
|
||||
res |=3;
|
||||
break;
|
||||
case 5:
|
||||
/* .3125 */
|
||||
res |=3;
|
||||
break;
|
||||
case 6:
|
||||
/* .3750 */
|
||||
res |=4;
|
||||
break;
|
||||
case 7:
|
||||
/* .4375 */
|
||||
res |=4;
|
||||
break;
|
||||
case 8:
|
||||
/* .5000 */
|
||||
res |=5;
|
||||
break;
|
||||
case 9:
|
||||
/* .5625 */
|
||||
res |=6;
|
||||
break;
|
||||
case 10:
|
||||
/* .6250 */
|
||||
res |=6;
|
||||
break;
|
||||
case 11:
|
||||
/* .6875 */
|
||||
res |=7;
|
||||
break;
|
||||
case 12:
|
||||
/* .7500 */
|
||||
res |=8;
|
||||
break;
|
||||
case 13:
|
||||
/* .8125 */
|
||||
res |=8;
|
||||
break;
|
||||
case 14:
|
||||
/* .8750 */
|
||||
res |=9;
|
||||
break;
|
||||
case 15:
|
||||
/* .9375 */
|
||||
res |=9;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
int ds1722_probe(int dev)
|
||||
{
|
||||
u16 temp = ds1722_temp(dev, DS1722_RESOLUTION_12BIT);
|
||||
printf("%d.%d deg C\n\n", (char)(temp >> 8), temp & 0xff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
+2979
File diff suppressed because it is too large.
Load diff
+1758
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -331,8 +331,8 @@ int eepro100_initialize (bd_t * bis)
|
||||
dev = (struct eth_device *) malloc (sizeof *dev);
|
||||
|
||||
sprintf (dev->name, "i82559#%d", card_number);
|
||||
dev->priv = (void *) devno; /* this have to come before bus_to_phys() */
|
||||
dev->iobase = bus_to_phys (iobase);
|
||||
dev->priv = (void *) devno;
|
||||
dev->init = eepro100_init;
|
||||
dev->halt = eepro100_halt;
|
||||
dev->send = eepro100_send;
|
||||
|
||||
@@ -0,0 +1,242 @@
|
||||
/* Three-wire (MicroWire) serial eeprom driver (for 93C46 and compatibles) */
|
||||
|
||||
#include <common.h>
|
||||
#include <ssi.h>
|
||||
|
||||
|
||||
#ifdef CONFIG_MW_EEPROM
|
||||
|
||||
/*
|
||||
* Serial EEPROM opcodes, including start bit
|
||||
*/
|
||||
#define EEP_OPC_ERASE 0x7 /* 3-bit opcode */
|
||||
#define EEP_OPC_WRITE 0x5 /* 3-bit opcode */
|
||||
#define EEP_OPC_READ 0x6 /* 3-bit opcode */
|
||||
|
||||
#define EEP_OPC_ERASE_ALL 0x12 /* 5-bit opcode */
|
||||
#define EEP_OPC_ERASE_EN 0x13 /* 5-bit opcode */
|
||||
#define EEP_OPC_WRITE_ALL 0x11 /* 5-bit opcode */
|
||||
#define EEP_OPC_ERASE_DIS 0x10 /* 5-bit opcode */
|
||||
|
||||
static int addrlen;
|
||||
|
||||
static void mw_eeprom_select(int dev)
|
||||
{
|
||||
ssi_set_interface(2048, 0, 0, 0);
|
||||
ssi_chip_select(0);
|
||||
udelay(1);
|
||||
ssi_chip_select(dev);
|
||||
udelay(1);
|
||||
}
|
||||
|
||||
static int mw_eeprom_size(int dev)
|
||||
{
|
||||
int x;
|
||||
u16 res;
|
||||
|
||||
mw_eeprom_select(dev);
|
||||
ssi_tx_byte(EEP_OPC_READ);
|
||||
|
||||
res = ssi_txrx_byte(0) << 8;
|
||||
res |= ssi_rx_byte();
|
||||
for (x = 0; x < 16; x++) {
|
||||
if (! (res & 0x8000)) {
|
||||
break;
|
||||
}
|
||||
res <<= 1;
|
||||
}
|
||||
ssi_chip_select(0);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int mw_eeprom_erase_enable(int dev)
|
||||
{
|
||||
mw_eeprom_select(dev);
|
||||
ssi_tx_byte(EEP_OPC_ERASE_EN);
|
||||
ssi_tx_byte(0);
|
||||
udelay(1);
|
||||
ssi_chip_select(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mw_eeprom_erase_disable(int dev)
|
||||
{
|
||||
mw_eeprom_select(dev);
|
||||
ssi_tx_byte(EEP_OPC_ERASE_DIS);
|
||||
ssi_tx_byte(0);
|
||||
udelay(1);
|
||||
ssi_chip_select(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
u32 mw_eeprom_read_word(int dev, int addr)
|
||||
{
|
||||
u16 rcv;
|
||||
u16 res;
|
||||
int bits;
|
||||
|
||||
mw_eeprom_select(dev);
|
||||
ssi_tx_byte((EEP_OPC_READ << 5) | ((addr >> (addrlen - 5)) & 0x1f));
|
||||
rcv = ssi_txrx_byte(addr << (13 - addrlen));
|
||||
res = rcv << (16 - addrlen);
|
||||
bits = 4 + addrlen;
|
||||
|
||||
while (bits>0) {
|
||||
rcv = ssi_rx_byte();
|
||||
if (bits > 7) {
|
||||
res |= rcv << (bits - 8);
|
||||
} else {
|
||||
res |= rcv >> (8 - bits);
|
||||
}
|
||||
bits -= 8;
|
||||
}
|
||||
|
||||
ssi_chip_select(0);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int mw_eeprom_write_word(int dev, int addr, u16 data)
|
||||
{
|
||||
u8 byte1=0;
|
||||
u8 byte2=0;
|
||||
|
||||
mw_eeprom_erase_enable(dev);
|
||||
mw_eeprom_select(dev);
|
||||
|
||||
switch (addrlen) {
|
||||
case 6:
|
||||
byte1 = EEP_OPC_WRITE >> 2;
|
||||
byte2 = (EEP_OPC_WRITE << 6)&0xc0;
|
||||
byte2 |= addr;
|
||||
break;
|
||||
case 7:
|
||||
byte1 = EEP_OPC_WRITE >> 1;
|
||||
byte2 = (EEP_OPC_WRITE << 7)&0x80;
|
||||
byte2 |= addr;
|
||||
break;
|
||||
case 8:
|
||||
byte1 = EEP_OPC_WRITE;
|
||||
byte2 = addr;
|
||||
break;
|
||||
case 9:
|
||||
byte1 = EEP_OPC_WRITE << 1;
|
||||
byte1 |= addr >> 8;
|
||||
byte2 = addr & 0xff;
|
||||
break;
|
||||
case 10:
|
||||
byte1 = EEP_OPC_WRITE << 2;
|
||||
byte1 |= addr >> 8;
|
||||
byte2 = addr & 0xff;
|
||||
break;
|
||||
default:
|
||||
printf("Unsupported number of address bits: %d\n", addrlen);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
ssi_tx_byte(byte1);
|
||||
ssi_tx_byte(byte2);
|
||||
ssi_tx_byte(data >> 8);
|
||||
ssi_tx_byte(data & 0xff);
|
||||
ssi_chip_select(0);
|
||||
udelay(10000); /* Worst case */
|
||||
mw_eeprom_erase_disable(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int mw_eeprom_write(int dev, int addr, u8 *buffer, int len)
|
||||
{
|
||||
int done;
|
||||
|
||||
done = 0;
|
||||
if (addr & 1) {
|
||||
u16 temp = mw_eeprom_read_word(dev, addr >> 1);
|
||||
temp &= 0xff00;
|
||||
temp |= buffer[0];
|
||||
|
||||
mw_eeprom_write_word(dev, addr >> 1, temp);
|
||||
len--;
|
||||
addr++;
|
||||
buffer++;
|
||||
done++;
|
||||
}
|
||||
|
||||
while (len <= 2) {
|
||||
mw_eeprom_write_word(dev, addr >> 1, *(u16*)buffer);
|
||||
len-=2;
|
||||
addr+=2;
|
||||
buffer+=2;
|
||||
done+=2;
|
||||
}
|
||||
|
||||
if (len) {
|
||||
u16 temp = mw_eeprom_read_word(dev, addr >> 1);
|
||||
temp &= 0x00ff;
|
||||
temp |= buffer[0] << 8;
|
||||
|
||||
mw_eeprom_write_word(dev, addr >> 1, temp);
|
||||
len--;
|
||||
addr++;
|
||||
buffer++;
|
||||
done++;
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int mw_eeprom_read(int dev, int addr, u8 *buffer, int len)
|
||||
{
|
||||
int done;
|
||||
|
||||
done = 0;
|
||||
if (addr & 1) {
|
||||
u16 temp = mw_eeprom_read_word(dev, addr >> 1);
|
||||
buffer[0]= temp & 0xff;
|
||||
|
||||
len--;
|
||||
addr++;
|
||||
buffer++;
|
||||
done++;
|
||||
}
|
||||
|
||||
while (len <= 2) {
|
||||
*(u16*)buffer = mw_eeprom_read_word(dev, addr >> 1);
|
||||
len-=2;
|
||||
addr+=2;
|
||||
buffer+=2;
|
||||
done+=2;
|
||||
}
|
||||
|
||||
if (len) {
|
||||
u16 temp = mw_eeprom_read_word(dev, addr >> 1);
|
||||
buffer[0] = temp >> 8;
|
||||
|
||||
len--;
|
||||
addr++;
|
||||
buffer++;
|
||||
done++;
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
int mw_eeprom_probe(int dev)
|
||||
{
|
||||
addrlen = mw_eeprom_size(dev);
|
||||
|
||||
if (addrlen < 6 || addrlen > 10) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,668 @@
|
||||
/*
|
||||
* (C) Copyright 2000-2002
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
* (C) Copyright 2002
|
||||
* Daniel Engström, Omicron Ceti AB
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
********************************************************************
|
||||
*
|
||||
* Lots of code copied from:
|
||||
*
|
||||
* m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
|
||||
* (C) 1999-2000 Magnus Damm <damm@bitsmart.com>
|
||||
*
|
||||
* "The ExCA standard specifies that socket controllers should provide
|
||||
* two IO and five memory windows per socket, which can be independently
|
||||
* configured and positioned in the host address space and mapped to
|
||||
* arbitrary segments of card address space. " - David A Hinds. 1999
|
||||
*
|
||||
* This controller does _not_ meet the ExCA standard.
|
||||
*
|
||||
* m8xx pcmcia controller brief info:
|
||||
* + 8 windows (attrib, mem, i/o)
|
||||
* + up to two slots (SLOT_A and SLOT_B)
|
||||
* + inputpins, outputpins, event and mask registers.
|
||||
* - no offset register. sigh.
|
||||
*
|
||||
* Because of the lacking offset register we must map the whole card.
|
||||
* We assign each memory window PCMCIA_MEM_WIN_SIZE address space.
|
||||
* Make sure there is (PCMCIA_MEM_WIN_SIZE * PCMCIA_MEM_WIN_NO
|
||||
* * PCMCIA_SOCKETS_NO) bytes at PCMCIA_MEM_WIN_BASE.
|
||||
* The i/o windows are dynamically allocated at PCMCIA_IO_WIN_BASE.
|
||||
* They are maximum 64KByte each...
|
||||
*/
|
||||
|
||||
|
||||
#undef DEBUG /**/
|
||||
|
||||
/*
|
||||
* PCMCIA support
|
||||
*/
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <config.h>
|
||||
#include <pci.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#include <pcmcia.h>
|
||||
#include <cmd_pcmcia.h>
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && defined(CONFIG_IDE_TI_CARDBUS)
|
||||
|
||||
int pcmcia_on(int ide_base_bus);
|
||||
|
||||
static int pcmcia_off(void);
|
||||
static int hardware_disable(int slot);
|
||||
static int hardware_enable(int slot);
|
||||
static int voltage_set(int slot, int vcc, int vpp);
|
||||
static void print_funcid(int func);
|
||||
static void print_fixed(volatile uchar *p);
|
||||
static int identify(volatile uchar *p);
|
||||
static int check_ide_device(int slot, int ide_base_bus);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
const char *indent = "\t ";
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
int do_pinit(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
#ifndef CFG_FISRT_PCMCIA_BUS
|
||||
# define CFG_FISRT_PCMCIA_BUS 0
|
||||
#endif
|
||||
|
||||
int rcode = 0;
|
||||
|
||||
if (argc != 2) {
|
||||
printf ("Usage: pinit {on | off}\n");
|
||||
return 1;
|
||||
}
|
||||
if (strcmp(argv[1],"on") == 0) {
|
||||
rcode = pcmcia_on(CFG_FISRT_PCMCIA_BUS);
|
||||
} else if (strcmp(argv[1],"off") == 0) {
|
||||
rcode = pcmcia_off();
|
||||
} else {
|
||||
printf ("Usage: pinit {on | off}\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return rcode;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static struct pci_device_id supported[] = {
|
||||
{ PCI_VENDOR_ID_TI, 0xac50 }, /* Ti PCI1410A */
|
||||
{ PCI_VENDOR_ID_TI, 0xac56 }, /* Ti PCI1510 */
|
||||
{ }
|
||||
};
|
||||
|
||||
static pci_dev_t devbusfn;
|
||||
static u32 socket_base;
|
||||
static u32 pcmcia_cis_ptr;
|
||||
|
||||
int pcmcia_on(int ide_base_bus)
|
||||
{
|
||||
u16 dev_id;
|
||||
u32 socket_status;
|
||||
int slot = 0;
|
||||
int cis_len;
|
||||
u16 io_base;
|
||||
u16 io_len;
|
||||
|
||||
/*
|
||||
* Find the CardBus PCI device(s).
|
||||
*/
|
||||
if ((devbusfn = pci_find_devices(supported, 0)) < 0) {
|
||||
printf("Ti CardBus: not found\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
pci_read_config_word(devbusfn, PCI_DEVICE_ID, &dev_id);
|
||||
|
||||
if (dev_id == 0xac56) {
|
||||
debug("Enable PCMCIA Ti PCI1510\n");
|
||||
} else {
|
||||
debug("Enable PCMCIA Ti PCI1410A\n");
|
||||
}
|
||||
|
||||
pcmcia_cis_ptr = CFG_PCMCIA_CIS_WIN;
|
||||
cis_len = CFG_PCMCIA_CIS_WIN_SIZE;
|
||||
|
||||
io_base = CFG_PCMCIA_IO_WIN;
|
||||
io_len = CFG_PCMCIA_IO_WIN_SIZE;
|
||||
|
||||
/*
|
||||
* Setup the PCI device.
|
||||
*/
|
||||
pci_read_config_dword(devbusfn, PCI_BASE_ADDRESS_0, &socket_base);
|
||||
socket_base &= ~0xf;
|
||||
|
||||
socket_status = readl(socket_base+8);
|
||||
if ((socket_status & 6) == 0) {
|
||||
printf("Card Present: ");
|
||||
|
||||
switch (socket_status & 0x3c00) {
|
||||
|
||||
case 0x400:
|
||||
printf("5V ");
|
||||
break;
|
||||
case 0x800:
|
||||
printf("3.3V ");
|
||||
break;
|
||||
case 0xc00:
|
||||
printf("3.3/5V ");
|
||||
break;
|
||||
default:
|
||||
printf("unsupported Vcc ");
|
||||
break;
|
||||
}
|
||||
switch (socket_status & 0x30) {
|
||||
case 0x10:
|
||||
printf("16bit PC-Card\n");
|
||||
break;
|
||||
case 0x20:
|
||||
printf("32bit CardBus Card\n");
|
||||
break;
|
||||
default:
|
||||
printf("8bit PC-Card\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
writeb(0x41, socket_base + 0x806); /* Enable I/O window 0 and memory window 0 */
|
||||
writeb(0x0e, socket_base + 0x807); /* Reset I/O window options */
|
||||
|
||||
/* Careful: the linux yenta driver do not seem to reset the offset
|
||||
* in the i/o windows, so leaving them non-zero is a problem */
|
||||
|
||||
writeb(io_base & 0xff, socket_base + 0x808); /* I/O window 0 base address */
|
||||
writeb(io_base>>8, socket_base + 0x809);
|
||||
writeb((io_base + io_len - 1) & 0xff, socket_base + 0x80a); /* I/O window 0 end address */
|
||||
writeb((io_base + io_len - 1)>>8, socket_base + 0x80b);
|
||||
writeb(0x00, socket_base + 0x836); /* I/O window 0 offset address 0x000 */
|
||||
writeb(0x00, socket_base + 0x837);
|
||||
|
||||
|
||||
writeb((pcmcia_cis_ptr&0x000ff000) >> 12,
|
||||
socket_base + 0x810); /* Memory window 0 start address bits 19-12 */
|
||||
writeb((pcmcia_cis_ptr&0x00f00000) >> 20,
|
||||
socket_base + 0x811); /* Memory window 0 start address bits 23-20 */
|
||||
writeb(((pcmcia_cis_ptr+cis_len-1) & 0x000ff000) >> 12,
|
||||
socket_base + 0x812); /* Memory window 0 end address bits 19-12*/
|
||||
writeb(((pcmcia_cis_ptr+cis_len-1) & 0x00f00000) >> 20,
|
||||
socket_base + 0x813); /* Memory window 0 end address bits 23-20*/
|
||||
writeb(0x00, socket_base + 0x814); /* Memory window 0 offset bits 19-12 */
|
||||
writeb(0x40, socket_base + 0x815); /* Memory window 0 offset bits 23-20 and
|
||||
* options (read/write, attribute access) */
|
||||
writeb(0x00, socket_base + 0x816); /* ExCA card-detect and general control */
|
||||
writeb(0x00, socket_base + 0x81e); /* ExCA global control (interrupt modes) */
|
||||
|
||||
writeb((pcmcia_cis_ptr & 0xff000000) >> 24,
|
||||
socket_base + 0x840); /* Memory window address bits 31-24 */
|
||||
|
||||
|
||||
/* turn off voltage */
|
||||
if (voltage_set(slot, 0, 0)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable external hardware */
|
||||
if (hardware_enable(slot)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (check_ide_device(slot, ide_base_bus)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
static int pcmcia_off (void)
|
||||
{
|
||||
int slot = 0;
|
||||
|
||||
writeb(0x00, socket_base + 0x806); /* disable all I/O and memory windows */
|
||||
|
||||
writeb(0x00, socket_base + 0x808); /* I/O window 0 base address */
|
||||
writeb(0x00, socket_base + 0x809);
|
||||
writeb(0x00, socket_base + 0x80a); /* I/O window 0 end address */
|
||||
writeb(0x00, socket_base + 0x80b);
|
||||
writeb(0x00, socket_base + 0x836); /* I/O window 0 offset address */
|
||||
writeb(0x00, socket_base + 0x837);
|
||||
|
||||
writeb(0x00, socket_base + 0x80c); /* I/O window 1 base address */
|
||||
writeb(0x00, socket_base + 0x80d);
|
||||
writeb(0x00, socket_base + 0x80e); /* I/O window 1 end address */
|
||||
writeb(0x00, socket_base + 0x80f);
|
||||
writeb(0x00, socket_base + 0x838); /* I/O window 1 offset address */
|
||||
writeb(0x00, socket_base + 0x839);
|
||||
|
||||
writeb(0x00, socket_base + 0x810); /* Memory window 0 start address */
|
||||
writeb(0x00, socket_base + 0x811);
|
||||
writeb(0x00, socket_base + 0x812); /* Memory window 0 end address */
|
||||
writeb(0x00, socket_base + 0x813);
|
||||
writeb(0x00, socket_base + 0x814); /* Memory window 0 offset */
|
||||
writeb(0x00, socket_base + 0x815);
|
||||
|
||||
writeb(0xc0, socket_base + 0x840); /* Memory window 0 page address */
|
||||
|
||||
|
||||
/* turn off voltage */
|
||||
voltage_set(slot, 0, 0);
|
||||
|
||||
/* disable external hardware */
|
||||
printf ("Shutdown and Poweroff Ti PCI1410A\n");
|
||||
hardware_disable(slot);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
#define MAX_TUPEL_SZ 512
|
||||
#define MAX_FEATURES 4
|
||||
int ide_devices_found;
|
||||
static int check_ide_device(int slot, int ide_base_bus)
|
||||
{
|
||||
volatile uchar *ident = NULL;
|
||||
volatile uchar *feature_p[MAX_FEATURES];
|
||||
volatile uchar *p, *start;
|
||||
int n_features = 0;
|
||||
uchar func_id = ~0;
|
||||
uchar code, len;
|
||||
ushort config_base = 0;
|
||||
int found = 0;
|
||||
int i;
|
||||
u32 socket_status;
|
||||
|
||||
debug ("PCMCIA MEM: %08X\n", pcmcia_cis_ptr);
|
||||
|
||||
socket_status = readl(socket_base+8);
|
||||
|
||||
if ((socket_status & 6) != 0 || (socket_status & 0x20) != 0) {
|
||||
printf("no card or CardBus card\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
start = p = (volatile uchar *) pcmcia_cis_ptr;
|
||||
|
||||
while ((p - start) < MAX_TUPEL_SZ) {
|
||||
|
||||
code = *p; p += 2;
|
||||
|
||||
if (code == 0xFF) { /* End of chain */
|
||||
break;
|
||||
}
|
||||
|
||||
len = *p; p += 2;
|
||||
#if defined(DEBUG) && (DEBUG > 1)
|
||||
{
|
||||
volatile uchar *q = p;
|
||||
printf ("\nTuple code %02x length %d\n\tData:",
|
||||
code, len);
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
printf (" %02x", *q);
|
||||
q+= 2;
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
switch (code) {
|
||||
case CISTPL_VERS_1:
|
||||
ident = p + 4;
|
||||
break;
|
||||
case CISTPL_FUNCID:
|
||||
/* Fix for broken SanDisk which may have 0x80 bit set */
|
||||
func_id = *p & 0x7F;
|
||||
break;
|
||||
case CISTPL_FUNCE:
|
||||
if (n_features < MAX_FEATURES)
|
||||
feature_p[n_features++] = p;
|
||||
break;
|
||||
case CISTPL_CONFIG:
|
||||
config_base = (*(p+6) << 8) + (*(p+4));
|
||||
debug ("\n## Config_base = %04x ###\n", config_base);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
p += 2 * len;
|
||||
}
|
||||
|
||||
found = identify(ident);
|
||||
|
||||
if (func_id != ((uchar)~0)) {
|
||||
print_funcid (func_id);
|
||||
|
||||
if (func_id == CISTPL_FUNCID_FIXED)
|
||||
found = 1;
|
||||
else
|
||||
return 1; /* no disk drive */
|
||||
}
|
||||
|
||||
for (i=0; i<n_features; ++i) {
|
||||
print_fixed(feature_p[i]);
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
printf("unknown card type\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* select config index 1 */
|
||||
writeb(1, pcmcia_cis_ptr + config_base);
|
||||
|
||||
#if 0
|
||||
printf("Confiuration Option Register: %02x\n", readb(pcmcia_cis_ptr + config_base));
|
||||
printf("Card Confiuration and Status Register: %02x\n", readb(pcmcia_cis_ptr + config_base + 2));
|
||||
printf("Pin Replacement Register Register: %02x\n", readb(pcmcia_cis_ptr + config_base + 4));
|
||||
printf("Socket and Copy Register: %02x\n", readb(pcmcia_cis_ptr + config_base + 6));
|
||||
#endif
|
||||
ide_devices_found |= (1 << (slot+ide_base_bus));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int voltage_set(int slot, int vcc, int vpp)
|
||||
{
|
||||
u32 socket_control;
|
||||
int reg=0;
|
||||
|
||||
switch (slot) {
|
||||
case 0:
|
||||
reg = socket_base + 0x10;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
socket_control = 0;
|
||||
|
||||
|
||||
switch (vcc) {
|
||||
case 50:
|
||||
socket_control |= 0x20;
|
||||
break;
|
||||
case 33:
|
||||
socket_control |= 0x30;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
}
|
||||
|
||||
switch (vpp) {
|
||||
case 120:
|
||||
socket_control |= 0x1;
|
||||
break;
|
||||
case 50:
|
||||
socket_control |= 0x2;
|
||||
break;
|
||||
case 33:
|
||||
socket_control |= 0x3;
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
}
|
||||
|
||||
writel(socket_control, reg);
|
||||
|
||||
debug ("voltage_set: Ti PCI1410A Slot %d, Vcc=%d.%d, Vpp=%d.%d\n",
|
||||
slot, vcc/10, vcc%10, vpp/10, vpp%10);
|
||||
|
||||
udelay(500);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int hardware_enable(int slot)
|
||||
{
|
||||
u32 socket_status;
|
||||
u16 brg_ctrl;
|
||||
int is_82365sl;
|
||||
|
||||
socket_status = readl(socket_base+8);
|
||||
|
||||
if ((socket_status & 6) == 0) {
|
||||
|
||||
switch (socket_status & 0x3c00) {
|
||||
|
||||
case 0x400:
|
||||
printf("5V ");
|
||||
voltage_set(slot, 50, 0);
|
||||
break;
|
||||
case 0x800:
|
||||
voltage_set(slot, 33, 0);
|
||||
break;
|
||||
case 0xc00:
|
||||
voltage_set(slot, 33, 0);
|
||||
break;
|
||||
default:
|
||||
voltage_set(slot, 0, 0);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
voltage_set(slot, 0, 0);
|
||||
}
|
||||
|
||||
pci_read_config_word(devbusfn, PCI_BRIDGE_CONTROL, &brg_ctrl);
|
||||
brg_ctrl &= ~PCI_BRIDGE_CTL_BUS_RESET;
|
||||
pci_write_config_word(devbusfn, PCI_BRIDGE_CONTROL, brg_ctrl);
|
||||
is_82365sl = ((readb(socket_base+0x800) & 0x0f) == 2);
|
||||
writeb(is_82365sl?0x90:0x98, socket_base+0x802);
|
||||
writeb(0x67, socket_base+0x803);
|
||||
udelay(100000);
|
||||
#if 0
|
||||
printf("ExCA Id %02x, Card Status %02x, Power config %02x, Interrupt Config %02x, bridge control %04x %d\n",
|
||||
readb(socket_base+0x800), readb(socket_base+0x801),
|
||||
readb(socket_base+0x802), readb(socket_base+0x803), brg_ctrl, is_82365sl);
|
||||
#endif
|
||||
|
||||
return ((readb(socket_base+0x801)&0x6c)==0x6c)?0:1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int hardware_disable(int slot)
|
||||
{
|
||||
voltage_set(slot, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void print_funcid(int func)
|
||||
{
|
||||
puts(indent);
|
||||
switch (func) {
|
||||
case CISTPL_FUNCID_MULTI:
|
||||
puts(" Multi-Function");
|
||||
break;
|
||||
case CISTPL_FUNCID_MEMORY:
|
||||
puts(" Memory");
|
||||
break;
|
||||
case CISTPL_FUNCID_SERIAL:
|
||||
puts(" Serial Port");
|
||||
break;
|
||||
case CISTPL_FUNCID_PARALLEL:
|
||||
puts(" Parallel Port");
|
||||
break;
|
||||
case CISTPL_FUNCID_FIXED:
|
||||
puts(" Fixed Disk");
|
||||
break;
|
||||
case CISTPL_FUNCID_VIDEO:
|
||||
puts(" Video Adapter");
|
||||
break;
|
||||
case CISTPL_FUNCID_NETWORK:
|
||||
puts(" Network Adapter");
|
||||
break;
|
||||
case CISTPL_FUNCID_AIMS:
|
||||
puts(" AIMS Card");
|
||||
break;
|
||||
case CISTPL_FUNCID_SCSI:
|
||||
puts(" SCSI Adapter");
|
||||
break;
|
||||
default:
|
||||
puts(" Unknown");
|
||||
break;
|
||||
}
|
||||
puts(" Card\n");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void print_fixed(volatile uchar *p)
|
||||
{
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
puts(indent);
|
||||
|
||||
switch (*p) {
|
||||
case CISTPL_FUNCE_IDE_IFACE:
|
||||
{ uchar iface = *(p+2);
|
||||
|
||||
puts ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
|
||||
puts (" interface ");
|
||||
break;
|
||||
}
|
||||
case CISTPL_FUNCE_IDE_MASTER:
|
||||
case CISTPL_FUNCE_IDE_SLAVE:
|
||||
{
|
||||
uchar f1 = *(p+2);
|
||||
uchar f2 = *(p+4);
|
||||
|
||||
puts((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
|
||||
|
||||
if (f1 & CISTPL_IDE_UNIQUE) {
|
||||
puts(" [unique]");
|
||||
}
|
||||
|
||||
puts((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
|
||||
|
||||
if (f2 & CISTPL_IDE_HAS_SLEEP) {
|
||||
puts(" [sleep]");
|
||||
}
|
||||
|
||||
if (f2 & CISTPL_IDE_HAS_STANDBY) {
|
||||
puts(" [standby]");
|
||||
}
|
||||
|
||||
if (f2 & CISTPL_IDE_HAS_IDLE) {
|
||||
puts(" [idle]");
|
||||
}
|
||||
|
||||
if (f2 & CISTPL_IDE_LOW_POWER) {
|
||||
puts(" [low power]");
|
||||
}
|
||||
|
||||
if (f2 & CISTPL_IDE_REG_INHIBIT) {
|
||||
puts(" [reg inhibit]");
|
||||
}
|
||||
|
||||
if (f2 & CISTPL_IDE_HAS_INDEX) {
|
||||
puts(" [index]");
|
||||
}
|
||||
|
||||
if (f2 & CISTPL_IDE_IOIS16) {
|
||||
puts(" [IOis16]");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
putc('\n');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define MAX_IDENT_CHARS 64
|
||||
#define MAX_IDENT_FIELDS 4
|
||||
|
||||
static uchar *known_cards[] = {
|
||||
"ARGOSY PnPIDE D5",
|
||||
NULL
|
||||
};
|
||||
|
||||
static int identify(volatile uchar *p)
|
||||
{
|
||||
uchar id_str[MAX_IDENT_CHARS];
|
||||
uchar data;
|
||||
uchar *t;
|
||||
uchar **card;
|
||||
int i, done;
|
||||
|
||||
if (p == NULL)
|
||||
return (0); /* Don't know */
|
||||
|
||||
t = id_str;
|
||||
done =0;
|
||||
|
||||
for (i=0; i<=4 && !done; ++i, p+=2) {
|
||||
while ((data = *p) != '\0') {
|
||||
if (data == 0xFF) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
*t++ = data;
|
||||
if (t == &id_str[MAX_IDENT_CHARS-1]) {
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
p += 2;
|
||||
}
|
||||
if (!done)
|
||||
*t++ = ' ';
|
||||
}
|
||||
*t = '\0';
|
||||
while (--t > id_str) {
|
||||
if (*t == ' ') {
|
||||
*t = '\0';
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
puts(id_str);
|
||||
putc('\n');
|
||||
|
||||
for (card=known_cards; *card; ++card) {
|
||||
debug ("## Compare against \"%s\"\n", *card);
|
||||
if (strcmp(*card, id_str) == 0) { /* found! */
|
||||
debug ("## CARD FOUND ##\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* don't know */
|
||||
}
|
||||
|
||||
#endif /* CONFIG_IDE_TI_CARDBUS */
|
||||
@@ -0,0 +1,354 @@
|
||||
|
||||
/*
|
||||
* Copyright 1998-2001 by Donald Becker.
|
||||
* This software may be used and distributed according to the terms of
|
||||
* the GNU General Public License (GPL), incorporated herein by reference.
|
||||
* Contact the author for use under other terms.
|
||||
*
|
||||
* This program must be compiled with "-O"!
|
||||
* See the bottom of this file for the suggested compile-command.
|
||||
*
|
||||
* The author may be reached as becker@scyld.com, or C/O
|
||||
* Scyld Computing Corporation
|
||||
* 410 Severn Ave., Suite 210
|
||||
* Annapolis MD 21403
|
||||
*
|
||||
* Common-sense licensing statement: Using any portion of this program in
|
||||
* your own program means that you must give credit to the original author
|
||||
* and release the resulting code under the GPL.
|
||||
*/
|
||||
|
||||
#define _PPC_STRING_H_ /* avoid unnecessary str/mem functions */
|
||||
#define _LINUX_STRING_H_ /* avoid unnecessary str/mem functions */
|
||||
|
||||
#include <common.h>
|
||||
#include <syscall.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
|
||||
/* Default EEPROM for i82559 */
|
||||
static unsigned short default_eeprom[64] = {
|
||||
0x0100, 0x0302, 0x0504, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
||||
0xffff, 0xffff, 0x40c0, 0x0000, 0x0000, 0xffff, 0xffff, 0xffff,
|
||||
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
||||
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
||||
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
||||
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
||||
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
|
||||
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
|
||||
};
|
||||
|
||||
static unsigned short eeprom[256];
|
||||
|
||||
static int eeprom_size = 64;
|
||||
static int eeprom_addr_size = 6;
|
||||
|
||||
static int debug = 0;
|
||||
|
||||
static inline unsigned short swap16(unsigned short x)
|
||||
{
|
||||
return (((x & 0xff) << 8) | ((x & 0xff00) >> 8));
|
||||
}
|
||||
|
||||
|
||||
static inline void *memcpy(void *dst, const void *src, unsigned int len)
|
||||
{
|
||||
void * ret = dst;
|
||||
while (len-- > 0) *((char *)dst)++ = *((char *)src)++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* The EEPROM commands include the alway-set leading bit. */
|
||||
#define EE_WRITE_CMD (5)
|
||||
#define EE_READ_CMD (6)
|
||||
#define EE_ERASE_CMD (7)
|
||||
|
||||
/* Serial EEPROM section. */
|
||||
#define EE_SHIFT_CLK 0x01 /* EEPROM shift clock. */
|
||||
#define EE_CS 0x02 /* EEPROM chip select. */
|
||||
#define EE_DATA_WRITE 0x04 /* EEPROM chip data in. */
|
||||
#define EE_DATA_READ 0x08 /* EEPROM chip data out. */
|
||||
#define EE_ENB (0x4800 | EE_CS)
|
||||
#define EE_WRITE_0 0x4802
|
||||
#define EE_WRITE_1 0x4806
|
||||
#define EE_OFFSET 14
|
||||
|
||||
/* Delay between EEPROM clock transitions. */
|
||||
#define eeprom_delay(ee_addr) inw(ee_addr)
|
||||
|
||||
/* Wait for the EEPROM to finish the previous operation. */
|
||||
static int eeprom_busy_poll(long ee_ioaddr)
|
||||
{
|
||||
int i;
|
||||
outw(EE_ENB, ee_ioaddr);
|
||||
for (i = 0; i < 10000; i++) /* Typical 2000 ticks */
|
||||
if (inw(ee_ioaddr) & EE_DATA_READ)
|
||||
break;
|
||||
return i;
|
||||
}
|
||||
|
||||
/* This executes a generic EEPROM command, typically a write or write enable.
|
||||
It returns the data output from the EEPROM, and thus may also be used for
|
||||
reads. */
|
||||
static int do_eeprom_cmd(long ioaddr, int cmd, int cmd_len)
|
||||
{
|
||||
unsigned retval = 0;
|
||||
long ee_addr = ioaddr + EE_OFFSET;
|
||||
|
||||
if (debug > 1)
|
||||
mon_printf(" EEPROM op 0x%x: ", cmd);
|
||||
|
||||
outw(EE_ENB | EE_SHIFT_CLK, ee_addr);
|
||||
|
||||
/* Shift the command bits out. */
|
||||
do {
|
||||
short dataval = (cmd & (1 << cmd_len)) ? EE_WRITE_1 : EE_WRITE_0;
|
||||
outw(dataval, ee_addr);
|
||||
eeprom_delay(ee_addr);
|
||||
if (debug > 2)
|
||||
mon_printf("%X", inw(ee_addr) & 15);
|
||||
outw(dataval | EE_SHIFT_CLK, ee_addr);
|
||||
eeprom_delay(ee_addr);
|
||||
retval = (retval << 1) | ((inw(ee_addr) & EE_DATA_READ) ? 1 : 0);
|
||||
} while (--cmd_len >= 0);
|
||||
#if 0
|
||||
outw(EE_ENB, ee_addr);
|
||||
#endif
|
||||
/* Terminate the EEPROM access. */
|
||||
outw(EE_ENB & ~EE_CS, ee_addr);
|
||||
if (debug > 1)
|
||||
mon_printf(" EEPROM result is 0x%5.5x.\n", retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int read_eeprom(long ioaddr, int location, int addr_len)
|
||||
{
|
||||
return do_eeprom_cmd(ioaddr, ((EE_READ_CMD << addr_len) | location)
|
||||
<< 16 , 3 + addr_len + 16) & 0xffff;
|
||||
}
|
||||
|
||||
static void write_eeprom(long ioaddr, int index, int value, int addr_len)
|
||||
{
|
||||
long ee_ioaddr = ioaddr + EE_OFFSET;
|
||||
int i;
|
||||
|
||||
/* Poll for previous op finished. */
|
||||
eeprom_busy_poll(ee_ioaddr); /* Typical 0 ticks */
|
||||
/* Enable programming modes. */
|
||||
do_eeprom_cmd(ioaddr, (0x4f << (addr_len-4)), 3 + addr_len);
|
||||
/* Do the actual write. */
|
||||
do_eeprom_cmd(ioaddr,
|
||||
(((EE_WRITE_CMD<<addr_len) | index)<<16) | (value & 0xffff),
|
||||
3 + addr_len + 16);
|
||||
/* Poll for write finished. */
|
||||
i = eeprom_busy_poll(ee_ioaddr); /* Typical 2000 ticks */
|
||||
if (debug)
|
||||
mon_printf(" Write finished after %d ticks.\n", i);
|
||||
/* Disable programming. This command is not instantaneous, so we check
|
||||
for busy before the next op. */
|
||||
do_eeprom_cmd(ioaddr, (0x40 << (addr_len-4)), 3 + addr_len);
|
||||
eeprom_busy_poll(ee_ioaddr);
|
||||
}
|
||||
|
||||
static int reset_eeprom(unsigned long ioaddr, unsigned char *hwaddr)
|
||||
{
|
||||
unsigned short checksum = 0;
|
||||
int size_test;
|
||||
int i;
|
||||
|
||||
mon_printf("Resetting i82559 EEPROM @ 0x%08x ... ", ioaddr);
|
||||
|
||||
size_test = do_eeprom_cmd(ioaddr, (EE_READ_CMD << 8) << 16, 27);
|
||||
eeprom_addr_size = (size_test & 0xffe0000) == 0xffe0000 ? 8 : 6;
|
||||
eeprom_size = 1 << eeprom_addr_size;
|
||||
|
||||
memcpy(eeprom, default_eeprom, sizeof default_eeprom);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
eeprom[i] = (hwaddr[i*2+1]<<8) + hwaddr[i*2];
|
||||
|
||||
/* Recalculate the checksum. */
|
||||
for (i = 0; i < eeprom_size - 1; i++)
|
||||
checksum += eeprom[i];
|
||||
eeprom[i] = 0xBABA - checksum;
|
||||
|
||||
for (i = 0; i < eeprom_size; i++)
|
||||
write_eeprom(ioaddr, i, eeprom[i], eeprom_addr_size);
|
||||
|
||||
for (i = 0; i < eeprom_size; i++)
|
||||
if (read_eeprom(ioaddr, i, eeprom_addr_size) != eeprom[i]) {
|
||||
mon_printf("failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
mon_printf("done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int hatoi(char *p, char **errp)
|
||||
{
|
||||
unsigned int res = 0;
|
||||
|
||||
while (1) {
|
||||
switch (*p) {
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
res |= (*p - 'a' + 10);
|
||||
break;
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
res |= (*p - 'A' + 10);
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
res |= (*p - '0');
|
||||
break;
|
||||
default:
|
||||
if (errp) {
|
||||
*errp = p;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
p++;
|
||||
if (*p == 0) {
|
||||
break;
|
||||
}
|
||||
res <<= 4;
|
||||
}
|
||||
|
||||
if (errp) {
|
||||
*errp = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static unsigned char *gethwaddr(char *in, unsigned char *out)
|
||||
{
|
||||
char tmp[3];
|
||||
int i;
|
||||
char *err;
|
||||
|
||||
for (i=0;i<6;i++) {
|
||||
if (in[i*3+2] == 0 && i == 5) {
|
||||
out[i] = hatoi(&in[i*3], &err);
|
||||
if (err) {
|
||||
return NULL;
|
||||
}
|
||||
} else if (in[i*3+2] == ':' && i < 5) {
|
||||
tmp[0] = in[i*3];
|
||||
tmp[1] = in[i*3+1];
|
||||
tmp[2] = 0;
|
||||
out[i] = hatoi(tmp, &err);
|
||||
if (err) {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static u32
|
||||
read_config_dword(int bus, int dev, int func, int reg)
|
||||
{
|
||||
u32 res;
|
||||
|
||||
outl(0x80000000|(bus&0xff)<<16|(dev&0x1f)<<11|(func&7)<<8|(reg&0xfc),
|
||||
0xcf8);
|
||||
res = inl(0xcfc);
|
||||
outl(0, 0xcf8);
|
||||
return res;
|
||||
}
|
||||
|
||||
static u16
|
||||
read_config_word(int bus, int dev, int func, int reg)
|
||||
{
|
||||
u32 res;
|
||||
|
||||
outl(0x80000000|(bus&0xff)<<16|(dev&0x1f)<<11|(func&7)<<8|(reg&0xfc),
|
||||
0xcf8);
|
||||
res = inw(0xcfc + (reg & 2));
|
||||
outl(0, 0xcf8);
|
||||
return res;
|
||||
}
|
||||
|
||||
static void
|
||||
write_config_word(int bus, int dev, int func, int reg, u16 data)
|
||||
{
|
||||
|
||||
outl(0x80000000|(bus&0xff)<<16|(dev&0x1f)<<11|(func&7)<<8|(reg&0xfc),
|
||||
0xcf8);
|
||||
outw(data, 0xcfc + (reg & 2));
|
||||
outl(0, 0xcf8);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
unsigned char *eth_addr;
|
||||
char buf[6];
|
||||
int instance;
|
||||
|
||||
if (argc != 2) {
|
||||
mon_printf ("call with base Ethernet address\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
eth_addr = gethwaddr(argv[1], buf);
|
||||
if (NULL == eth_addr) {
|
||||
mon_printf ("Can not parse ethernet address\n");
|
||||
return 1;
|
||||
}
|
||||
if (eth_addr[5] & 0x01) {
|
||||
mon_printf("Base Ethernet address must be even\n");
|
||||
}
|
||||
|
||||
|
||||
for (instance = 0; instance < 2; instance ++) {
|
||||
unsigned int io_addr;
|
||||
unsigned char mac[6];
|
||||
int bar1 = read_config_dword(0, 6+instance, 0, 0x14);
|
||||
if (! (bar1 & 1)) {
|
||||
mon_printf("ETH%d is disabled %x\n", instance, bar1);
|
||||
} else {
|
||||
mon_printf("ETH%d IO=0x%04x\n", instance, bar1 & ~3);
|
||||
}
|
||||
io_addr = (bar1 & (~3L));
|
||||
|
||||
|
||||
write_config_word(0, 6+instance, 0, 4,
|
||||
read_config_word(0, 6+instance, 0, 4) | 1);
|
||||
mon_printf("ETH%d CMD %04x\n", instance,
|
||||
read_config_word(0, 6+instance, 0, 4));
|
||||
|
||||
memcpy(mac, eth_addr, 6);
|
||||
mac[5] += instance;
|
||||
|
||||
mon_printf("got io=%04x, ha=%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
io_addr, mac[0], mac[1], mac[2],
|
||||
mac[3], mac[4], mac[5]);
|
||||
reset_eeprom(io_addr, mac);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -28,6 +28,11 @@ include $(TOPDIR)/config.mk
|
||||
SREC = hello_world.srec
|
||||
BIN = hello_world.bin
|
||||
|
||||
ifeq ($(ARCH),i386)
|
||||
SREC += 82559_eeprom.srec
|
||||
BIN += 82559_eeprom.bin
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),ppc)
|
||||
SREC += sched.srec
|
||||
BIN += sched.bin
|
||||
|
||||
+5
-1
@@ -76,7 +76,11 @@ mon_free:
|
||||
#define SYSCALL(name,n) \
|
||||
.globl SYMBOL_NAME(name) ; \
|
||||
SYMBOL_NAME_LABEL(name) ; \
|
||||
ret
|
||||
movl $n, %eax ;\
|
||||
pushl %ebx; \
|
||||
pushl %ecx; \
|
||||
int $0x40 ;\
|
||||
|
||||
|
||||
#endif /* CONFIG_I386 */
|
||||
|
||||
|
||||
@@ -241,6 +241,4 @@ struct arp_entry {
|
||||
/*-----------------------------------------------------------------------------+
|
||||
| Function prototypes for device table.
|
||||
+-----------------------------------------------------------------------------*/
|
||||
int enetInt(void);
|
||||
|
||||
#endif /* _enetLib_h_ */
|
||||
@@ -5,7 +5,6 @@
|
||||
* Copyright 1992, Linus Torvalds.
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
|
||||
/*
|
||||
* These have to be done with inline assembly: that way the bit-setting
|
||||
|
||||
@@ -5,10 +5,6 @@
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
/* For avoiding bswap on i386 */
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/config.h>
|
||||
#endif
|
||||
|
||||
static __inline__ __const__ __u32 ___arch__swab32(__u32 x)
|
||||
{
|
||||
|
||||
@@ -116,6 +116,11 @@
|
||||
#define SC520_UART2CTL 0x0cc4 /* UART 2 General Control Register */
|
||||
#define SC520_UART2STA 0x0cc5 /* UART 2 General Status Register */
|
||||
#define SC520_UART2FCRSHAD 0x0cc6 /* UART 2 FIFO Control Shadow Register */
|
||||
#define SC520_SSICTL 0x0cd0 /* SSI Control */
|
||||
#define SC520_SSIXMIT 0x0cd1 /* SSI Transmit */
|
||||
#define SC520_SSICMD 0x0cd2 /* SSI Command */
|
||||
#define SC520_SSISTA 0x0cd3 /* SSI Status */
|
||||
#define SC520_SSIRCV 0x0cd4 /* SSI Receive */
|
||||
#define SC520_PICICR 0x0d00 /* Interrupt Control Register */
|
||||
#define SC520_MPICMODE 0x0d02 /* Master PIC Interrupt Mode Register */
|
||||
#define SC520_SL1PICMODE 0x0d03 /* Slave 1 PIC Interrupt Mode Register */
|
||||
@@ -195,9 +200,31 @@
|
||||
|
||||
/* MMCR Register bits (not all of them :) ) */
|
||||
|
||||
/* SSI Stuff */
|
||||
#define CTL_CLK_SEL_4 0x00 /* Nominal Bit Rate = 8 MHz */
|
||||
#define CTL_CLK_SEL_8 0x10 /* Nominal Bit Rate = 4 MHz */
|
||||
#define CTL_CLK_SEL_16 0x20 /* Nominal Bit Rate = 2 MHz */
|
||||
#define CTL_CLK_SEL_32 0x30 /* Nominal Bit Rate = 1 MHz */
|
||||
#define CTL_CLK_SEL_64 0x40 /* Nominal Bit Rate = 512 KHz */
|
||||
#define CTL_CLK_SEL_128 0x50 /* Nominal Bit Rate = 256 KHz */
|
||||
#define CTL_CLK_SEL_256 0x60 /* Nominal Bit Rate = 128 KHz */
|
||||
#define CTL_CLK_SEL_512 0x70 /* Nominal Bit Rate = 64 KHz */
|
||||
|
||||
#define TC_INT_ENB 0x08 /* Transaction Complete Interrupt Enable */
|
||||
#define PHS_INV_ENB 0x04 /* SSI Inverted Phase Mode Enable */
|
||||
#define CLK_INV_ENB 0x02 /* SSI Inverted Clock Mode Enable */
|
||||
#define MSBF_ENB 0x01 /* SSI Most Significant Bit First Mode Enable */
|
||||
|
||||
#define SSICMD_CMD_SEL_XMITRCV 0x03 /* Simultaneous Transmit / Receive Transaction */
|
||||
#define SSICMD_CMD_SEL_RCV 0x02 /* Receive Transaction */
|
||||
#define SSICMD_CMD_SEL_XMIT 0x01 /* Transmit Transaction */
|
||||
#define SSISTA_BSY 0x02 /* SSI Busy */
|
||||
#define SSISTA_TC_INT 0x01 /* SSI Transaction Complete Interrupt */
|
||||
|
||||
|
||||
/* BITS for SC520_ADDDECCTL: */
|
||||
#define WPV_INT_ENB 0x80 /* Write-Protect Violation Interrupt Enable */
|
||||
#define IO_HOLE_DEST 0x10 /* I/O Hole Access Destination */
|
||||
#define IO_HOLE_DEST_PCI 0x10 /* I/O Hole Access Destination */
|
||||
#define RTC_DIS 0x04 /* RTC Disable */
|
||||
#define UART2_DIS 0x02 /* UART2 Disable */
|
||||
#define UART1_DIS 0x01 /* UART1 Disable */
|
||||
@@ -215,25 +242,64 @@
|
||||
#define SC520_ISA_IO_BUS 0x00000000
|
||||
#define SC520_ISA_IO_SIZE 0x00001000
|
||||
|
||||
/* PCI I/O space from 0x1000 to 0xfdff */
|
||||
/* PCI I/O space from 0x1000 to 0xdfff
|
||||
* (make 0xe000-0xfdff available for stuff like PCCard boot) */
|
||||
#define SC520_PCI_IO_PHYS 0x00001000
|
||||
#define SC520_PCI_IO_BUS 0x00001000
|
||||
#define SC520_PCI_IO_SIZE 0x0000ee00
|
||||
#define SC520_PCI_IO_SIZE 0x0000d000
|
||||
|
||||
/* system memory from 0x00000000 to 0x0fffffff */
|
||||
#define SC520_PCI_MEMORY_PHYS 0x00000000
|
||||
#define SC520_PCI_MEMORY_BUS 0x00000000
|
||||
#define SC520_PCI_MEMORY_SIZE 0x10000000
|
||||
|
||||
/* PCI bus memory from 0x10000000 to 0x27ffffff */
|
||||
/* PCI bus memory from 0x10000000 to 0x26ffffff
|
||||
* (make 0x27000000 - 0x27ffffff available for stuff like PCCard boot) */
|
||||
#define SC520_PCI_MEM_PHYS 0x10000000
|
||||
#define SC520_PCI_MEM_BUS 0x10000000
|
||||
#define SC520_PCI_MEM_SIZE 0x18000000
|
||||
#define SC520_PCI_MEM_SIZE 0x17000000
|
||||
|
||||
/* 0x28000000 - 0x3fffffff is used by the flash banks */
|
||||
|
||||
/* 0x40000000 - 0xffffffff is not adressable by the SC520 */
|
||||
|
||||
/* priority numbers used for interrupt channel mappings */
|
||||
#define SC520_IRQ_DISABLED 0
|
||||
#define SC520_IRQ0 1
|
||||
#define SC520_IRQ1 2
|
||||
#define SC520_IRQ2 4 /* same as IRQ9 */
|
||||
#define SC520_IRQ3 11
|
||||
#define SC520_IRQ4 12
|
||||
#define SC520_IRQ5 13
|
||||
#define SC520_IRQ6 21
|
||||
#define SC520_IRQ7 22
|
||||
#define SC520_IRQ8 3
|
||||
#define SC520_IRQ9 4
|
||||
#define SC520_IRQ10 5
|
||||
#define SC520_IRQ11 6
|
||||
#define SC520_IRQ12 7
|
||||
#define SC520_IRQ13 8
|
||||
#define SC520_IRQ14 9
|
||||
#define SC520_IRQ15 10
|
||||
|
||||
|
||||
/* pin number used for PCI interrupt mappings */
|
||||
#define SC520_PCI_INTA 0
|
||||
#define SC520_PCI_INTB 1
|
||||
#define SC520_PCI_INTC 2
|
||||
#define SC520_PCI_INTD 3
|
||||
#define SC520_PCI_GPIRQ0 4
|
||||
#define SC520_PCI_GPIRQ1 5
|
||||
#define SC520_PCI_GPIRQ2 6
|
||||
#define SC520_PCI_GPIRQ3 7
|
||||
#define SC520_PCI_GPIRQ4 8
|
||||
#define SC520_PCI_GPIRQ5 9
|
||||
#define SC520_PCI_GPIRQ6 10
|
||||
#define SC520_PCI_GPIRQ7 11
|
||||
#define SC520_PCI_GPIRQ8 12
|
||||
#define SC520_PCI_GPIRQ9 13
|
||||
#define SC520_PCI_GPIRQ10 14
|
||||
|
||||
/* utility functions */
|
||||
void write_mmcr_byte(u16 mmcr, u8 data);
|
||||
void write_mmcr_word(u16 mmcr, u16 data);
|
||||
@@ -242,8 +308,11 @@ u8 read_mmcr_byte(u16 mmcr);
|
||||
u16 read_mmcr_word(u16 mmcr);
|
||||
u32 read_mmcr_long(u16 mmcr);
|
||||
|
||||
extern int sc520_pci_ints[];
|
||||
|
||||
void init_sc520(void);
|
||||
unsigned long init_sc520_dram(void);
|
||||
void pci_sc520_init(struct pci_controller *hose);
|
||||
int pci_sc520_set_irq(int pci_pin, int irq);
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef _ASM_IO_H
|
||||
#define _ASM_IO_H
|
||||
|
||||
#include <linux/config.h>
|
||||
|
||||
/*
|
||||
* This file contains the definitions for the x86 IO instructions
|
||||
* inb/inw/inl/outb/outw/outl and the "string versions" of the same
|
||||
|
||||
@@ -27,5 +27,11 @@
|
||||
#define _PCI_I386_H_ 1
|
||||
|
||||
void pci_setup_type1(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data);
|
||||
int pci_enable_legacy_video_ports(struct pci_controller* hose);
|
||||
int pci_shadow_rom(pci_dev_t dev, unsigned char *dest);
|
||||
void pci_remove_rom_window(struct pci_controller* hose, u32 addr);
|
||||
u32 pci_get_rom_window(struct pci_controller* hose, int size);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -27,5 +27,6 @@
|
||||
|
||||
int bios_setup(void);
|
||||
int enter_realmode(u16 seg, u16 off, struct pt_regs *in, struct pt_regs *out);
|
||||
int enter_realmode_int(u8 lvl, struct pt_regs *in, struct pt_regs *out);
|
||||
|
||||
#endif
|
||||
@@ -46,8 +46,15 @@ int cpu_init(void);
|
||||
int timer_init(void);
|
||||
|
||||
/* board/.../... */
|
||||
int board_init(void);
|
||||
int dram_init (void);
|
||||
int board_init(void);
|
||||
int dram_init(void);
|
||||
|
||||
void isa_unmap_rom(u32 addr);
|
||||
u32 isa_map_rom(u32 bus_addr, int size);
|
||||
|
||||
/* lib_i386/... */
|
||||
int video_bios_init(void);
|
||||
int video_init(void);
|
||||
|
||||
|
||||
#endif /* _U_BOOT_I386_H_ */
|
||||
@@ -43,7 +43,8 @@ typedef struct bd_info {
|
||||
unsigned short bi_ethspeed; /* Ethernet speed in Mbps */
|
||||
unsigned long bi_intfreq; /* Internal Freq, in MHz */
|
||||
unsigned long bi_busfreq; /* Bus Freq, in MHz */
|
||||
unsigned long bi_baudrate; /* Console Baudrate */
|
||||
unsigned int bi_baudrate; /* Console Baudrate */
|
||||
unsigned long bi_boot_params; /* where this board expects params */
|
||||
struct environment_s *bi_env;
|
||||
struct /* RAM configuration */
|
||||
{
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
#define CFG_CMD_VFD 0x0000400000000000 /* VFD support (TRAB) */
|
||||
#define CFG_CMD_NAND 0x0000800000000000 /* NAND support */
|
||||
#define CFG_CMD_BMP 0x0001000000000000 /* BMP support */
|
||||
#define CFG_CMD_PORTIO 0x0002000000000000 /* Port I/O */
|
||||
#define CFG_CMD_PING 0x0004000000000000 /* ping support */
|
||||
|
||||
#define CFG_CMD_ALL 0xFFFFFFFFFFFFFFFF /* ALL commands */
|
||||
|
||||
@@ -112,6 +114,7 @@
|
||||
CFG_CMD_NAND | \
|
||||
CFG_CMD_PCI | \
|
||||
CFG_CMD_PCMCIA | \
|
||||
CFG_CMD_PING | \
|
||||
CFG_CMD_REGINFO | \
|
||||
CFG_CMD_SAVES | \
|
||||
CFG_CMD_SCSI | \
|
||||
|
||||
+11
-8
@@ -27,18 +27,21 @@
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
|
||||
#define CMD_TBL_NAND MK_CMD_TBL_ENTRY( \
|
||||
"nand", 3, 5, 1, do_nand, \
|
||||
"nand - NAND sub-system\n", \
|
||||
"nand", 3, 5, 1, do_nand, \
|
||||
"nand - NAND sub-system\n", \
|
||||
"info - show available NAND devices\n" \
|
||||
"nand device [dev] - show or set current device\n" \
|
||||
"nand read addr off size\n" \
|
||||
"nand write addr off size - read/write `size'" \
|
||||
" bytes starting at offset `off'\n" \
|
||||
" to/from memory address `addr'\n" \
|
||||
"nand erase off size - erase `size' bytes of NAND from offset `off'\n" \
|
||||
"nand read[.jffs2] addr off size\n" \
|
||||
"nand write[.jffs2] addr off size - read/write `size' bytes starting\n" \
|
||||
" at offset `off' to/from memory address `addr'\n" \
|
||||
"nand erase [clean] [off size] - erase `size' bytes from\n" \
|
||||
" offset `off' (entire device if not specified)\n" \
|
||||
"nand bad - show bad blocks\n" \
|
||||
"nand read.oob addr off size - read out-of-band data\n" \
|
||||
"nand write.oob addr off size - read out-of-band data\n" \
|
||||
),
|
||||
|
||||
#define CMD_TBL_NANDBOOT MK_CMD_TBL_ENTRY( \
|
||||
#define CMD_TBL_NANDBOOT MK_CMD_TBL_ENTRY( \
|
||||
"nboot", 4, 4, 1, do_nandboot, \
|
||||
"nboot - boot from NAND device\n", \
|
||||
"loadAddr dev\n" \
|
||||
|
||||
@@ -64,11 +64,24 @@ int do_dhcp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
#define CMD_TBL_DHCP
|
||||
#endif /* CFG_CMD_DHCP */
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_PING)
|
||||
#define CMD_TBL_PING MK_CMD_TBL_ENTRY( \
|
||||
"ping", 4, 2, 1, do_ping, \
|
||||
"ping - check if host is reachable\n", \
|
||||
"host\n" \
|
||||
),
|
||||
|
||||
int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
#else
|
||||
#define CMD_TBL_PING
|
||||
#endif /* CFG_CMD_PING */
|
||||
|
||||
#else
|
||||
#define CMD_TBL_BOOTP
|
||||
#define CMD_TBL_TFTPB
|
||||
#define CMD_TBL_RARPB
|
||||
#define CMD_TBL_DHCP
|
||||
#define CMD_TBL_PING
|
||||
#endif /* CFG_CMD_NET */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* (C) Copyright 2003
|
||||
* Marc Singer, elf@buici.com
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* Memory Functions
|
||||
*/
|
||||
#ifndef _CMD_PORTIO_H
|
||||
#define _CMD_PORTIO_H
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_PORTIO)
|
||||
|
||||
#define CMD_TBL_PORTIO_OUT MK_CMD_TBL_ENTRY( \
|
||||
"out", 3, 3, 1, do_portio_out, \
|
||||
"out - write datum to IO port\n", \
|
||||
"[.b, .w, .l] port value\n - output to IO port\n" \
|
||||
),
|
||||
#define CMD_TBL_PORTIO_IN MK_CMD_TBL_ENTRY( \
|
||||
"in", 2, 2, 1, do_portio_in, \
|
||||
"in - read data from an IO port\n", \
|
||||
"[.b, .w, .l] port\n" \
|
||||
" - read datum from IO port\n" \
|
||||
),
|
||||
|
||||
int do_portio_out (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
int do_portio_in (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
|
||||
#else
|
||||
#define CMD_TBL_PORTIO_OUT
|
||||
#define CMD_TBL_PORTIO_IN
|
||||
#endif /* CFG_CMD_PORTIO */
|
||||
|
||||
#endif /* _CMD_PORTIO_H */
|
||||
Loaded 100 of 160 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user