mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
Compare commits
9 Commits
U-Boot-0_4
...
LABEL_2003
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f7cb08ee7 | ||
|
|
a43278a43d | ||
|
|
7205e4075d | ||
|
|
149dded2b1 | ||
|
|
7152b1d0b3 | ||
|
|
4d816774f1 | ||
|
|
093ae273da | ||
|
|
12f34241cb | ||
|
|
326428cc8b |
79
CHANGELOG
79
CHANGELOG
@@ -1,3 +1,80 @@
|
||||
======================================================================
|
||||
Changes for U-Boot 1.0.0:
|
||||
======================================================================
|
||||
|
||||
* Patch by Martin Krause, 11 Sep 2003:
|
||||
add burn-in tests for TRAB board
|
||||
|
||||
* Enable instruction cache on MPC5200 board
|
||||
|
||||
* Patch by Denis Peter, 11 Sep 2003:
|
||||
- fix USB data pointer assignment for bulk only transfer.
|
||||
- prevent to display erased directories in FAT filesystem.
|
||||
|
||||
* Change output format for NAND flash - make it look like for other
|
||||
memory, too
|
||||
|
||||
======================================================================
|
||||
Changes for U-Boot 0.4.8:
|
||||
======================================================================
|
||||
|
||||
* Patches by Denis Peter, 9 Sep 2003:
|
||||
add FAT support for IDE, SCSI and USB
|
||||
|
||||
* Patches by Gleb Natapov, 2 Sep 2003:
|
||||
- cleanup of POST code for unsupported architectures
|
||||
- MPC824x locks way0 of data cache for use as initial RAM;
|
||||
this patch unlocks it after relocation to RAM and invalidates
|
||||
the locked entries.
|
||||
|
||||
* Patch by Gleb Natapov, 30 Aug 2003:
|
||||
new I2C driver for mpc107 bridge. Now works from flash.
|
||||
|
||||
* Patch by Dave Ellis, 11 Aug 2003:
|
||||
- JFFS2: fix typo in common/cmd_jffs2.c
|
||||
- JFFS2: fix CFG_JFFS2_SORT_FRAGMENTS option
|
||||
- JFFS2: remove node version 0 warning
|
||||
- JFFS2: accept JFFS2 PADDING nodes
|
||||
- SXNI855T: add AM29LV800 support
|
||||
- SXNI855T: move environment from EEPROM to flash
|
||||
- SXNI855T: boot from JFFS2 in NOR or NAND flash
|
||||
|
||||
* Patch by Bill Hargen, 11 Aug 2003:
|
||||
fixes for I2C on MPC8240
|
||||
- fix i2c_write routine
|
||||
- fix iprobe command
|
||||
- eliminates use of global variables, plus dead code, cleanup.
|
||||
|
||||
* Add support for USB Mass Storage Devices (BBB)
|
||||
(tested with USB memory sticks only)
|
||||
|
||||
* Avoid flicker on TRAB's VFD
|
||||
|
||||
* Add support for SK98xx driver
|
||||
|
||||
* Add PCI support for SL8245 board
|
||||
|
||||
* Support IceCube board configurations with 1 x AMD AM29LV065 (8 MB)
|
||||
or 1 x AM29LV652 (two LV065 in one chip = 16 MB);
|
||||
Run IPB at 133 Mhz; adjust the MII clock frequency accordingly
|
||||
|
||||
* Set BRG_CLK on PM825/826 to 64MHz (VCO_OUT / 4, instead of 16 MHz)
|
||||
to allow for more accurate baudrate settings
|
||||
(error now 0.7% at 115 kbps, instead of 3.5% before)
|
||||
|
||||
* Patch by Andreas Mohr, 4 Sep 2003:
|
||||
Fix a lot of spelling errors
|
||||
|
||||
* Add support for PPChameleon Eval Board
|
||||
|
||||
* Add support for P3G4 board
|
||||
|
||||
* Fix problem with MGT5100 FEC driver: add "early" MAC address
|
||||
initialization
|
||||
|
||||
* Patch by Yuli Barcohen, 7 Aug 2003:
|
||||
check BCSR to detect if the board is configured in PCI mode
|
||||
|
||||
======================================================================
|
||||
Changes for U-Boot 0.4.7:
|
||||
======================================================================
|
||||
@@ -238,7 +315,7 @@ Changes for U-Boot 0.4.1:
|
||||
- PIC on LWMON board needs delay after power-on
|
||||
- Add missing RSR definitions for MPC8xx
|
||||
- Improve log buffer handling: guarantee clean reset after power-on
|
||||
- Add support for EXBITGEN board
|
||||
- Add support for EXBITGEN board (aka "genie")
|
||||
- Add support for SL8245 board
|
||||
|
||||
* Code cleanup:
|
||||
|
||||
6
CREDITS
6
CREDITS
@@ -302,3 +302,9 @@ W: www.elinos.com
|
||||
N: Pantelis Antoniou
|
||||
E: panto@intracom.gr
|
||||
D: NETVIA board support, ARTOS support.
|
||||
|
||||
N: Raghu Krishnaprasad
|
||||
E: Raghu.Krishnaprasad@fci.com
|
||||
D: Support for Adder-II MPC852T evaluation board
|
||||
W: http://www.forcecomputers.com
|
||||
|
||||
|
||||
@@ -89,9 +89,12 @@ Wolfgang Denk <wd@denx.de>
|
||||
TQM8255 MPC8255
|
||||
|
||||
CPU86 MPC8260
|
||||
PM825 MPC8250
|
||||
PM826 MPC8260
|
||||
TQM8260 MPC8260
|
||||
|
||||
P3G4 MPC7410
|
||||
|
||||
PCIPPC2 MPC750
|
||||
PCIPPC6 MPC750
|
||||
|
||||
@@ -105,6 +108,10 @@ Dave Ellis <DGE@sixnetio.com>
|
||||
|
||||
SXNI855T MPC8xx
|
||||
|
||||
Raghu Krishnaprasad <raghu.krishnaprasad@fci.com>
|
||||
|
||||
ADDERII MPC852T
|
||||
|
||||
Thomas Frieden <ThomasF@hyperion-entertainment.com>
|
||||
|
||||
AmigaOneG3SE MPC7xx
|
||||
|
||||
5
MAKEALL
5
MAKEALL
@@ -59,7 +59,7 @@ LIST_4xx=" \
|
||||
DU405 EBONY ERIC EXBITGEN \
|
||||
MIP405 MIP405T ML2 OCRTC \
|
||||
ORSG PCI405 PIP405 PMC405 \
|
||||
W7OLMC W7OLMG WALNUT405 \
|
||||
PPChameleonEVB W7OLMC W7OLMG WALNUT405 \
|
||||
"
|
||||
|
||||
#########################################################################
|
||||
@@ -89,7 +89,8 @@ LIST_8260=" \
|
||||
#########################################################################
|
||||
|
||||
LIST_74xx=" \
|
||||
EVB64260 PCIPPC2 PCIPPC6 ZUMA \
|
||||
EVB64260 P3G4 PCIPPC2 PCIPPC6 \
|
||||
ZUMA \
|
||||
"
|
||||
|
||||
LIST_7xx=" \
|
||||
|
||||
12
Makefile
12
Makefile
@@ -87,6 +87,7 @@ SUBDIRS = tools \
|
||||
rtc \
|
||||
dtt \
|
||||
drivers \
|
||||
drivers/sk98lin \
|
||||
post \
|
||||
post/cpu \
|
||||
examples
|
||||
@@ -112,9 +113,12 @@ LIBS += disk/libdisk.a
|
||||
LIBS += rtc/librtc.a
|
||||
LIBS += dtt/libdtt.a
|
||||
LIBS += drivers/libdrivers.a
|
||||
LIBS += drivers/sk98lin/libsk98lin.a
|
||||
LIBS += post/libpost.a post/cpu/libcpu.a
|
||||
LIBS += common/libcommon.a
|
||||
LIBS += lib_generic/libgeneric.a
|
||||
# Add GCC lib
|
||||
PLATFORM_LIBS += -L $(shell dirname `$(CC) -print-libgcc-file-name`) -lgcc
|
||||
|
||||
#########################################################################
|
||||
#########################################################################
|
||||
@@ -142,7 +146,7 @@ u-boot.dis: u-boot
|
||||
u-boot: depend subdirs $(OBJS) $(LIBS) $(LDSCRIPT)
|
||||
UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
|
||||
$(LD) $(LDFLAGS) $$UNDEF_SYM $(OBJS) \
|
||||
--start-group $(LIBS) --end-group \
|
||||
--start-group $(LIBS) $(PLATFORM_LIBS) --end-group \
|
||||
-Map u-boot.map -o u-boot
|
||||
|
||||
subdirs:
|
||||
@@ -539,6 +543,9 @@ PIP405_config:unconfig
|
||||
PMC405_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc ppc4xx pmc405 esd
|
||||
|
||||
PPChameleonEVB_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc ppc4xx PPChameleonEVB dave
|
||||
|
||||
W7OLMC_config \
|
||||
W7OLMG_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc ppc4xx w7o
|
||||
@@ -751,6 +758,9 @@ BAB7xx_config: unconfig
|
||||
ELPPC_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc 74xx_7xx elppc eltec
|
||||
|
||||
P3G4_config: unconfig
|
||||
@./mkconfig $(@:_config=) ppc 74xx_7xx evb64260
|
||||
|
||||
#========================================================================
|
||||
# ARM
|
||||
#========================================================================
|
||||
|
||||
59
README
59
README
@@ -119,12 +119,12 @@ U-Boot will always have a patchlevel of "0".
|
||||
Directory Hierarchy:
|
||||
====================
|
||||
|
||||
- board Board dependend files
|
||||
- common Misc architecture independend functions
|
||||
- board Board dependent files
|
||||
- common Misc architecture independent functions
|
||||
- cpu CPU specific files
|
||||
- disk Code for disk drive partition handling
|
||||
- doc Documentation (don't expect too much)
|
||||
- drivers Common used device drivers
|
||||
- drivers Commonly used device drivers
|
||||
- dtt Digital Thermometer and Thermostat drivers
|
||||
- examples Example code for standalone applications, etc.
|
||||
- include Header Files
|
||||
@@ -306,6 +306,7 @@ The following options need to be configured:
|
||||
or CONFIG_MPC824X, CONFIG_MPC8260
|
||||
or CONFIG_IOP480
|
||||
or CONFIG_405GP
|
||||
or CONFIG_405EP
|
||||
or CONFIG_440
|
||||
or CONFIG_MPC74xx
|
||||
or CONFIG_750FX
|
||||
@@ -643,7 +644,7 @@ The following options need to be configured:
|
||||
- Watchdog:
|
||||
CONFIG_WATCHDOG
|
||||
If this variable is defined, it enables watchdog
|
||||
support. There must support in the platform specific
|
||||
support. There must be support in the platform specific
|
||||
code for a watchdog. For the 8xx and 8260 CPUs, the
|
||||
SIU Watchdog feature is enabled in the SYPCR
|
||||
register.
|
||||
@@ -851,7 +852,7 @@ The following options need to be configured:
|
||||
Normally display is black on white background; define
|
||||
CFG_WHITE_ON_BLACK to get it inverted.
|
||||
|
||||
- Spash Screen Support: CONFIG_SPLASH_SCREEN
|
||||
- Splash Screen Support: CONFIG_SPLASH_SCREEN
|
||||
|
||||
If this option is set, the environment is checked for
|
||||
a variable "splashimage". If found, the usual display
|
||||
@@ -1202,7 +1203,7 @@ The following options need to be configured:
|
||||
|
||||
U-Boot considers the values of the environment
|
||||
variables "serial#" (Board Serial Number) and
|
||||
"ethaddr" (Ethernet Address) to bb parameters that
|
||||
"ethaddr" (Ethernet Address) to be parameters that
|
||||
are set once by the board vendor / manufacturer, and
|
||||
protects these variables from casual modification by
|
||||
the user. Once set, these variables are read-only,
|
||||
@@ -1317,7 +1318,7 @@ The following options need to be configured:
|
||||
|
||||
Define this to contain any number of null terminated
|
||||
strings (variable = value pairs) that will be part of
|
||||
the default enviroment compiled into the boot image.
|
||||
the default environment compiled into the boot image.
|
||||
|
||||
For example, place something like this in your
|
||||
board's config file:
|
||||
@@ -1330,7 +1331,7 @@ The following options need to be configured:
|
||||
internal format how the environment is stored by the
|
||||
U-Boot code. This is NOT an official, exported
|
||||
interface! Although it is unlikely that this format
|
||||
will change soon, but there is no guarantee either.
|
||||
will change soon, there is no guarantee either.
|
||||
You better know what you are doing here.
|
||||
|
||||
Note: overly (ab)use of the default environment is
|
||||
@@ -1768,7 +1769,7 @@ Low Level (hardware related) configuration options:
|
||||
|
||||
- CFG_INIT_RAM_ADDR:
|
||||
|
||||
Start address of memory area tha can be used for
|
||||
Start address of memory area that can be used for
|
||||
initial data and stack; please note that this must be
|
||||
writable memory that is working WITHOUT special
|
||||
initialization, i. e. you CANNOT use normal RAM which
|
||||
@@ -1940,7 +1941,7 @@ Note: for some board special configuration names may exist; check if
|
||||
|
||||
|
||||
Finally, type "make all", and you should get some working U-Boot
|
||||
images ready for downlod to / installation on your system:
|
||||
images ready for download to / installation on your system:
|
||||
|
||||
- "u-boot.bin" is a raw binary image
|
||||
- "u-boot" is an image in ELF binary format
|
||||
@@ -1959,7 +1960,7 @@ steps:
|
||||
1. Add a new configuration option for your board to the toplevel
|
||||
"Makefile" and to the "MAKEALL" script, using the existing
|
||||
entries as examples. Note that here and at many other places
|
||||
boards and other names are listed alphabetically sorted. Please
|
||||
boards and other names are listed in alphabetical sort order. Please
|
||||
keep this order.
|
||||
2. Create a new directory to hold your board specific code. Add any
|
||||
files you need. In your board directory, you will need at least
|
||||
@@ -1989,7 +1990,7 @@ cation did not break existing code. At least make sure that *ALL* of
|
||||
the supported boards compile WITHOUT ANY compiler warnings. To do so,
|
||||
just run the "MAKEALL" script, which will configure and build U-Boot
|
||||
for ALL supported system. Be warned, this will take a while. You can
|
||||
select which (cross) compiler to use py passing a `CROSS_COMPILE'
|
||||
select which (cross) compiler to use by passing a `CROSS_COMPILE'
|
||||
environment variable to the script, i. e. to use the cross tools from
|
||||
MontaVista's Hard Hat Linux you can type
|
||||
|
||||
@@ -2116,10 +2117,10 @@ Some configuration options can be set using Environment Variables:
|
||||
does not overwrite the U-Boot stack and data).
|
||||
|
||||
For instance, when you have a system with 16 MB
|
||||
RAM, and want to reseve 4 MB from use by Linux,
|
||||
RAM, and want to reserve 4 MB from use by Linux,
|
||||
you can do this by adding "mem=12M" to the value of
|
||||
the "bootargs" variable. However, now you must make
|
||||
sure, that the initrd image is placed in the first
|
||||
sure that the initrd image is placed in the first
|
||||
12 MB as well - this can be done with
|
||||
|
||||
setenv initrd_high 00c00000
|
||||
@@ -2188,8 +2189,8 @@ only effect after the next boot (yes, that's just like Windoze :-).
|
||||
Command Line Parsing:
|
||||
=====================
|
||||
|
||||
There are two different command line parsers available with U-Boot:
|
||||
the old "simple" one, and the much more pwerful "hush" shell:
|
||||
There are two different command line parsers available with U-Boot:
|
||||
the old "simple" one, and the much more powerful "hush" shell:
|
||||
|
||||
Old, simple command line parser:
|
||||
--------------------------------
|
||||
@@ -2230,9 +2231,9 @@ General rules:
|
||||
Note for Redundant Ethernet Interfaces:
|
||||
=======================================
|
||||
|
||||
Some boards come with redundand ethernet interfaces; U-Boot supports
|
||||
Some boards come with redundant ethernet interfaces; U-Boot supports
|
||||
such configurations and is capable of automatic selection of a
|
||||
"working" interface when needed. MAC assignemnt works as follows:
|
||||
"working" interface when needed. MAC assignment works as follows:
|
||||
|
||||
Network interfaces are numbered eth0, eth1, eth2, ... Corresponding
|
||||
MAC addresses can be stored in the environment as "ethaddr" (=>eth0),
|
||||
@@ -2291,21 +2292,21 @@ Linux Support:
|
||||
==============
|
||||
|
||||
Although U-Boot should support any OS or standalone application
|
||||
easily, Linux has always been in the focus during the design of
|
||||
easily, the main focus has always been on Linux during the design of
|
||||
U-Boot.
|
||||
|
||||
U-Boot includes many features that so far have been part of some
|
||||
special "boot loader" code within the Linux kernel. Also, any
|
||||
"initrd" images to be used are no longer part of one big Linux image;
|
||||
instead, kernel and "initrd" are separate images. This implementation
|
||||
serves serveral purposes:
|
||||
serves several purposes:
|
||||
|
||||
- the same features can be used for other OS or standalone
|
||||
applications (for instance: using compressed images to reduce the
|
||||
Flash memory footprint)
|
||||
|
||||
- it becomes much easier to port new Linux kernel versions because
|
||||
lots of low-level, hardware dependend stuff are done by U-Boot
|
||||
lots of low-level, hardware dependent stuff are done by U-Boot
|
||||
|
||||
- the same Linux kernel image can now be used with different "initrd"
|
||||
images; of course this also means that different kernel images can
|
||||
@@ -2557,7 +2558,7 @@ parameters. You can check and modify this variable using the
|
||||
...
|
||||
|
||||
If you want to boot a Linux kernel with initial ram disk, you pass
|
||||
the memory addreses of both the kernel and the initrd image (PPBCOOT
|
||||
the memory addresses of both the kernel and the initrd image (PPBCOOT
|
||||
format!) to the "bootm" command:
|
||||
|
||||
=> imi 40100000 40200000
|
||||
@@ -2737,7 +2738,7 @@ Hit 'q':
|
||||
Minicom warning:
|
||||
================
|
||||
|
||||
Over time, many people have reported problems when trying to used the
|
||||
Over time, many people have reported problems when trying to use the
|
||||
"minicom" terminal emulation program for serial download. I (wd)
|
||||
consider minicom to be broken, and recommend not to use it. Under
|
||||
Unix, I recommend to use C-Kermit for general purpose use (and
|
||||
@@ -2805,7 +2806,7 @@ models provide on-chip memory (like the IMMR area on MPC8xx and
|
||||
MPC826x processors), on others (parts of) the data cache can be
|
||||
locked as (mis-) used as memory, etc.
|
||||
|
||||
Chris Hallinan posted a good summy of these issues to the
|
||||
Chris Hallinan posted a good summary of these issues to the
|
||||
u-boot-users mailing list:
|
||||
|
||||
Subject: RE: [U-Boot-Users] RE: More On Memory Bank x (nothingness)?
|
||||
@@ -2851,9 +2852,9 @@ code for the initialization procedures:
|
||||
|
||||
* Do not use any unitialized global data (or implicitely initialized
|
||||
as zero data - BSS segment) at all - this is undefined, initiali-
|
||||
zation is performed later (when relocationg to RAM).
|
||||
zation is performed later (when relocating to RAM).
|
||||
|
||||
* Stack space is very limited. Avoid big data buffers or things like
|
||||
* Stack space is very limited. Avoid big data buffers or things like
|
||||
that.
|
||||
|
||||
Having only the stack as writable memory limits means we cannot use
|
||||
@@ -2866,7 +2867,7 @@ the GCC compiler (Global Register Variables) to share the data: we
|
||||
place a pointer (gd) to the global data into a register which we
|
||||
reserve for this purpose.
|
||||
|
||||
When chosing a register for such a purpose we are restricted by the
|
||||
When choosing a register for such a purpose we are restricted by the
|
||||
relevant (E)ABI specifications for the current architecture, and by
|
||||
GCC's implementation.
|
||||
|
||||
@@ -2956,7 +2957,7 @@ System Initialization:
|
||||
In the reset configuration, U-Boot starts at the reset entry point
|
||||
(on most PowerPC systens at address 0x00000100). Because of the reset
|
||||
configuration for CS0# this is a mirror of the onboard Flash memory.
|
||||
To be able to re-map memory U-Boot then jumps to it's link address.
|
||||
To be able to re-map memory U-Boot then jumps to its link address.
|
||||
To be able to implement the initialization code in C, a (small!)
|
||||
initial stack is set up in the internal Dual Ported RAM (in case CPUs
|
||||
which provide such a feature like MPC8xx or MPC8260), or in a locked
|
||||
@@ -2972,7 +2973,7 @@ simple memory test is run that determines the size of the SDRAM
|
||||
banks.
|
||||
|
||||
When there is more than one SDRAM bank, and the banks are of
|
||||
different size, the larger is mapped first. For equal size, the first
|
||||
different size, the largest is mapped first. For equal size, the first
|
||||
bank (CS2#) is mapped first. The first mapping is always for address
|
||||
0x00000000, with any additional banks following immediately to create
|
||||
contiguous memory starting from 0.
|
||||
|
||||
@@ -66,7 +66,7 @@ int dram_init (void)
|
||||
* The NAND lives in the CS2* space
|
||||
*/
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
|
||||
extern void nand_probe (ulong physadr);
|
||||
extern ulong nand_probe (ulong physadr);
|
||||
|
||||
#define AT91_SMARTMEDIA_BASE 0x40000000 /* physical address to access memory on NCS3 */
|
||||
void nand_init (void)
|
||||
@@ -103,10 +103,12 @@ void nand_init (void)
|
||||
*AT91C_PIOB_ODR = AT91C_PIO_PB1; /* disable output */
|
||||
|
||||
if (*AT91C_PIOB_PDSR & AT91C_PIO_PB1)
|
||||
printf ("No ");
|
||||
printf ("SmartMedia card inserted\n");
|
||||
printf (" No SmartMedia card inserted\n");
|
||||
#ifdef DEBUG
|
||||
printf (" SmartMedia card inserted\n");
|
||||
|
||||
printf ("Probing at 0x%.8x\n", AT91_SMARTMEDIA_BASE);
|
||||
nand_probe (AT91_SMARTMEDIA_BASE);
|
||||
#endif
|
||||
printf ("%4lu MB\n", nand_probe(AT91_SMARTMEDIA_BASE) >> 20);
|
||||
}
|
||||
#endif
|
||||
|
||||
46
board/dave/PPChameleonEVB/Makefile
Normal file
46
board/dave/PPChameleonEVB/Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
#
|
||||
# (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): $(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 $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
|
||||
|
||||
sinclude .depend
|
||||
|
||||
#########################################################################
|
||||
274
board/dave/PPChameleonEVB/PPChameleonEVB.c
Normal file
274
board/dave/PPChameleonEVB/PPChameleonEVB.c
Normal file
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* (C) Copyright 2001-2003
|
||||
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/processor.h>
|
||||
#include <command.h>
|
||||
#include <malloc.h>
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#if 0
|
||||
#define FPGA_DEBUG
|
||||
#endif
|
||||
|
||||
/* fpga configuration data - gzip compressed and generated by bin2c */
|
||||
const unsigned char fpgadata[] =
|
||||
{
|
||||
#include "fpgadata.c"
|
||||
};
|
||||
|
||||
/*
|
||||
* include common fpga code (for esd boards)
|
||||
*/
|
||||
#include "../common/fpga.c"
|
||||
|
||||
|
||||
/* Prototypes */
|
||||
int gunzip(void *, int, unsigned char *, int *);
|
||||
|
||||
|
||||
int board_pre_init (void)
|
||||
{
|
||||
out32(GPIO0_OR, CFG_NAND0_CE); /* set initial outputs */
|
||||
out32(GPIO0_OR, CFG_NAND1_CE); /* set initial outputs */
|
||||
|
||||
/*
|
||||
* IRQ 0-15 405GP internally generated; active high; level sensitive
|
||||
* IRQ 16 405GP internally generated; active low; level sensitive
|
||||
* IRQ 17-24 RESERVED
|
||||
* IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive
|
||||
* IRQ 26 (EXT IRQ 1) SER0 ; active low; level sensitive
|
||||
* IRQ 27 (EXT IRQ 2) SER1; active low; level sensitive
|
||||
* IRQ 28 (EXT IRQ 3) FPGA 0; active low; level sensitive
|
||||
* IRQ 29 (EXT IRQ 4) FPGA 1; active low; level sensitive
|
||||
* IRQ 30 (EXT IRQ 5) PCI INTA; active low; level sensitive
|
||||
* IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive
|
||||
*/
|
||||
mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
|
||||
mtdcr(uicer, 0x00000000); /* disable all ints */
|
||||
mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
|
||||
mtdcr(uicpr, 0xFFFFFF81); /* set int polarities */
|
||||
mtdcr(uictr, 0x10000000); /* set int trigger levels */
|
||||
mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
|
||||
mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
|
||||
|
||||
/*
|
||||
* EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
|
||||
*/
|
||||
#if 1 /* test-only */
|
||||
mtebc (epcr, 0xa8400000); /* ebc always driven */
|
||||
#else
|
||||
mtebc (epcr, 0x28400000); /* ebc in high-z */
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int misc_init_f (void)
|
||||
{
|
||||
return 0; /* dummy implementation */
|
||||
}
|
||||
|
||||
|
||||
int misc_init_r (void)
|
||||
{
|
||||
#if 0 /* test-only */
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
#if 0
|
||||
volatile unsigned short *fpga_mode =
|
||||
(unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL);
|
||||
volatile unsigned char *duart0_mcr =
|
||||
(unsigned char *)((ulong)DUART0_BA + 4);
|
||||
volatile unsigned char *duart1_mcr =
|
||||
(unsigned char *)((ulong)DUART1_BA + 4);
|
||||
|
||||
bd_t *bd = gd->bd;
|
||||
char * tmp; /* Temporary char pointer */
|
||||
unsigned char *dst;
|
||||
ulong len = sizeof(fpgadata);
|
||||
int status;
|
||||
int index;
|
||||
int i;
|
||||
unsigned long cntrl0Reg;
|
||||
|
||||
dst = malloc(CFG_FPGA_MAX_SIZE);
|
||||
if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, (int *)&len) != 0) {
|
||||
printf ("GUNZIP ERROR - must RESET board to recover\n");
|
||||
do_reset (NULL, 0, 0, NULL);
|
||||
}
|
||||
|
||||
status = fpga_boot(dst, len);
|
||||
if (status != 0) {
|
||||
printf("\nFPGA: Booting failed ");
|
||||
switch (status) {
|
||||
case ERROR_FPGA_PRG_INIT_LOW:
|
||||
printf("(Timeout: INIT not low after asserting PROGRAM*)\n ");
|
||||
break;
|
||||
case ERROR_FPGA_PRG_INIT_HIGH:
|
||||
printf("(Timeout: INIT not high after deasserting PROGRAM*)\n ");
|
||||
break;
|
||||
case ERROR_FPGA_PRG_DONE:
|
||||
printf("(Timeout: DONE not high after programming FPGA)\n ");
|
||||
break;
|
||||
}
|
||||
|
||||
/* display infos on fpgaimage */
|
||||
index = 15;
|
||||
for (i=0; i<4; i++) {
|
||||
len = dst[index];
|
||||
printf("FPGA: %s\n", &(dst[index+1]));
|
||||
index += len+3;
|
||||
}
|
||||
putc ('\n');
|
||||
/* delayed reboot */
|
||||
for (i=20; i>0; i--) {
|
||||
printf("Rebooting in %2d seconds \r",i);
|
||||
for (index=0;index<1000;index++)
|
||||
udelay(1000);
|
||||
}
|
||||
putc ('\n');
|
||||
do_reset(NULL, 0, 0, NULL);
|
||||
}
|
||||
|
||||
puts("FPGA: ");
|
||||
|
||||
/* display infos on fpgaimage */
|
||||
index = 15;
|
||||
for (i=0; i<4; i++) {
|
||||
len = dst[index];
|
||||
printf("%s ", &(dst[index+1]));
|
||||
index += len+3;
|
||||
}
|
||||
putc ('\n');
|
||||
|
||||
free(dst);
|
||||
|
||||
/*
|
||||
* Reset FPGA via FPGA_DATA pin
|
||||
*/
|
||||
SET_FPGA(FPGA_PRG | FPGA_CLK);
|
||||
udelay(1000); /* wait 1ms */
|
||||
SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);
|
||||
udelay(1000); /* wait 1ms */
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Enable power on PS/2 interface
|
||||
*/
|
||||
*fpga_mode |= CFG_FPGA_CTRL_PS2_RESET;
|
||||
|
||||
/*
|
||||
* Enable interrupts in exar duart mcr[3]
|
||||
*/
|
||||
*duart0_mcr = 0x08;
|
||||
*duart1_mcr = 0x08;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check Board Identity:
|
||||
*/
|
||||
|
||||
int checkboard (void)
|
||||
{
|
||||
unsigned char str[64];
|
||||
int i = getenv_r ("serial#", str, sizeof(str));
|
||||
|
||||
puts ("Board: ");
|
||||
|
||||
if (i == -1) {
|
||||
puts ("### No HW ID - assuming PPChameleonEVB");
|
||||
} else {
|
||||
puts(str);
|
||||
}
|
||||
|
||||
putc ('\n');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
long int initdram (int board_type)
|
||||
{
|
||||
unsigned long val;
|
||||
|
||||
mtdcr(memcfga, mem_mb0cf);
|
||||
val = mfdcr(memcfgd);
|
||||
|
||||
#if 0 /* test-only */
|
||||
for (;;) {
|
||||
NAND_DISABLE_CE(1);
|
||||
udelay(100);
|
||||
NAND_ENABLE_CE(1);
|
||||
udelay(100);
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
printf("\nmb0cf=%x\n", val); /* test-only */
|
||||
printf("strap=%x\n", mfdcr(strap)); /* test-only */
|
||||
#endif
|
||||
|
||||
return (4*1024*1024 << ((val & 0x000e0000) >> 17));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
int testdram (void)
|
||||
{
|
||||
/* TODO: XXX XXX XXX */
|
||||
printf ("test: 16 MB - ok\n");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
|
||||
extern ulong
|
||||
nand_probe(ulong physadr);
|
||||
|
||||
void
|
||||
nand_init(void)
|
||||
{
|
||||
ulong totlen;
|
||||
|
||||
debug ("Probing at 0x%.8x\n", CFG_NAND0_BASE);
|
||||
totlen = nand_probe (CFG_NAND0_BASE);
|
||||
|
||||
debug ("Probing at 0x%.8x\n", CFG_NAND1_BASE);
|
||||
totlen += nand_probe (CFG_NAND1_BASE);
|
||||
|
||||
printf ("%4lu MB\n", totlen >>20);
|
||||
}
|
||||
#endif
|
||||
24
board/dave/PPChameleonEVB/config.mk
Normal file
24
board/dave/PPChameleonEVB/config.mk
Normal file
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# (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
|
||||
#
|
||||
|
||||
TEXT_BASE = 0xFFFC0000
|
||||
105
board/dave/PPChameleonEVB/flash.c
Normal file
105
board/dave/PPChameleonEVB/flash.c
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* (C) Copyright 2001
|
||||
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <ppc4xx.h>
|
||||
#include <asm/processor.h>
|
||||
|
||||
/*
|
||||
* include common flash code (for esd boards)
|
||||
*/
|
||||
#include "../common/flash.c"
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Functions
|
||||
*/
|
||||
static ulong flash_get_size (vu_long * addr, flash_info_t * info);
|
||||
static void flash_get_offsets (ulong base, flash_info_t * info);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
unsigned long flash_init (void)
|
||||
{
|
||||
#ifdef __DEBUG_START_FROM_SRAM__
|
||||
return CFG_DUMMY_FLASH_SIZE;
|
||||
#else
|
||||
unsigned long size_b0;
|
||||
int i;
|
||||
uint pbcr;
|
||||
unsigned long base_b0;
|
||||
int size_val = 0;
|
||||
|
||||
/* 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_BASE0_PRELIM, &flash_info[0]);
|
||||
|
||||
if (flash_info[0].flash_id == FLASH_UNKNOWN) {
|
||||
printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
|
||||
size_b0, size_b0<<20);
|
||||
}
|
||||
|
||||
/* Setup offsets */
|
||||
flash_get_offsets (-size_b0, &flash_info[0]);
|
||||
|
||||
/* Re-do sizing to get full correct info */
|
||||
mtdcr(ebccfga, pb0cr);
|
||||
pbcr = mfdcr(ebccfgd);
|
||||
mtdcr(ebccfga, pb0cr);
|
||||
base_b0 = -size_b0;
|
||||
switch (size_b0) {
|
||||
case 1 << 20:
|
||||
size_val = 0;
|
||||
break;
|
||||
case 2 << 20:
|
||||
size_val = 1;
|
||||
break;
|
||||
case 4 << 20:
|
||||
size_val = 2;
|
||||
break;
|
||||
case 8 << 20:
|
||||
size_val = 3;
|
||||
break;
|
||||
case 16 << 20:
|
||||
size_val = 4;
|
||||
break;
|
||||
}
|
||||
pbcr = (pbcr & 0x0001ffff) | base_b0 | (size_val << 17);
|
||||
mtdcr(ebccfgd, pbcr);
|
||||
|
||||
/* Monitor protection ON by default */
|
||||
(void)flash_protect(FLAG_PROTECT_SET,
|
||||
-CFG_MONITOR_LEN,
|
||||
0xffffffff,
|
||||
&flash_info[0]);
|
||||
|
||||
flash_info[0].size = size_b0;
|
||||
|
||||
return (size_b0);
|
||||
#endif
|
||||
}
|
||||
1139
board/dave/PPChameleonEVB/fpgadata.c
Normal file
1139
board/dave/PPChameleonEVB/fpgadata.c
Normal file
File diff suppressed because it is too large
Load Diff
147
board/dave/PPChameleonEVB/u-boot.lds
Normal file
147
board/dave/PPChameleonEVB/u-boot.lds
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* (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
|
||||
{
|
||||
.resetvec 0xFFFFFFFC :
|
||||
{
|
||||
*(.resetvec)
|
||||
} = 0xffff
|
||||
|
||||
/* 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/ppc4xx/start.o (.text)
|
||||
cpu/ppc4xx/traps.o (.text)
|
||||
cpu/ppc4xx/interrupts.o (.text)
|
||||
cpu/ppc4xx/serial.o (.text)
|
||||
cpu/ppc4xx/cpu_init.o (.text)
|
||||
cpu/ppc4xx/speed.o (.text)
|
||||
cpu/ppc4xx/405gp_enet.o (.text)
|
||||
common/dlmalloc.o (.text)
|
||||
lib_generic/crc32.o (.text)
|
||||
lib_ppc/extable.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 = .);
|
||||
|
||||
__u_boot_cmd_start = .;
|
||||
.u_boot_cmd : { *(.u_boot_cmd) }
|
||||
__u_boot_cmd_end = .;
|
||||
|
||||
|
||||
__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 = .);
|
||||
}
|
||||
681
board/dave/common/flash.c
Normal file
681
board/dave/common/flash.c
Normal file
@@ -0,0 +1,681 @@
|
||||
/*
|
||||
* (C) Copyright 2001
|
||||
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <ppc4xx.h>
|
||||
#include <asm/processor.h>
|
||||
|
||||
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Functions
|
||||
*/
|
||||
static int write_word (flash_info_t *info, ulong dest, ulong data);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
static void flash_get_offsets (ulong base, flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
short n;
|
||||
|
||||
/* set up sector start address table */
|
||||
if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AM640U)) {
|
||||
for (i = 0; i < info->sector_count; i++)
|
||||
info->start[i] = base + (i * 0x00010000);
|
||||
} else if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL322B) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL323B) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320B) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL324B)) {
|
||||
/* set sector offsets for bottom boot block type */
|
||||
for (i=0; i<8; ++i) { /* 8 x 8k boot sectors */
|
||||
info->start[i] = base;
|
||||
base += 8 << 10;
|
||||
}
|
||||
while (i < info->sector_count) { /* 64k regular sectors */
|
||||
info->start[i] = base;
|
||||
base += 64 << 10;
|
||||
++i;
|
||||
}
|
||||
} else if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL322T) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL323T) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320T) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL324T)) {
|
||||
/* set sector offsets for top boot block type */
|
||||
base += info->size;
|
||||
i = info->sector_count;
|
||||
for (n=0; n<8; ++n) { /* 8 x 8k boot sectors */
|
||||
base -= 8 << 10;
|
||||
--i;
|
||||
info->start[i] = base;
|
||||
}
|
||||
while (i > 0) { /* 64k regular sectors */
|
||||
base -= 64 << 10;
|
||||
--i;
|
||||
info->start[i] = base;
|
||||
}
|
||||
} else {
|
||||
if (info->flash_id & FLASH_BTYPE) {
|
||||
/* set sector offsets for bottom boot block type */
|
||||
info->start[0] = base + 0x00000000;
|
||||
info->start[1] = base + 0x00004000;
|
||||
info->start[2] = base + 0x00006000;
|
||||
info->start[3] = base + 0x00008000;
|
||||
for (i = 4; i < info->sector_count; i++) {
|
||||
info->start[i] = base + (i * 0x00010000) - 0x00030000;
|
||||
}
|
||||
} else {
|
||||
/* set sector offsets for top boot block type */
|
||||
i = info->sector_count - 1;
|
||||
info->start[i--] = base + info->size - 0x00004000;
|
||||
info->start[i--] = base + info->size - 0x00006000;
|
||||
info->start[i--] = base + info->size - 0x00008000;
|
||||
for (; i >= 0; i--) {
|
||||
info->start[i] = base + i * 0x00010000;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
void flash_print_info (flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
int k;
|
||||
int size;
|
||||
int erased;
|
||||
volatile unsigned long *flash;
|
||||
|
||||
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;
|
||||
case FLASH_MAN_SST: printf ("SST "); break;
|
||||
case FLASH_MAN_STM: printf ("ST "); 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_AM320T: printf ("AM29LV320T (32 M, top sector)\n");
|
||||
break;
|
||||
case FLASH_AM320B: printf ("AM29LV320B (32 M, bottom sector)\n");
|
||||
break;
|
||||
case FLASH_AMDL322T: printf ("AM29DL322T (32 M, top sector)\n");
|
||||
break;
|
||||
case FLASH_AMDL322B: printf ("AM29DL322B (32 M, bottom sector)\n");
|
||||
break;
|
||||
case FLASH_AMDL323T: printf ("AM29DL323T (32 M, top sector)\n");
|
||||
break;
|
||||
case FLASH_AMDL323B: printf ("AM29DL323B (32 M, bottom sector)\n");
|
||||
break;
|
||||
case FLASH_AM640U: printf ("AM29LV640D (64 M, uniform sector)\n");
|
||||
break;
|
||||
case FLASH_SST800A: printf ("SST39LF/VF800 (8 Mbit, uniform sector size)\n");
|
||||
break;
|
||||
case FLASH_SST160A: printf ("SST39LF/VF160 (16 Mbit, uniform sector size)\n");
|
||||
break;
|
||||
case FLASH_STMW320DT: printf ("M29W320DT (32 M, top 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) {
|
||||
#ifdef CFG_FLASH_EMPTY_INFO
|
||||
/*
|
||||
* Check if whole sector is erased
|
||||
*/
|
||||
if (i != (info->sector_count-1))
|
||||
size = info->start[i+1] - info->start[i];
|
||||
else
|
||||
size = info->start[0] + info->size - info->start[i];
|
||||
erased = 1;
|
||||
flash = (volatile unsigned long *)info->start[i];
|
||||
size = size >> 2; /* divide by 4 for longword access */
|
||||
for (k=0; k<size; k++)
|
||||
{
|
||||
if (*flash++ != 0xffffffff)
|
||||
{
|
||||
erased = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((i % 5) == 0)
|
||||
printf ("\n ");
|
||||
/* print empty and read-only info */
|
||||
printf (" %08lX%s%s",
|
||||
info->start[i],
|
||||
erased ? " E" : " ",
|
||||
info->protect[i] ? "RO " : " ");
|
||||
#else
|
||||
if ((i % 5) == 0)
|
||||
printf ("\n ");
|
||||
printf (" %08lX%s",
|
||||
info->start[i],
|
||||
info->protect[i] ? " (RO)" : " ");
|
||||
#endif
|
||||
|
||||
}
|
||||
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;
|
||||
short n;
|
||||
CFG_FLASH_WORD_SIZE value;
|
||||
ulong base = (ulong)addr;
|
||||
volatile CFG_FLASH_WORD_SIZE *addr2 = (CFG_FLASH_WORD_SIZE *)addr;
|
||||
|
||||
/* Write auto select command: read Manufacturer ID */
|
||||
addr2[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr2[CFG_FLASH_ADDR1] = (CFG_FLASH_WORD_SIZE)0x00550055;
|
||||
addr2[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00900090;
|
||||
|
||||
value = addr2[CFG_FLASH_READ0];
|
||||
|
||||
switch (value) {
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_MANUFACT:
|
||||
info->flash_id = FLASH_MAN_AMD;
|
||||
break;
|
||||
case (CFG_FLASH_WORD_SIZE)FUJ_MANUFACT:
|
||||
info->flash_id = FLASH_MAN_FUJ;
|
||||
break;
|
||||
case (CFG_FLASH_WORD_SIZE)SST_MANUFACT:
|
||||
info->flash_id = FLASH_MAN_SST;
|
||||
break;
|
||||
case (CFG_FLASH_WORD_SIZE)STM_MANUFACT:
|
||||
info->flash_id = FLASH_MAN_STM;
|
||||
break;
|
||||
default:
|
||||
info->flash_id = FLASH_UNKNOWN;
|
||||
info->sector_count = 0;
|
||||
info->size = 0;
|
||||
return (0); /* no or unknown flash */
|
||||
}
|
||||
|
||||
value = addr2[CFG_FLASH_READ1]; /* device ID */
|
||||
|
||||
switch (value) {
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV400T:
|
||||
info->flash_id += FLASH_AM400T;
|
||||
info->sector_count = 11;
|
||||
info->size = 0x00080000;
|
||||
break; /* => 0.5 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV400B:
|
||||
info->flash_id += FLASH_AM400B;
|
||||
info->sector_count = 11;
|
||||
info->size = 0x00080000;
|
||||
break; /* => 0.5 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV800T:
|
||||
info->flash_id += FLASH_AM800T;
|
||||
info->sector_count = 19;
|
||||
info->size = 0x00100000;
|
||||
break; /* => 1 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV800B:
|
||||
info->flash_id += FLASH_AM800B;
|
||||
info->sector_count = 19;
|
||||
info->size = 0x00100000;
|
||||
break; /* => 1 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV160T:
|
||||
info->flash_id += FLASH_AM160T;
|
||||
info->sector_count = 35;
|
||||
info->size = 0x00200000;
|
||||
break; /* => 2 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV160B:
|
||||
info->flash_id += FLASH_AM160B;
|
||||
info->sector_count = 35;
|
||||
info->size = 0x00200000;
|
||||
break; /* => 2 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)STM_ID_29W320DT:
|
||||
info->flash_id += FLASH_STMW320DT;
|
||||
info->sector_count = 67;
|
||||
info->size = 0x00400000; break; /* => 4 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV320T:
|
||||
info->flash_id += FLASH_AM320T;
|
||||
info->sector_count = 71;
|
||||
info->size = 0x00400000; break; /* => 4 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV320B:
|
||||
info->flash_id += FLASH_AM320B;
|
||||
info->sector_count = 71;
|
||||
info->size = 0x00400000; break; /* => 4 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_DL322T:
|
||||
info->flash_id += FLASH_AMDL322T;
|
||||
info->sector_count = 71;
|
||||
info->size = 0x00400000; break; /* => 4 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_DL322B:
|
||||
info->flash_id += FLASH_AMDL322B;
|
||||
info->sector_count = 71;
|
||||
info->size = 0x00400000; break; /* => 4 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_DL323T:
|
||||
info->flash_id += FLASH_AMDL323T;
|
||||
info->sector_count = 71;
|
||||
info->size = 0x00400000; break; /* => 4 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_DL323B:
|
||||
info->flash_id += FLASH_AMDL323B;
|
||||
info->sector_count = 71;
|
||||
info->size = 0x00400000; break; /* => 4 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)AMD_ID_LV640U:
|
||||
info->flash_id += FLASH_AM640U;
|
||||
info->sector_count = 128;
|
||||
info->size = 0x00800000; break; /* => 8 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)SST_ID_xF800A:
|
||||
info->flash_id += FLASH_SST800A;
|
||||
info->sector_count = 16;
|
||||
info->size = 0x00100000;
|
||||
break; /* => 1 MB */
|
||||
|
||||
case (CFG_FLASH_WORD_SIZE)SST_ID_xF160A:
|
||||
info->flash_id += FLASH_SST160A;
|
||||
info->sector_count = 32;
|
||||
info->size = 0x00200000;
|
||||
break; /* => 2 MB */
|
||||
|
||||
default:
|
||||
info->flash_id = FLASH_UNKNOWN;
|
||||
return (0); /* => no or unknown flash */
|
||||
|
||||
}
|
||||
|
||||
/* set up sector start address table */
|
||||
if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AM640U)) {
|
||||
for (i = 0; i < info->sector_count; i++)
|
||||
info->start[i] = base + (i * 0x00010000);
|
||||
} else if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL322B) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL323B) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320B) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL324B)) {
|
||||
/* set sector offsets for bottom boot block type */
|
||||
for (i=0; i<8; ++i) { /* 8 x 8k boot sectors */
|
||||
info->start[i] = base;
|
||||
base += 8 << 10;
|
||||
}
|
||||
while (i < info->sector_count) { /* 64k regular sectors */
|
||||
info->start[i] = base;
|
||||
base += 64 << 10;
|
||||
++i;
|
||||
}
|
||||
} else if (((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL322T) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL323T) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AM320T) ||
|
||||
((info->flash_id & FLASH_TYPEMASK) == FLASH_AMDL324T)) {
|
||||
/* set sector offsets for top boot block type */
|
||||
base += info->size;
|
||||
i = info->sector_count;
|
||||
for (n=0; n<8; ++n) { /* 8 x 8k boot sectors */
|
||||
base -= 8 << 10;
|
||||
--i;
|
||||
info->start[i] = base;
|
||||
}
|
||||
while (i > 0) { /* 64k regular sectors */
|
||||
base -= 64 << 10;
|
||||
--i;
|
||||
info->start[i] = base;
|
||||
}
|
||||
} else if ((info->flash_id & FLASH_TYPEMASK) == FLASH_STMW320DT) {
|
||||
/* set sector offsets for top boot block type */
|
||||
base += info->size;
|
||||
i = info->sector_count;
|
||||
/* 1 x 16k boot sector */
|
||||
base -= 16 << 10;
|
||||
--i;
|
||||
info->start[i] = base;
|
||||
/* 2 x 8k boot sectors */
|
||||
for (n=0; n<2; ++n) {
|
||||
base -= 8 << 10;
|
||||
--i;
|
||||
info->start[i] = base;
|
||||
}
|
||||
/* 1 x 32k boot sector */
|
||||
base -= 32 << 10;
|
||||
--i;
|
||||
info->start[i] = base;
|
||||
|
||||
while (i > 0) { /* 64k regular sectors */
|
||||
base -= 64 << 10;
|
||||
--i;
|
||||
info->start[i] = base;
|
||||
}
|
||||
} else {
|
||||
if (info->flash_id & FLASH_BTYPE) {
|
||||
/* set sector offsets for bottom boot block type */
|
||||
info->start[0] = base + 0x00000000;
|
||||
info->start[1] = base + 0x00004000;
|
||||
info->start[2] = base + 0x00006000;
|
||||
info->start[3] = base + 0x00008000;
|
||||
for (i = 4; i < info->sector_count; i++) {
|
||||
info->start[i] = base + (i * 0x00010000) - 0x00030000;
|
||||
}
|
||||
} else {
|
||||
/* set sector offsets for top boot block type */
|
||||
i = info->sector_count - 1;
|
||||
info->start[i--] = base + info->size - 0x00004000;
|
||||
info->start[i--] = base + info->size - 0x00006000;
|
||||
info->start[i--] = base + info->size - 0x00008000;
|
||||
for (; i >= 0; i--) {
|
||||
info->start[i] = base + i * 0x00010000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
addr2 = (volatile CFG_FLASH_WORD_SIZE *)(info->start[i]);
|
||||
if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST)
|
||||
info->protect[i] = 0;
|
||||
else
|
||||
info->protect[i] = addr2[CFG_FLASH_READ2] & 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prevent writes to uninitialized FLASH.
|
||||
*/
|
||||
if (info->flash_id != FLASH_UNKNOWN) {
|
||||
addr2 = (CFG_FLASH_WORD_SIZE *)info->start[0];
|
||||
*addr2 = (CFG_FLASH_WORD_SIZE)0x00F000F0; /* reset bank */
|
||||
}
|
||||
|
||||
return (info->size);
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int flash_erase (flash_info_t *info, int s_first, int s_last)
|
||||
{
|
||||
volatile CFG_FLASH_WORD_SIZE *addr = (CFG_FLASH_WORD_SIZE *)(info->start[0]);
|
||||
volatile CFG_FLASH_WORD_SIZE *addr2;
|
||||
int flag, prot, sect, l_sect;
|
||||
ulong start, now, last;
|
||||
int i;
|
||||
|
||||
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) {
|
||||
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();
|
||||
|
||||
/* Start erase on unprotected sectors */
|
||||
for (sect = s_first; sect<=s_last; sect++) {
|
||||
if (info->protect[sect] == 0) { /* not protected */
|
||||
addr2 = (CFG_FLASH_WORD_SIZE *)(info->start[sect]);
|
||||
if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) {
|
||||
addr[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr[CFG_FLASH_ADDR1] = (CFG_FLASH_WORD_SIZE)0x00550055;
|
||||
addr[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00800080;
|
||||
addr[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr[CFG_FLASH_ADDR1] = (CFG_FLASH_WORD_SIZE)0x00550055;
|
||||
addr2[0] = (CFG_FLASH_WORD_SIZE)0x00500050; /* block erase */
|
||||
for (i=0; i<50; i++)
|
||||
udelay(1000); /* wait 1 ms */
|
||||
} else {
|
||||
if (sect == s_first) {
|
||||
addr[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr[CFG_FLASH_ADDR1] = (CFG_FLASH_WORD_SIZE)0x00550055;
|
||||
addr[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00800080;
|
||||
addr[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr[CFG_FLASH_ADDR1] = (CFG_FLASH_WORD_SIZE)0x00550055;
|
||||
}
|
||||
addr2[0] = (CFG_FLASH_WORD_SIZE)0x00300030; /* sector erase */
|
||||
}
|
||||
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 = (CFG_FLASH_WORD_SIZE *)(info->start[l_sect]);
|
||||
while ((addr[0] & (CFG_FLASH_WORD_SIZE)0x00800080) != (CFG_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 */
|
||||
putc ('.');
|
||||
last = now;
|
||||
}
|
||||
}
|
||||
|
||||
DONE:
|
||||
/* reset to read mode */
|
||||
addr = (CFG_FLASH_WORD_SIZE *)info->start[0];
|
||||
addr[0] = (CFG_FLASH_WORD_SIZE)0x00F000F0; /* 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 CFG_FLASH_WORD_SIZE *addr2 = (CFG_FLASH_WORD_SIZE *)(info->start[0]);
|
||||
volatile CFG_FLASH_WORD_SIZE *dest2 = (CFG_FLASH_WORD_SIZE *)dest;
|
||||
volatile CFG_FLASH_WORD_SIZE *data2 = (CFG_FLASH_WORD_SIZE *)&data;
|
||||
ulong start;
|
||||
int flag;
|
||||
int i;
|
||||
|
||||
/* Check if Flash is (sufficiently) erased */
|
||||
if ((*((volatile CFG_FLASH_WORD_SIZE *)dest) &
|
||||
(CFG_FLASH_WORD_SIZE)data) != (CFG_FLASH_WORD_SIZE)data) {
|
||||
return (2);
|
||||
}
|
||||
/* Disable interrupts which might cause a timeout here */
|
||||
flag = disable_interrupts();
|
||||
|
||||
for (i=0; i<4/sizeof(CFG_FLASH_WORD_SIZE); i++)
|
||||
{
|
||||
addr2[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00AA00AA;
|
||||
addr2[CFG_FLASH_ADDR1] = (CFG_FLASH_WORD_SIZE)0x00550055;
|
||||
addr2[CFG_FLASH_ADDR0] = (CFG_FLASH_WORD_SIZE)0x00A000A0;
|
||||
|
||||
dest2[i] = data2[i];
|
||||
|
||||
/* re-enable interrupts if necessary */
|
||||
if (flag)
|
||||
enable_interrupts();
|
||||
|
||||
/* data polling for D7 */
|
||||
start = get_timer (0);
|
||||
while ((dest2[i] & (CFG_FLASH_WORD_SIZE)0x00800080) !=
|
||||
(data2[i] & (CFG_FLASH_WORD_SIZE)0x00800080)) {
|
||||
if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
256
board/dave/common/fpga.c
Normal file
256
board/dave/common/fpga.c
Normal file
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* (C) Copyright 2001-2003
|
||||
* Matthias Fuchs, esd gmbh germany, matthias.fuchs@esd-electronics.com
|
||||
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/processor.h>
|
||||
#include <command.h>
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef FPGA_DEBUG
|
||||
#define DBG(x...) printf(x)
|
||||
#else
|
||||
#define DBG(x...)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#define MAX_ONES 226
|
||||
|
||||
#ifdef CFG_FPGA_PRG
|
||||
# define FPGA_PRG CFG_FPGA_PRG /* FPGA program pin (ppc output)*/
|
||||
# define FPGA_CLK CFG_FPGA_CLK /* FPGA clk pin (ppc output) */
|
||||
# define FPGA_DATA CFG_FPGA_DATA /* FPGA data pin (ppc output) */
|
||||
# define FPGA_DONE CFG_FPGA_DONE /* FPGA done pin (ppc input) */
|
||||
# define FPGA_INIT CFG_FPGA_INIT /* FPGA init pin (ppc input) */
|
||||
#else
|
||||
# define FPGA_PRG 0x04000000 /* FPGA program pin (ppc output) */
|
||||
# define FPGA_CLK 0x02000000 /* FPGA clk pin (ppc output) */
|
||||
# define FPGA_DATA 0x01000000 /* FPGA data pin (ppc output) */
|
||||
# define FPGA_DONE 0x00800000 /* FPGA done pin (ppc input) */
|
||||
# define FPGA_INIT 0x00400000 /* FPGA init pin (ppc input) */
|
||||
#endif
|
||||
|
||||
#define ERROR_FPGA_PRG_INIT_LOW -1 /* Timeout after PRG* asserted */
|
||||
#define ERROR_FPGA_PRG_INIT_HIGH -2 /* Timeout after PRG* deasserted */
|
||||
#define ERROR_FPGA_PRG_DONE -3 /* Timeout after programming */
|
||||
|
||||
#define SET_FPGA(data) out32(GPIO0_OR, data)
|
||||
|
||||
#define FPGA_WRITE_1 { \
|
||||
SET_FPGA(FPGA_PRG | FPGA_DATA); /* set clock to 0 */ \
|
||||
SET_FPGA(FPGA_PRG | FPGA_DATA); /* set data to 1 */ \
|
||||
SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA); /* set clock to 1 */ \
|
||||
SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);} /* set data to 1 */
|
||||
|
||||
#define FPGA_WRITE_0 { \
|
||||
SET_FPGA(FPGA_PRG | FPGA_DATA); /* set clock to 0 */ \
|
||||
SET_FPGA(FPGA_PRG); /* set data to 0 */ \
|
||||
SET_FPGA(FPGA_PRG | FPGA_CLK); /* set clock to 1 */ \
|
||||
SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA);} /* set data to 1 */
|
||||
|
||||
#if 0
|
||||
static int fpga_boot (unsigned char *fpgadata, int size)
|
||||
{
|
||||
int i, index, len;
|
||||
int count;
|
||||
|
||||
#ifdef CFG_FPGA_SPARTAN2
|
||||
int j;
|
||||
#else
|
||||
unsigned char b;
|
||||
int bit;
|
||||
#endif
|
||||
|
||||
/* display infos on fpgaimage */
|
||||
index = 15;
|
||||
for (i = 0; i < 4; i++) {
|
||||
len = fpgadata[index];
|
||||
DBG ("FPGA: %s\n", &(fpgadata[index + 1]));
|
||||
index += len + 3;
|
||||
}
|
||||
|
||||
#ifdef CFG_FPGA_SPARTAN2
|
||||
/* search for preamble 0xFFFFFFFF */
|
||||
while (1) {
|
||||
if ((fpgadata[index] == 0xff) && (fpgadata[index + 1] == 0xff)
|
||||
&& (fpgadata[index + 2] == 0xff)
|
||||
&& (fpgadata[index + 3] == 0xff))
|
||||
break; /* preamble found */
|
||||
else
|
||||
index++;
|
||||
}
|
||||
#else
|
||||
/* search for preamble 0xFF2X */
|
||||
for (index = 0; index < size - 1; index++) {
|
||||
if ((fpgadata[index] == 0xff)
|
||||
&& ((fpgadata[index + 1] & 0xf0) == 0x30))
|
||||
break;
|
||||
}
|
||||
index += 2;
|
||||
#endif
|
||||
|
||||
DBG ("FPGA: configdata starts at position 0x%x\n", index);
|
||||
DBG ("FPGA: length of fpga-data %d\n", size - index);
|
||||
|
||||
/*
|
||||
* Setup port pins for fpga programming
|
||||
*/
|
||||
out32 (GPIO0_ODR, 0x00000000); /* no open drain pins */
|
||||
out32 (GPIO0_TCR, in32 (GPIO0_TCR) | FPGA_PRG | FPGA_CLK | FPGA_DATA); /* setup for output */
|
||||
out32 (GPIO0_OR, in32 (GPIO0_OR) | FPGA_PRG | FPGA_CLK | FPGA_DATA); /* set pins to high */
|
||||
|
||||
DBG ("%s, ",
|
||||
((in32 (GPIO0_IR) & FPGA_DONE) == 0) ? "NOT DONE" : "DONE");
|
||||
DBG ("%s\n",
|
||||
((in32 (GPIO0_IR) & FPGA_INIT) == 0) ? "NOT INIT" : "INIT");
|
||||
|
||||
/*
|
||||
* Init fpga by asserting and deasserting PROGRAM*
|
||||
*/
|
||||
SET_FPGA (FPGA_CLK | FPGA_DATA);
|
||||
|
||||
/* Wait for FPGA init line low */
|
||||
count = 0;
|
||||
while (in32 (GPIO0_IR) & FPGA_INIT) {
|
||||
udelay (1000); /* wait 1ms */
|
||||
/* Check for timeout - 100us max, so use 3ms */
|
||||
if (count++ > 3) {
|
||||
DBG ("FPGA: Booting failed!\n");
|
||||
return ERROR_FPGA_PRG_INIT_LOW;
|
||||
}
|
||||
}
|
||||
|
||||
DBG ("%s, ",
|
||||
((in32 (GPIO0_IR) & FPGA_DONE) == 0) ? "NOT DONE" : "DONE");
|
||||
DBG ("%s\n",
|
||||
((in32 (GPIO0_IR) & FPGA_INIT) == 0) ? "NOT INIT" : "INIT");
|
||||
|
||||
/* deassert PROGRAM* */
|
||||
SET_FPGA (FPGA_PRG | FPGA_CLK | FPGA_DATA);
|
||||
|
||||
/* Wait for FPGA end of init period . */
|
||||
count = 0;
|
||||
while (!(in32 (GPIO0_IR) & FPGA_INIT)) {
|
||||
udelay (1000); /* wait 1ms */
|
||||
/* Check for timeout */
|
||||
if (count++ > 3) {
|
||||
DBG ("FPGA: Booting failed!\n");
|
||||
return ERROR_FPGA_PRG_INIT_HIGH;
|
||||
}
|
||||
}
|
||||
|
||||
DBG ("%s, ",
|
||||
((in32 (GPIO0_IR) & FPGA_DONE) == 0) ? "NOT DONE" : "DONE");
|
||||
DBG ("%s\n",
|
||||
((in32 (GPIO0_IR) & FPGA_INIT) == 0) ? "NOT INIT" : "INIT");
|
||||
|
||||
DBG ("write configuration data into fpga\n");
|
||||
/* write configuration-data into fpga... */
|
||||
|
||||
#ifdef CFG_FPGA_SPARTAN2
|
||||
/*
|
||||
* Load uncompressed image into fpga
|
||||
*/
|
||||
for (i = index; i < size; i++) {
|
||||
for (j = 0; j < 8; j++) {
|
||||
if ((fpgadata[i] & 0x80) == 0x80) {
|
||||
FPGA_WRITE_1;
|
||||
} else {
|
||||
FPGA_WRITE_0;
|
||||
}
|
||||
fpgadata[i] <<= 1;
|
||||
}
|
||||
}
|
||||
#else /* ! CFG_FPGA_SPARTAN2 */
|
||||
/* send 0xff 0x20 */
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_0;
|
||||
FPGA_WRITE_0;
|
||||
FPGA_WRITE_1;
|
||||
FPGA_WRITE_0;
|
||||
FPGA_WRITE_0;
|
||||
FPGA_WRITE_0;
|
||||
FPGA_WRITE_0;
|
||||
FPGA_WRITE_0;
|
||||
|
||||
/*
|
||||
** Bit_DeCompression
|
||||
** Code 1 .. maxOnes : n '1's followed by '0'
|
||||
** maxOnes + 1 .. maxOnes + 1 : n - 1 '1's no '0'
|
||||
** maxOnes + 2 .. 254 : n - (maxOnes + 2) '0's followed by '1'
|
||||
** 255 : '1'
|
||||
*/
|
||||
|
||||
for (i = index; i < size; i++) {
|
||||
b = fpgadata[i];
|
||||
if ((b >= 1) && (b <= MAX_ONES)) {
|
||||
for (bit = 0; bit < b; bit++) {
|
||||
FPGA_WRITE_1;
|
||||
}
|
||||
FPGA_WRITE_0;
|
||||
} else if (b == (MAX_ONES + 1)) {
|
||||
for (bit = 1; bit < b; bit++) {
|
||||
FPGA_WRITE_1;
|
||||
}
|
||||
} else if ((b >= (MAX_ONES + 2)) && (b <= 254)) {
|
||||
for (bit = 0; bit < (b - (MAX_ONES + 2)); bit++) {
|
||||
FPGA_WRITE_0;
|
||||
}
|
||||
FPGA_WRITE_1;
|
||||
} else if (b == 255) {
|
||||
FPGA_WRITE_1;
|
||||
}
|
||||
}
|
||||
#endif /* CFG_FPGA_SPARTAN2 */
|
||||
|
||||
DBG ("%s, ",
|
||||
((in32 (GPIO0_IR) & FPGA_DONE) == 0) ? "NOT DONE" : "DONE");
|
||||
DBG ("%s\n",
|
||||
((in32 (GPIO0_IR) & FPGA_INIT) == 0) ? "NOT INIT" : "INIT");
|
||||
|
||||
/*
|
||||
* Check if fpga's DONE signal - correctly booted ?
|
||||
*/
|
||||
|
||||
/* Wait for FPGA end of programming period . */
|
||||
count = 0;
|
||||
while (!(in32 (GPIO0_IR) & FPGA_DONE)) {
|
||||
udelay (1000); /* wait 1ms */
|
||||
/* Check for timeout */
|
||||
if (count++ > 3) {
|
||||
DBG ("FPGA: Booting failed!\n");
|
||||
return ERROR_FPGA_PRG_DONE;
|
||||
}
|
||||
}
|
||||
|
||||
DBG ("FPGA: Booting successful!\n");
|
||||
return 0;
|
||||
}
|
||||
#endif /* 0 */
|
||||
202
board/dave/common/pci.c
Normal file
202
board/dave/common/pci.c
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* (C) Copyright 2001
|
||||
* Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.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
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <ppc4xx.h>
|
||||
#include <asm/processor.h>
|
||||
#include <pci.h>
|
||||
|
||||
|
||||
u_long pci9054_iobase;
|
||||
|
||||
|
||||
#define PCI_PRIMARY_CAR (0x500000dc) /* PCI config address reg */
|
||||
#define PCI_PRIMARY_CDR (0x80000000) /* PCI config data reg */
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------+
|
||||
| Subroutine: pci9054_read_config_dword
|
||||
| Description: Read a PCI configuration register
|
||||
| Inputs:
|
||||
| hose PCI Controller
|
||||
| dev PCI Bus+Device+Function number
|
||||
| offset Configuration register number
|
||||
| value Address of the configuration register value
|
||||
| Return value:
|
||||
| 0 Successful
|
||||
+-----------------------------------------------------------------------------*/
|
||||
int pci9054_read_config_dword(struct pci_controller *hose,
|
||||
pci_dev_t dev, int offset, u32* value)
|
||||
{
|
||||
unsigned long conAdrVal;
|
||||
unsigned long val;
|
||||
|
||||
/* generate coded value for CON_ADR register */
|
||||
conAdrVal = dev | (offset & 0xfc) | 0x80000000;
|
||||
|
||||
/* Load the CON_ADR (CAR) value first, then read from CON_DATA (CDR) */
|
||||
*(unsigned long *)PCI_PRIMARY_CAR = conAdrVal;
|
||||
|
||||
/* Note: *pResult comes back as -1 if machine check happened */
|
||||
val = in32r(PCI_PRIMARY_CDR);
|
||||
|
||||
*value = (unsigned long) val;
|
||||
|
||||
out32r(PCI_PRIMARY_CAR, 0);
|
||||
|
||||
if ((*(unsigned long *)0x50000304) & 0x60000000)
|
||||
{
|
||||
/* clear pci master/target abort bits */
|
||||
*(unsigned long *)0x50000304 = *(unsigned long *)0x50000304;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------+
|
||||
| Subroutine: pci9054_write_config_dword
|
||||
| Description: Write a PCI configuration register.
|
||||
| Inputs:
|
||||
| hose PCI Controller
|
||||
| dev PCI Bus+Device+Function number
|
||||
| offset Configuration register number
|
||||
| Value Configuration register value
|
||||
| Return value:
|
||||
| 0 Successful
|
||||
| Updated for pass2 errata #6. Need to disable interrupts and clear the
|
||||
| PCICFGADR reg after writing the PCICFGDATA reg.
|
||||
+-----------------------------------------------------------------------------*/
|
||||
int pci9054_write_config_dword(struct pci_controller *hose,
|
||||
pci_dev_t dev, int offset, u32 value)
|
||||
{
|
||||
unsigned long conAdrVal;
|
||||
|
||||
conAdrVal = dev | (offset & 0xfc) | 0x80000000;
|
||||
|
||||
*(unsigned long *)PCI_PRIMARY_CAR = conAdrVal;
|
||||
|
||||
out32r(PCI_PRIMARY_CDR, value);
|
||||
|
||||
out32r(PCI_PRIMARY_CAR, 0);
|
||||
|
||||
/* clear pci master/target abort bits */
|
||||
*(unsigned long *)0x50000304 = *(unsigned long *)0x50000304;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_DASA_SIM
|
||||
static void pci_dasa_sim_config_pci9054(struct pci_controller *hose, pci_dev_t dev,
|
||||
struct pci_config_table *_)
|
||||
{
|
||||
unsigned int iobase;
|
||||
unsigned short status = 0;
|
||||
unsigned char timer;
|
||||
|
||||
/*
|
||||
* Configure PLX PCI9054
|
||||
*/
|
||||
pci_read_config_word(CFG_PCI9054_DEV_FN, PCI_COMMAND, &status);
|
||||
status |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
|
||||
pci_write_config_word(CFG_PCI9054_DEV_FN, PCI_COMMAND, status);
|
||||
|
||||
/* Check the latency timer for values >= 0x60.
|
||||
*/
|
||||
pci_read_config_byte(CFG_PCI9054_DEV_FN, PCI_LATENCY_TIMER, &timer);
|
||||
if (timer < 0x60)
|
||||
{
|
||||
pci_write_config_byte(CFG_PCI9054_DEV_FN, PCI_LATENCY_TIMER, 0x60);
|
||||
}
|
||||
|
||||
/* Set I/O base register.
|
||||
*/
|
||||
pci_write_config_dword(CFG_PCI9054_DEV_FN, PCI_BASE_ADDRESS_0, CFG_PCI9054_IOBASE);
|
||||
pci_read_config_dword(CFG_PCI9054_DEV_FN, PCI_BASE_ADDRESS_0, &iobase);
|
||||
|
||||
pci9054_iobase = pci_mem_to_phys(CFG_PCI9054_DEV_FN, iobase & PCI_BASE_ADDRESS_MEM_MASK);
|
||||
|
||||
if (pci9054_iobase == 0xffffffff)
|
||||
{
|
||||
printf("Error: Can not set I/O base register.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct pci_config_table pci9054_config_table[] = {
|
||||
#ifndef CONFIG_PCI_PNP
|
||||
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
||||
PCI_BUS(CFG_ETH_DEV_FN), PCI_DEV(CFG_ETH_DEV_FN), PCI_FUNC(CFG_ETH_DEV_FN),
|
||||
pci_cfgfunc_config_device, { CFG_ETH_IOBASE,
|
||||
CFG_ETH_IOBASE,
|
||||
PCI_COMMAND_IO | PCI_COMMAND_MASTER }},
|
||||
#ifdef CONFIG_DASA_SIM
|
||||
{ PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
|
||||
PCI_BUS(CFG_PCI9054_DEV_FN), PCI_DEV(CFG_PCI9054_DEV_FN), PCI_FUNC(CFG_PCI9054_DEV_FN),
|
||||
pci_dasa_sim_config_pci9054 },
|
||||
#endif
|
||||
#endif
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct pci_controller pci9054_hose = {
|
||||
config_table: pci9054_config_table,
|
||||
};
|
||||
|
||||
void pci_init(void)
|
||||
{
|
||||
struct pci_controller *hose = &pci9054_hose;
|
||||
|
||||
/*
|
||||
* Register the hose
|
||||
*/
|
||||
hose->first_busno = 0;
|
||||
hose->last_busno = 0xff;
|
||||
|
||||
/* System memory space */
|
||||
pci_set_region(hose->regions + 0,
|
||||
0x00000000, 0x00000000, 0x01000000,
|
||||
PCI_REGION_MEM | PCI_REGION_MEMORY);
|
||||
|
||||
/* PCI Memory space */
|
||||
pci_set_region(hose->regions + 1,
|
||||
0x00000000, 0xc0000000, 0x10000000,
|
||||
PCI_REGION_MEM);
|
||||
|
||||
pci_set_ops(hose,
|
||||
pci_hose_read_config_byte_via_dword,
|
||||
pci_hose_read_config_word_via_dword,
|
||||
pci9054_read_config_dword,
|
||||
pci_hose_write_config_byte_via_dword,
|
||||
pci_hose_write_config_word_via_dword,
|
||||
pci9054_write_config_dword);
|
||||
|
||||
hose->region_count = 2;
|
||||
|
||||
pci_register_hose(hose);
|
||||
|
||||
hose->last_busno = pci_hose_scan(hose);
|
||||
}
|
||||
@@ -239,15 +239,11 @@ int testdram (void)
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
|
||||
#include <linux/mtd/nand.h>
|
||||
extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
|
||||
|
||||
void nand_init(void)
|
||||
{
|
||||
nand_probe(CFG_NAND_BASE);
|
||||
if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
|
||||
puts("NAND: ");
|
||||
print_size(nand_dev_desc[0].totlen, "\n");
|
||||
}
|
||||
unsigned long totlen = nand_probe(CFG_NAND_BASE);
|
||||
|
||||
printf ("%4lu MB\n", totlen >> 20);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -237,7 +237,7 @@ int board_pre_init (void)
|
||||
* on-board sram on the eval board, and updates the correct
|
||||
* registers to boot from the sram. (device0)
|
||||
*/
|
||||
#ifdef CONFIG_ZUMA_V2
|
||||
#if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4)
|
||||
/* Zuma has no SRAM */
|
||||
sram_boot = 0;
|
||||
#else
|
||||
@@ -265,6 +265,7 @@ int board_pre_init (void)
|
||||
GT_REG_WRITE(DEVICE_BANK2PARAMETERS, CFG_DEV2_PAR);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EVB64260
|
||||
#ifdef CFG_32BIT_BOOT_PAR
|
||||
/* detect if we are booting from the 32 bit flash */
|
||||
if (GTREGREAD(DEVICE_BOOT_BANK_PARAMETERS) & (0x3 << 20)) {
|
||||
@@ -280,6 +281,11 @@ int board_pre_init (void)
|
||||
/* 8 bit boot flash only */
|
||||
GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CFG_8BIT_BOOT_PAR);
|
||||
#endif
|
||||
#else /* CONFIG_EVB64260 not defined */
|
||||
/* We are booting from 16-bit flash.
|
||||
*/
|
||||
GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CFG_16BIT_BOOT_PAR);
|
||||
#endif
|
||||
|
||||
gt_cpu_config();
|
||||
|
||||
@@ -351,7 +357,7 @@ checkboard (void)
|
||||
void
|
||||
debug_led(int led, int mode)
|
||||
{
|
||||
#ifndef CONFIG_ZUMA_V2
|
||||
#if !defined(CONFIG_ZUMA_V2) && !defined(CONFIG_P3G4)
|
||||
volatile int *addr = NULL;
|
||||
int dummy;
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
|
||||
static ulong flash_get_size (int portwidth, vu_long *addr, flash_info_t *info);
|
||||
static int write_word (flash_info_t *info, ulong dest, ulong data);
|
||||
static void flash_get_offsets (ulong base, flash_info_t *info);
|
||||
static flash_info_t *flash_get_info(ulong base);
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
@@ -72,7 +73,11 @@ flash_init (void)
|
||||
|
||||
/* the boot flash */
|
||||
base = CFG_FLASH_BASE;
|
||||
size_b0 = flash_get_size(1, (vu_long *)base, &flash_info[0]);
|
||||
#ifndef CFG_BOOT_FLASH_WIDTH
|
||||
#define CFG_BOOT_FLASH_WIDTH 1
|
||||
#endif
|
||||
size_b0 = flash_get_size(CFG_BOOT_FLASH_WIDTH, (vu_long *)base,
|
||||
&flash_info[0]);
|
||||
|
||||
printf("[%ldkB@%lx] ", size_b0/1024, base);
|
||||
|
||||
@@ -98,6 +103,22 @@ flash_init (void)
|
||||
base+=size;
|
||||
}
|
||||
|
||||
#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_get_info(CFG_MONITOR_BASE));
|
||||
#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_get_info(CFG_ENV_ADDR));
|
||||
#endif
|
||||
|
||||
flash_size = size_b0 + size_b1;
|
||||
return flash_size;
|
||||
}
|
||||
@@ -146,6 +167,23 @@ flash_get_offsets (ulong base, flash_info_t *info)
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static flash_info_t *flash_get_info(ulong base)
|
||||
{
|
||||
int i;
|
||||
flash_info_t * info;
|
||||
|
||||
for (i = 0; i < CFG_MAX_FLASH_BANKS; i ++) {
|
||||
info = & flash_info[i];
|
||||
if (info->start[0] <= base && base <= info->start[0] + info->size - 1)
|
||||
break;
|
||||
}
|
||||
|
||||
return i == CFG_MAX_FLASH_BANKS ? 0 : info;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
@@ -247,8 +285,11 @@ static inline void flash_cmd(int width, volatile unsigned char *addr, int offset
|
||||
/* 2x16 */
|
||||
unsigned long cmd32=(cmd<<16)|cmd;
|
||||
*(volatile unsigned long *)(addr+offset*2)=cmd32;
|
||||
} else if (width == 2) {
|
||||
/* 1x16 */
|
||||
*(volatile unsigned short *)((unsigned short*)addr+offset)=cmd;
|
||||
} else {
|
||||
/* 1x16 or 1x8 */
|
||||
/* 1x8 */
|
||||
*(volatile unsigned char *)(addr+offset)=cmd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ mpsc_init(int baud)
|
||||
|
||||
/* BRG CONFIG */
|
||||
galbrg_set_baudrate(CHANNEL, baud);
|
||||
#ifdef CONFIG_ZUMA_V2
|
||||
#if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4)
|
||||
galbrg_set_clksrc(CHANNEL,0x8); /* connect TCLK -> BRG */
|
||||
#else
|
||||
galbrg_set_clksrc(CHANNEL,0);
|
||||
@@ -387,7 +387,7 @@ galbrg_set_baudrate(int channel, int rate)
|
||||
|
||||
galbrg_disable(channel);
|
||||
|
||||
#ifdef CONFIG_ZUMA_V2
|
||||
#if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4)
|
||||
/* from tclk */
|
||||
clock = (CFG_BUS_HZ/(16*rate)) - 1;
|
||||
#else
|
||||
@@ -803,6 +803,7 @@ static int
|
||||
galmpsc_shutdown(int mpsc)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
#if 0
|
||||
unsigned int temp;
|
||||
|
||||
/* cause RX abort (clears RX) */
|
||||
@@ -810,9 +811,11 @@ galmpsc_shutdown(int mpsc)
|
||||
temp |= MPSC_RX_ABORT | MPSC_TX_ABORT;
|
||||
temp &= ~MPSC_ENTER_HUNT;
|
||||
GT_REG_WRITE_MIRROR(GALMPSC_CHANNELREG_2,mpsc,GALMPSC_REG_GAP,temp);
|
||||
#endif
|
||||
|
||||
GT_REG_WRITE(GALSDMA_0_COM_REG, 0);
|
||||
GT_REG_WRITE(GALSDMA_0_COM_REG, SDMA_TX_ABORT | SDMA_RX_ABORT);
|
||||
GT_REG_WRITE(GALSDMA_0_COM_REG + CHANNEL * GALSDMA_REG_DIFF, 0);
|
||||
GT_REG_WRITE(GALSDMA_0_COM_REG + CHANNEL * GALSDMA_REG_DIFF,
|
||||
SDMA_TX_ABORT | SDMA_RX_ABORT);
|
||||
|
||||
/* shut down the MPSC */
|
||||
GT_REG_WRITE(GALMPSC_MCONF_LOW, 0);
|
||||
@@ -823,14 +826,15 @@ galmpsc_shutdown(int mpsc)
|
||||
|
||||
/* shut down the sdma engines. */
|
||||
/* reset config to default */
|
||||
GT_REG_WRITE(GALSDMA_0_CONF_REG, 0x000000fc);
|
||||
GT_REG_WRITE(GALSDMA_0_CONF_REG + CHANNEL * GALSDMA_REG_DIFF,
|
||||
0x000000fc);
|
||||
|
||||
udelay(100);
|
||||
|
||||
/* clear the SDMA current and first TX and RX pointers */
|
||||
GT_REG_WRITE(GALSDMA_0_CUR_RX_PTR, 0);
|
||||
GT_REG_WRITE(GALSDMA_0_CUR_TX_PTR, 0);
|
||||
GT_REG_WRITE(GALSDMA_0_FIR_TX_PTR, 0);
|
||||
GT_REG_WRITE(GALSDMA_0_CUR_RX_PTR + CHANNEL * GALSDMA_REG_DIFF, 0);
|
||||
GT_REG_WRITE(GALSDMA_0_CUR_TX_PTR + CHANNEL * GALSDMA_REG_DIFF, 0);
|
||||
GT_REG_WRITE(GALSDMA_0_FIR_TX_PTR + CHANNEL * GALSDMA_REG_DIFF, 0);
|
||||
|
||||
udelay(100);
|
||||
|
||||
|
||||
@@ -175,7 +175,30 @@ check_dimm(uchar slot, sdram_info_t *info)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* ! CONFIG_ZUMA_V2 */
|
||||
#elif defined(CONFIG_P3G4)
|
||||
|
||||
static int
|
||||
check_dimm(uchar slot, sdram_info_t *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
|
||||
if (slot)
|
||||
return 0;
|
||||
|
||||
info->slot = slot;
|
||||
info->banks = 1;
|
||||
info->registered = 0;
|
||||
info->drb_size = 4;
|
||||
info->tpar = 3;
|
||||
info->tras_clocks = 6;
|
||||
info->burst_len = 4;
|
||||
#ifdef CONFIG_ECC
|
||||
info->ecc = 2;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* ! CONFIG_ZUMA_V2 && ! CONFIG_P3G4*/
|
||||
|
||||
/* This code reads the SPD chip on the sdram and populates
|
||||
* the array which is passed in with the relevant information */
|
||||
|
||||
@@ -64,24 +64,20 @@ unsigned long flash_init (void)
|
||||
unsigned long size = 0;
|
||||
int i;
|
||||
extern void flash_preinit(void);
|
||||
extern void flash_afterinit(ulong);
|
||||
ulong flashbase = CFG_FLASH_BASE;
|
||||
|
||||
flash_preinit();
|
||||
|
||||
/* Init: no FLASHes known */
|
||||
for (i=0; i < CFG_MAX_FLASH_BANKS; ++i) {
|
||||
ulong flashbase = CFG_FLASH_BASE;
|
||||
|
||||
memset(&flash_info[i], 0, sizeof(flash_info_t));
|
||||
|
||||
flash_info[i].size =
|
||||
flash_get_size((FPW *)flashbase, &flash_info[i]);
|
||||
|
||||
if (flash_info[i].flash_id == FLASH_UNKNOWN) {
|
||||
printf ("## Unknown FLASH on Bank %d - Size = 0x%08lx\n",
|
||||
i, flash_info[i].size);
|
||||
}
|
||||
|
||||
size += flash_info[i].size;
|
||||
flashbase += 0x800000;
|
||||
}
|
||||
#if CFG_MONITOR_BASE >= CFG_FLASH_BASE
|
||||
/* monitor protection ON by default */
|
||||
@@ -100,6 +96,7 @@ unsigned long flash_init (void)
|
||||
#endif
|
||||
|
||||
|
||||
flash_afterinit(size);
|
||||
return size ? size : 1;
|
||||
}
|
||||
|
||||
@@ -126,7 +123,8 @@ static flash_info_t *flash_get_info(ulong base)
|
||||
|
||||
for (i = 0; i < CFG_MAX_FLASH_BANKS; i ++) {
|
||||
info = & flash_info[i];
|
||||
if (info->start[0] <= base && base <= info->start[0] + info->size - 1)
|
||||
if (info->size &&
|
||||
info->start[0] <= base && base <= info->start[0] + info->size - 1)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -211,6 +209,8 @@ void flash_print_info (flash_info_t *info)
|
||||
ulong flash_get_size (FPWV *addr, flash_info_t *info)
|
||||
{
|
||||
int i;
|
||||
FPWV* addr2;
|
||||
|
||||
/* Write auto select command: read Manufacturer ID */
|
||||
/* Write auto select command sequence and test FLASH answer */
|
||||
addr[FLASH_CYCLE1] = (FPW)0x00AA00AA; /* for AMD, Intel ignores this */
|
||||
@@ -256,6 +256,17 @@ ulong flash_get_size (FPWV *addr, flash_info_t *info)
|
||||
return (0); /* => no or unknown flash */
|
||||
}
|
||||
|
||||
/* test for real flash at bank 1 */
|
||||
addr2 = (FPW *)((ulong)addr | 0x800000);
|
||||
if (addr2 != addr &&
|
||||
((addr2[0] & 0xff) == (addr[0] & 0xff)) && ((FPW)addr2[1] == (FPW)addr[1])) {
|
||||
/* Seems 2 banks are the same space (8Mb chip is installed,
|
||||
* J24 in default position (CS0)). Disable this (first) bank.
|
||||
*/
|
||||
info->flash_id = FLASH_UNKNOWN;
|
||||
info->sector_count = 0;
|
||||
info->size = 0;
|
||||
}
|
||||
/* Put FLASH back in read mode */
|
||||
flash_reset(info);
|
||||
|
||||
|
||||
@@ -171,6 +171,16 @@ void flash_preinit(void)
|
||||
*(vu_long *)MPC5XXX_BOOTCS_CFG &= ~0x1; /* clear RO */
|
||||
}
|
||||
|
||||
void flash_afterinit(ulong size)
|
||||
{
|
||||
if (size == 0x800000) { /* adjust mapping */
|
||||
*(vu_long *)MPC5XXX_BOOTCS_START = *(vu_long *)MPC5XXX_CS0_START =
|
||||
START_REG(CFG_BOOTCS_START | size);
|
||||
*(vu_long *)MPC5XXX_BOOTCS_STOP = *(vu_long *)MPC5XXX_CS0_STOP =
|
||||
STOP_REG(CFG_BOOTCS_START | size, size);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
static struct pci_controller hose;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <common.h>
|
||||
#include <ioports.h>
|
||||
#include <mpc8260.h>
|
||||
#include <asm/m8260_pci.h>
|
||||
#include <i2c.h>
|
||||
#include <spd.h>
|
||||
#include <miiphy.h>
|
||||
@@ -237,6 +238,9 @@ int board_pre_init (void)
|
||||
|
||||
long int initdram (int board_type)
|
||||
{
|
||||
#if CONFIG_ADSTYPE == CFG_PQ2FADS
|
||||
vu_long *bcsr = (vu_long *)CFG_BCSR;
|
||||
#endif
|
||||
volatile immap_t *immap = (immap_t *) CFG_IMMR;
|
||||
volatile memctl8260_t *memctl = &immap->im_memctl;
|
||||
volatile uchar *ramaddr, c = 0xff;
|
||||
@@ -252,27 +256,41 @@ long int initdram (int board_type)
|
||||
immap->im_siu_conf.sc_ppc_alrh = 0x01267893;
|
||||
immap->im_siu_conf.sc_tescr1 = 0x00004000;
|
||||
|
||||
#if CONFIG_ADSTYPE == CFG_PQ2FADS
|
||||
if ((bcsr[3] & BCSR_PCI_MODE) == 0) { /* PCI mode selected by JP9 */
|
||||
immap->im_clkrst.car_sccr |= M826X_SCCR_PCI_MODE_EN;
|
||||
immap->im_siu_conf.sc_siumcr =
|
||||
(immap->im_siu_conf.sc_siumcr & ~SIUMCR_LBPC11)
|
||||
| SIUMCR_LBPC01;
|
||||
}
|
||||
#endif /* CONFIG_ADSTYPE == CFG_PQ2FADS */
|
||||
|
||||
memctl->memc_mptpr = CFG_MPTPR;
|
||||
#ifdef CFG_LSDRAM_BASE
|
||||
/* Init local bus SDRAM */
|
||||
memctl->memc_lsrt = CFG_LSRT;
|
||||
/*
|
||||
Initialise local bus SDRAM only if the pins
|
||||
are configured as local bus pins and not as PCI.
|
||||
The configuration is determined by the HRCW.
|
||||
*/
|
||||
if ((immap->im_siu_conf.sc_siumcr & SIUMCR_LBPC11) == SIUMCR_LBPC00) {
|
||||
memctl->memc_lsrt = CFG_LSRT;
|
||||
#if CONFIG_ADSTYPE == CFG_PQ2FADS /* CS3 */
|
||||
memctl->memc_or3 = 0xFF803280;
|
||||
memctl->memc_br3 = CFG_LSDRAM_BASE | 0x00001861;
|
||||
memctl->memc_or3 = 0xFF803280;
|
||||
memctl->memc_br3 = CFG_LSDRAM_BASE | 0x00001861;
|
||||
#else /* CS4 */
|
||||
memctl->memc_or4 = 0xFFC01480;
|
||||
memctl->memc_br4 = CFG_LSDRAM_BASE | 0x00001861;
|
||||
memctl->memc_or4 = 0xFFC01480;
|
||||
memctl->memc_br4 = CFG_LSDRAM_BASE | 0x00001861;
|
||||
#endif /* CONFIG_ADSTYPE == CFG_PQ2FADS */
|
||||
memctl->memc_lsdmr = CFG_LSDMR | 0x28000000;
|
||||
ramaddr = (uchar *) CFG_LSDRAM_BASE;
|
||||
*ramaddr = c;
|
||||
memctl->memc_lsdmr = CFG_LSDMR | 0x08000000;
|
||||
for (i = 0; i < 8; i++) {
|
||||
memctl->memc_lsdmr = CFG_LSDMR | 0x28000000;
|
||||
ramaddr = (uchar *) CFG_LSDRAM_BASE;
|
||||
*ramaddr = c;
|
||||
memctl->memc_lsdmr = CFG_LSDMR | 0x08000000;
|
||||
for (i = 0; i < 8; i++)
|
||||
*ramaddr = c;
|
||||
memctl->memc_lsdmr = CFG_LSDMR | 0x18000000;
|
||||
*ramaddr = c;
|
||||
memctl->memc_lsdmr = CFG_LSDMR | 0x40000000;
|
||||
}
|
||||
memctl->memc_lsdmr = CFG_LSDMR | 0x18000000;
|
||||
*ramaddr = c;
|
||||
memctl->memc_lsdmr = CFG_LSDMR | 0x40000000;
|
||||
#endif /* CFG_LSDRAM_BASE */
|
||||
|
||||
/* Init 60x bus SDRAM */
|
||||
|
||||
@@ -375,138 +375,6 @@ void show_stdio_dev(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* switches the cs0 and the cs1 to the locations.
|
||||
When boot is TRUE, the the mapping is switched
|
||||
to the boot configuration, If it is FALSE, the
|
||||
flash will be switched in the boot area */
|
||||
|
||||
#undef SW_CS_DBG
|
||||
#ifdef SW_CS_DBG
|
||||
#define SW_CS_PRINTF(fmt,args...) printf (fmt ,##args)
|
||||
#else
|
||||
#define SW_CS_PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
|
||||
int switch_cs(unsigned char boot)
|
||||
{
|
||||
unsigned long pbcr;
|
||||
int mode;
|
||||
|
||||
mode=get_boot_mode();
|
||||
mtdcr(ebccfga, pb0cr);
|
||||
pbcr = mfdcr (ebccfgd);
|
||||
if (mode & BOOT_MPS) {
|
||||
/* Boot width = 8 bit MPS Boot, set up MPS on CS0 */
|
||||
/* we need only to switch if boot from MPS */
|
||||
/* printf(" MPS boot mode detected. ");*/
|
||||
/* printf("cs0 cfg: %lx\n",pbcr); */
|
||||
if(boot) {
|
||||
/* switch to boot configuration */
|
||||
/* this is a 8bit boot, switch cs0 to flash location */
|
||||
SW_CS_PRINTF("switch to boot mode (MPS on High address\n");
|
||||
pbcr&=0x000FFFFF; /*mask base address of the cs0 */
|
||||
pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
|
||||
mtdcr(ebccfga, pb0cr);
|
||||
mtdcr(ebccfgd, pbcr);
|
||||
SW_CS_PRINTF(" new cs0 cfg: %lx\n",pbcr);
|
||||
mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
|
||||
pbcr = mfdcr(ebccfgd);
|
||||
SW_CS_PRINTF(" old cs1 cfg: %lx\n",pbcr);
|
||||
pbcr&=0x000FFFFF; /*mask base address of the cs1 */
|
||||
pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
|
||||
mtdcr(ebccfga, pb1cr);
|
||||
mtdcr(ebccfgd, pbcr);
|
||||
SW_CS_PRINTF(" new cs1 cfg: %lx, MPS is on High Address\n",pbcr);
|
||||
}
|
||||
else {
|
||||
/* map flash to boot area, */
|
||||
SW_CS_PRINTF("map Flash to boot area\n");
|
||||
pbcr&=0x000FFFFF; /*mask base address of the cs0 */
|
||||
pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
|
||||
mtdcr(ebccfga, pb0cr);
|
||||
mtdcr(ebccfgd, pbcr);
|
||||
SW_CS_PRINTF(" new cs0 cfg: %lx\n",pbcr);
|
||||
mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
|
||||
pbcr = mfdcr(ebccfgd);
|
||||
SW_CS_PRINTF(" cs1 cfg: %lx\n",pbcr);
|
||||
pbcr&=0x000FFFFF; /*mask base address of the cs1 */
|
||||
pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
|
||||
mtdcr(ebccfga, pb1cr);
|
||||
mtdcr(ebccfgd, pbcr);
|
||||
SW_CS_PRINTF(" new cs1 cfg: %lx Flash is on High Address\n",pbcr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
SW_CS_PRINTF("Normal boot, no switching necessary\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int get_boot_mode(void)
|
||||
{
|
||||
unsigned long pbcr;
|
||||
int res = 0;
|
||||
pbcr = mfdcr (strap);
|
||||
if ((pbcr & PSR_ROM_WIDTH_MASK) == 0)
|
||||
/* boot via MPS or MPS mapping */
|
||||
res = BOOT_MPS;
|
||||
if(pbcr & PSR_ROM_LOC)
|
||||
/* boot via PCI.. */
|
||||
res |= BOOT_PCI;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Setup cs0 parameter finally.
|
||||
Map the flash high (in boot area)
|
||||
This code can only be executed from SDRAM (after relocation).
|
||||
*/
|
||||
void setup_cs_reloc(void)
|
||||
{
|
||||
unsigned long pbcr;
|
||||
/* Since we are relocated, we can set-up the CS finaly
|
||||
* but first of all, switch off PCI mapping (in case it was a PCI boot) */
|
||||
out32r(PMM0MA,0L);
|
||||
icache_enable (); /* we are relocated */
|
||||
/* for PCI Boot, we have to set-up the remaining CS correctly */
|
||||
pbcr = mfdcr (strap);
|
||||
if(pbcr & PSR_ROM_LOC) {
|
||||
/* boot via PCI.. */
|
||||
if ((pbcr & PSR_ROM_WIDTH_MASK) == 0) {
|
||||
/* Boot width = 8 bit MPS Boot, set up MPS on CS0 */
|
||||
#ifdef DEBUG
|
||||
printf("Mapping MPS to CS0 @ 0x%lx\n",(MPS_CR_B & 0xfff00000));
|
||||
#endif
|
||||
mtdcr (ebccfga, pb0ap);
|
||||
mtdcr (ebccfgd, MPS_AP);
|
||||
mtdcr (ebccfga, pb0cr);
|
||||
mtdcr (ebccfgd, MPS_CR_B);
|
||||
}
|
||||
else {
|
||||
/* Flash boot, set up the Flash on CS0 */
|
||||
#ifdef DEBUG
|
||||
printf("Mapping Flash to CS0 @ 0x%lx\n",(FLASH_CR_B & 0xfff00000));
|
||||
#endif
|
||||
mtdcr (ebccfga, pb0ap);
|
||||
mtdcr (ebccfgd, FLASH_AP);
|
||||
mtdcr (ebccfga, pb0cr);
|
||||
mtdcr (ebccfgd, FLASH_CR_B);
|
||||
}
|
||||
}
|
||||
switch_cs(0); /* map Flash High */
|
||||
}
|
||||
|
||||
|
||||
#elif defined(CONFIG_VCMA9)
|
||||
int switch_cs(unsigned char boot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_VCMA9 */
|
||||
|
||||
int do_mplcommon(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
@@ -625,6 +493,7 @@ void doc_init (void)
|
||||
|
||||
#ifdef CONFIG_CONSOLE_EXTRA_INFO
|
||||
extern GraphicDevice ctfb;
|
||||
extern int get_boot_mode(void);
|
||||
|
||||
void video_get_info_str (int line_number, char *info)
|
||||
{
|
||||
|
||||
@@ -31,10 +31,8 @@ typedef struct {
|
||||
} backup_t;
|
||||
|
||||
void get_backup_values(backup_t *buf);
|
||||
int switch_cs(unsigned char boot);
|
||||
|
||||
#if defined(CONFIG_PIP405) || defined(CONFIG_MIP405)
|
||||
int get_boot_mode(void);
|
||||
void setup_cs_reloc(void);
|
||||
#define BOOT_MPS 0x01
|
||||
#define BOOT_PCI 0x02
|
||||
#endif
|
||||
|
||||
@@ -39,6 +39,13 @@
|
||||
#include <ppc4xx.h>
|
||||
#include <asm/processor.h>
|
||||
#include "common_util.h"
|
||||
#if defined(CONFIG_MIP405)
|
||||
#include "../mip405/mip405.h"
|
||||
#endif
|
||||
#if defined(CONFIG_PIP405)
|
||||
#include "../pip405/pip405.h"
|
||||
#endif
|
||||
#include <405gp_pci.h>
|
||||
|
||||
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
|
||||
/*-----------------------------------------------------------------------
|
||||
@@ -66,23 +73,102 @@ void unlock_intel_sectors(flash_info_t *info,ulong addr,ulong cnt);
|
||||
#define TRUE 1
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Some CS switching routines:
|
||||
*
|
||||
* On PIP/MIP405 we have 3 (4) possible boot mode
|
||||
*
|
||||
* - Boot from Flash (Flash CS = CS0, MPS CS = CS1)
|
||||
* - Boot from MPS (Flash CS = CS1, MPS CS = CS0)
|
||||
* - Boot from PCI with Flash map (Flash CS = CS0, MPS CS = CS1)
|
||||
* - Boot from PCI with MPS map (Flash CS = CS1, MPS CS = CS0)
|
||||
* The flash init is the first board specific routine which is called
|
||||
* after code relocation (running from SDRAM)
|
||||
* The first thing we do is to map the Flash CS to the Flash area and
|
||||
* the MPS CS to the MPS area. Since the flash size is unknown at this
|
||||
* point, we use the max flash size and the lowest flash address as base.
|
||||
*
|
||||
* After flash detection we adjust the size of the CS area accordingly.
|
||||
* The board_init_r will fill in wrong values in the board init structure,
|
||||
* but this will be fixed in the misc_init_r routine:
|
||||
* bd->bi_flashstart=0-flash_info[0].size
|
||||
* bd->bi_flashsize=flash_info[0].size-CFG_MONITOR_LEN
|
||||
* bd->bi_flashoffset=0
|
||||
*
|
||||
*/
|
||||
int get_boot_mode(void)
|
||||
{
|
||||
unsigned long pbcr;
|
||||
int res = 0;
|
||||
pbcr = mfdcr (strap);
|
||||
if ((pbcr & PSR_ROM_WIDTH_MASK) == 0)
|
||||
/* boot via MPS or MPS mapping */
|
||||
res = BOOT_MPS;
|
||||
if(pbcr & PSR_ROM_LOC)
|
||||
/* boot via PCI.. */
|
||||
res |= BOOT_PCI;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Map the flash high (in boot area)
|
||||
This code can only be executed from SDRAM (after relocation).
|
||||
*/
|
||||
void setup_cs_reloc(void)
|
||||
{
|
||||
int mode;
|
||||
/* Since we are relocated, we can set-up the CS finaly
|
||||
* but first of all, switch off PCI mapping (in case it was a PCI boot) */
|
||||
out32r(PMM0MA,0L);
|
||||
icache_enable (); /* we are relocated */
|
||||
/* get boot mode */
|
||||
mode=get_boot_mode();
|
||||
/* we map the flash high in every case */
|
||||
/* first findout on which cs the flash is */
|
||||
if(mode & BOOT_MPS) {
|
||||
/* map flash high on CS1 and MPS on CS0 */
|
||||
mtdcr (ebccfga, pb0ap);
|
||||
mtdcr (ebccfgd, MPS_AP);
|
||||
mtdcr (ebccfga, pb0cr);
|
||||
mtdcr (ebccfgd, MPS_CR);
|
||||
/* we use the default values (max values) for the flash
|
||||
* because its real size is not yet known */
|
||||
mtdcr (ebccfga, pb1ap);
|
||||
mtdcr (ebccfgd, FLASH_AP);
|
||||
mtdcr (ebccfga, pb1cr);
|
||||
mtdcr (ebccfgd, FLASH_CR_B);
|
||||
}
|
||||
else {
|
||||
/* map flash high on CS0 and MPS on CS1 */
|
||||
mtdcr (ebccfga, pb1ap);
|
||||
mtdcr (ebccfgd, MPS_AP);
|
||||
mtdcr (ebccfga, pb1cr);
|
||||
mtdcr (ebccfgd, MPS_CR);
|
||||
/* we use the default values (max values) for the flash
|
||||
* because its real size is not yet known */
|
||||
mtdcr (ebccfga, pb0ap);
|
||||
mtdcr (ebccfgd, FLASH_AP);
|
||||
mtdcr (ebccfga, pb0cr);
|
||||
mtdcr (ebccfgd, FLASH_CR_B);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned long flash_init (void)
|
||||
{
|
||||
unsigned long size_b0, size_b1;
|
||||
int i;
|
||||
unsigned long size_b0, size_b1,flashcr;
|
||||
int mode, i;
|
||||
extern char version_string;
|
||||
char *p=&version_string;
|
||||
|
||||
/* Since we are relocated, we can set-up the CS finally */
|
||||
setup_cs_reloc();
|
||||
/* get and display boot mode */
|
||||
i=get_boot_mode();
|
||||
if(i & BOOT_PCI)
|
||||
printf("(PCI Boot %s Map) ",(i & BOOT_MPS) ?
|
||||
mode=get_boot_mode();
|
||||
if(mode & BOOT_PCI)
|
||||
printf("(PCI Boot %s Map) ",(mode & BOOT_MPS) ?
|
||||
"MPS" : "Flash");
|
||||
else
|
||||
printf("(%s Boot) ",(i & BOOT_MPS) ?
|
||||
printf("(%s Boot) ",(mode & BOOT_MPS) ?
|
||||
"MPS" : "Flash");
|
||||
/* Init: no FLASHes known */
|
||||
for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
|
||||
@@ -91,7 +177,7 @@ unsigned long flash_init (void)
|
||||
|
||||
/* Static FLASH Bank configuration here - FIXME XXX */
|
||||
|
||||
size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
|
||||
size_b0 = flash_get_size((vu_long *)CFG_MONITOR_BASE, &flash_info[0]);
|
||||
|
||||
if (flash_info[0].flash_id == FLASH_UNKNOWN) {
|
||||
printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
|
||||
@@ -109,8 +195,31 @@ unsigned long flash_init (void)
|
||||
flash_info[0].protect[flash_info[0].sector_count-1] = 1;
|
||||
size_b1 = 0 ;
|
||||
flash_info[0].size = size_b0;
|
||||
/* set up flash cs according to the size */
|
||||
if(mode & BOOT_MPS) {
|
||||
/* flash is on CS1 */
|
||||
mtdcr(ebccfga, pb1cr);
|
||||
flashcr = mfdcr (ebccfgd);
|
||||
/* we map the flash high in every case */
|
||||
flashcr&=0x0001FFFF; /* mask out address bits */
|
||||
flashcr|= ((0-flash_info[0].size) & 0xFFF00000); /* start addr */
|
||||
flashcr|= (((flash_info[0].size >>21) & 0x07) << 17); /* size addr */
|
||||
mtdcr(ebccfga, pb1cr);
|
||||
mtdcr(ebccfgd, flashcr);
|
||||
}
|
||||
else {
|
||||
/* flash is on CS0 */
|
||||
mtdcr(ebccfga, pb0cr);
|
||||
flashcr = mfdcr (ebccfgd);
|
||||
/* we map the flash high in every case */
|
||||
flashcr&=0x0001FFFF; /* mask out address bits */
|
||||
flashcr|= ((0-flash_info[0].size) & 0xFFF00000); /* start addr */
|
||||
flashcr|= (((flash_info[0].size >>21) & 0x07) << 17); /* size addr */
|
||||
mtdcr(ebccfga, pb0cr);
|
||||
mtdcr(ebccfgd, flashcr);
|
||||
}
|
||||
#if 0
|
||||
/* include this if you want to test if
|
||||
/* enable this if you want to test if
|
||||
the relocation has be done ok.
|
||||
This will disable both Chipselects */
|
||||
mtdcr (ebccfga, pb0cr);
|
||||
@@ -119,6 +228,14 @@ unsigned long flash_init (void)
|
||||
mtdcr (ebccfgd, 0L);
|
||||
printf("CS0 & CS1 switched off for test\n");
|
||||
#endif
|
||||
/* patch version_string */
|
||||
for(i=0;i<0x100;i++) {
|
||||
if(*p=='\n') {
|
||||
*p=0;
|
||||
break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return (size_b0);
|
||||
}
|
||||
|
||||
@@ -171,6 +288,8 @@ void flash_print_info (flash_info_t *info)
|
||||
break;
|
||||
case FLASH_INTEL320T: printf ("TE28F320C3 (32 Mbit, top sector size)\n");
|
||||
break;
|
||||
case FLASH_AM640U: printf ("AM29LV640U (64 Mbit, uniform sector size)\n");
|
||||
break;
|
||||
default: printf ("Unknown Chip Type\n");
|
||||
break;
|
||||
}
|
||||
@@ -211,7 +330,8 @@ void flash_print_info (flash_info_t *info)
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following code cannot be run from FLASH!
|
||||
@@ -220,7 +340,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
{
|
||||
short i;
|
||||
FLASH_WORD_SIZE value;
|
||||
ulong base = (ulong)addr;
|
||||
ulong base;
|
||||
volatile FLASH_WORD_SIZE *addr2 = (FLASH_WORD_SIZE *)addr;
|
||||
|
||||
/* Write auto select command: read Manufacturer ID */
|
||||
@@ -250,7 +370,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
return (0); /* no or unknown flash */
|
||||
}
|
||||
value = addr2[1]; /* device ID */
|
||||
/* printf("Device value %x\n",value); */
|
||||
/* printf("Device value %x\n",value); */
|
||||
switch (value) {
|
||||
case (FLASH_WORD_SIZE)AMD_ID_F040B:
|
||||
info->flash_id += FLASH_AM040;
|
||||
@@ -292,12 +412,17 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
info->sector_count = 35;
|
||||
info->size = 0x00200000;
|
||||
break; /* => 2 MB */
|
||||
#if 0 /* enable when device IDs are available */
|
||||
case (FLASH_WORD_SIZE)AMD_ID_LV320T:
|
||||
info->flash_id += FLASH_AM320T;
|
||||
info->sector_count = 67;
|
||||
info->size = 0x00400000;
|
||||
break; /* => 4 MB */
|
||||
case (FLASH_WORD_SIZE)AMD_ID_LV640U:
|
||||
info->flash_id += FLASH_AM640U;
|
||||
info->sector_count = 128;
|
||||
info->size = 0x00800000;
|
||||
break; /* => 8 MB */
|
||||
#if 0 /* enable when device IDs are available */
|
||||
|
||||
case (FLASH_WORD_SIZE)AMD_ID_LV320B:
|
||||
info->flash_id += FLASH_AM320B;
|
||||
@@ -328,10 +453,12 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
|
||||
return (0); /* => no or unknown flash */
|
||||
|
||||
}
|
||||
|
||||
/* base address calculation */
|
||||
base=0-info->size;
|
||||
/* set up sector start address table */
|
||||
if (((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_SST) ||
|
||||
(info->flash_id == FLASH_AM040)){
|
||||
(info->flash_id == FLASH_AM040) ||
|
||||
(info->flash_id == FLASH_AM640U)){
|
||||
for (i = 0; i < info->sector_count; i++)
|
||||
info->start[i] = base + (i * 0x00010000);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "kbd.h"
|
||||
#include "video.h"
|
||||
|
||||
extern int drv_isa_kbd_init (void);
|
||||
|
||||
#undef ISA_DEBUG
|
||||
|
||||
@@ -49,6 +48,9 @@ extern int drv_isa_kbd_init (void);
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PIP405)
|
||||
|
||||
extern int drv_isa_kbd_init (void);
|
||||
|
||||
/* fdc (logical device 0) */
|
||||
const SIO_LOGDEV_TABLE sio_fdc[] = {
|
||||
@@ -183,7 +185,7 @@ void isa_sio_setup(void)
|
||||
close_cfg_super_IO(0x3F0);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* IRQ Controller
|
||||
@@ -202,7 +204,7 @@ static struct isa_irq_action isa_irqs[16];
|
||||
/*
|
||||
* This contains the irq mask for both 8259A irq controllers,
|
||||
*/
|
||||
static unsigned int cached_irq_mask = 0xffff;
|
||||
static unsigned int cached_irq_mask = 0xfff9;
|
||||
|
||||
#define cached_imr1 (unsigned char)cached_irq_mask
|
||||
#define cached_imr2 (unsigned char)(cached_irq_mask>>8)
|
||||
@@ -387,19 +389,22 @@ int handle_isa_int(void)
|
||||
isr2=in8(ISR_2);
|
||||
isr1=in8(ISR_1);
|
||||
irq=(unsigned char)irqack;
|
||||
if((irq==7)&&((isr1&0x80)==0)) {
|
||||
irq-=32;
|
||||
/* if((irq==7)&&((isr1&0x80)==0)) {
|
||||
PRINTF("IRQ7 detected but not in ISR\n");
|
||||
}
|
||||
else {
|
||||
/* we should handle cascaded interrupts here also */
|
||||
/* printf("ISA Irq %d\n",irq); */
|
||||
isa_irqs[irq].count++;
|
||||
if (isa_irqs[irq].handler != NULL)
|
||||
(*isa_irqs[irq].handler)(isa_irqs[irq].arg); /* call isr */
|
||||
else
|
||||
*/ /* we should handle cascaded interrupts here also */
|
||||
{
|
||||
PRINTF ("bogus interrupt vector 0x%x\n", irq);
|
||||
}
|
||||
/* printf("ISA Irq %d\n",irq); */
|
||||
isa_irqs[irq].count++;
|
||||
if(irq!=2) { /* just swallow the cascade irq 2 */
|
||||
if (isa_irqs[irq].handler != NULL)
|
||||
(*isa_irqs[irq].handler)(isa_irqs[irq].arg); /* call isr */
|
||||
else {
|
||||
PRINTF ("bogus interrupt vector 0x%x\n", irq);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* issue EOI instruction to clear the IRQ */
|
||||
mask_and_ack_8259A(irq);
|
||||
@@ -413,13 +418,13 @@ int handle_isa_int(void)
|
||||
|
||||
void isa_irq_install_handler(int vec, interrupt_handler_t *handler, void *arg)
|
||||
{
|
||||
if (isa_irqs[vec].handler != NULL) {
|
||||
printf ("ISA Interrupt vector %d: handler 0x%x replacing 0x%x\n",
|
||||
vec, (uint)handler, (uint)isa_irqs[vec].handler);
|
||||
}
|
||||
isa_irqs[vec].handler = handler;
|
||||
isa_irqs[vec].arg = arg;
|
||||
enable_8259A_irq(vec);
|
||||
if (isa_irqs[vec].handler != NULL) {
|
||||
printf ("ISA Interrupt vector %d: handler 0x%x replacing 0x%x\n",
|
||||
vec, (uint)handler, (uint)isa_irqs[vec].handler);
|
||||
}
|
||||
isa_irqs[vec].handler = handler;
|
||||
isa_irqs[vec].arg = arg;
|
||||
enable_8259A_irq(vec);
|
||||
PRINTF ("Install ISA IRQ %d ==> %p, @ %p mask=%04x\n", vec, handler, &isa_irqs[vec].handler,cached_irq_mask);
|
||||
|
||||
}
|
||||
@@ -427,9 +432,9 @@ void isa_irq_install_handler(int vec, interrupt_handler_t *handler, void *arg)
|
||||
void isa_irq_free_handler(int vec)
|
||||
{
|
||||
disable_8259A_irq(vec);
|
||||
isa_irqs[vec].handler = NULL;
|
||||
isa_irqs[vec].arg = NULL;
|
||||
printf ("Free ISA IRQ %d mask=%04x\n", vec, cached_irq_mask);
|
||||
isa_irqs[vec].handler = NULL;
|
||||
isa_irqs[vec].arg = NULL;
|
||||
PRINTF ("Free ISA IRQ %d mask=%04x\n", vec, cached_irq_mask);
|
||||
|
||||
}
|
||||
|
||||
@@ -448,16 +453,42 @@ void isa_init_irq_contr(void)
|
||||
init_8259A();
|
||||
out8(IMR_2,0xFF);
|
||||
}
|
||||
/*************************************************************************/
|
||||
|
||||
void isa_show_irq(void)
|
||||
{
|
||||
int vec;
|
||||
|
||||
printf ("\nISA Interrupt-Information:\n");
|
||||
printf ("Nr Routine Arg Count\n");
|
||||
|
||||
for (vec=0; vec<16; vec++) {
|
||||
if (isa_irqs[vec].handler != NULL) {
|
||||
printf ("%02d %08lx %08lx %d\n",
|
||||
vec,
|
||||
(ulong)isa_irqs[vec].handler,
|
||||
(ulong)isa_irqs[vec].arg,
|
||||
isa_irqs[vec].count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int isa_irq_get_count(int vec)
|
||||
{
|
||||
return(isa_irqs[vec].count);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* Init the ISA bus and devices.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_PIP405)
|
||||
|
||||
int isa_init(void)
|
||||
{
|
||||
isa_sio_setup();
|
||||
isa_init_irq_contr();
|
||||
drv_isa_kbd_init();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _PIP405_ISA_H_
|
||||
#define _PIP405_ISA_H_
|
||||
#ifndef _ISA_H_
|
||||
#define _ISA_H_
|
||||
/* Super IO */
|
||||
#define SIO_CFG_PORT 0x3F0 /* Config Port Address */
|
||||
|
||||
|
||||
#if defined(CONFIG_PIP405)
|
||||
/* table fore SIO initialization */
|
||||
typedef struct {
|
||||
const uchar index;
|
||||
@@ -44,10 +44,14 @@ unsigned char read_cfg_super_IO(int address, unsigned char function, unsigned ch
|
||||
void write_cfg_super_IO(int address, unsigned char function, unsigned char regaddr, unsigned char data);
|
||||
void close_cfg_super_IO(int address);
|
||||
void isa_sio_setup(void);
|
||||
void isa_sio_setup(void);
|
||||
#endif
|
||||
|
||||
void isa_irq_install_handler(int vec, interrupt_handler_t *handler, void *arg);
|
||||
void isa_irq_free_handler(int vec);
|
||||
int handle_isa_int(void);
|
||||
void isa_init_irq_contr(void);
|
||||
void isa_show_irq(void);
|
||||
int isa_irq_get_count(int vec);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -92,7 +92,7 @@ extern void pci_pip405_write_regs(struct pci_controller *,
|
||||
/* PIIX4 ISA Bridge Function 0 */
|
||||
static struct pci_pip405_config_entry piix4_isa_bridge_f0[] = {
|
||||
{PCI_CFG_PIIX4_SERIRQ, 0xD0, 1}, /* enable Continous SERIRQ Pin */
|
||||
{PCI_CFG_PIIX4_GENCFG, 0x00010041, 4}, /* enable SERIRQs, ISA, PNP */
|
||||
{PCI_CFG_PIIX4_GENCFG, 0x00018041, 4}, /* enable SERIRQs, ISA, PNP, GPI11 */
|
||||
{PCI_CFG_PIIX4_TOM, 0xFE, 1}, /* Top of Memory */
|
||||
{PCI_CFG_PIIX4_XBCS, 0x02C4, 2}, /* disable all peri CS */
|
||||
{PCI_CFG_PIIX4_RTCCFG, 0x21, 1}, /* enable RTC */
|
||||
@@ -106,6 +106,7 @@ 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_CFG_PIIX4_BMIBA, 0x0001000, 4}, /* set BMI to a valid address */
|
||||
{PCI_COMMAND, 0x0001, 2}, /* enable IO access */
|
||||
#if !defined(CONFIG_MIP405T)
|
||||
{PCI_CFG_PIIX4_IDETIM, 0x80008000, 4}, /* enable Both IDE channels */
|
||||
@@ -129,10 +130,10 @@ static struct pci_pip405_config_entry piix4_usb_cntrl_f2[] = {
|
||||
|
||||
/* PIIX4 Power Management Function 3 */
|
||||
static struct pci_pip405_config_entry piix4_pmm_cntrl_f3[] = {
|
||||
{PCI_COMMAND, 0x0001, 2}, /* enable IO access */
|
||||
{PCI_CFG_PIIX4_PMAB, 0x00004000, 4}, /* set PMBA to "valid" value */
|
||||
{PCI_CFG_PIIX4_PMMISC, 0x01, 1}, /* enable PMBA IO access */
|
||||
{PCI_CFG_PIIX4_PMBA, 0x00004000, 4}, /* set PMBA to "valid" value */
|
||||
{PCI_CFG_PIIX4_SMBBA, 0x00005000, 4}, /* set SMBBA to "valid" value */
|
||||
{PCI_CFG_PIIX4_PMMISC, 0x01, 1}, /* enable PMBA IO access */
|
||||
{PCI_COMMAND, 0x0001, 2}, /* enable IO access */
|
||||
{ } /* end of device table */
|
||||
};
|
||||
/* PPC405 Dummy only used to prevent autosetup on this host bridge */
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
#define PCI_CFG_PIIX4_LEGSUP 0xC0
|
||||
|
||||
/* Function 3 Power Management */
|
||||
#define PCI_CFG_PIIX4_PMAB 0x40
|
||||
#define PCI_CFG_PIIX4_PMBA 0x40
|
||||
#define PCI_CFG_PIIX4_CNTA 0x44
|
||||
#define PCI_CFG_PIIX4_CNTB 0x48
|
||||
#define PCI_CFG_PIIX4_GPICTL 0x4C
|
||||
|
||||
@@ -54,10 +54,13 @@ int do_mip405(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
return (do_mplcommon(cmdtp, flag, argc, argv));
|
||||
}
|
||||
U_BOOT_CMD(
|
||||
mip405, 6, 1, do_mip405,
|
||||
mip405, 8, 1, do_mip405,
|
||||
"mip405 - MIP405 specific Cmds\n",
|
||||
"flash mem [SrcAddr] - updates U-Boot with image in memory\n"
|
||||
"mip405 flash mps - updates U-Boot with image from MPS\n"
|
||||
"mip405 info - displays board information\n"
|
||||
"mip405 led <on> - switches LED on (on=1) or off (on=0)\n"
|
||||
"mip405 mem [cnt] - Memory Test <cnt>-times, <cnt> = -1 loop forever\n"
|
||||
);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@@ -87,19 +87,15 @@ ext_bus_cntlr_init:
|
||||
mfdcr r4,ebccfgd
|
||||
|
||||
andi. r0, r4, 0x2000 /* mask out irrelevant bits */
|
||||
beq 0f /* jump if 8 bit bus width */
|
||||
beq 0f /* jump if 8 bit bus width */
|
||||
|
||||
/* setup 16 bit things (Flash Boot)
|
||||
/* setup 16 bit things
|
||||
*-----------------------------------------------------------------------
|
||||
* Memory Bank 0 (16 Bit Flash) initialization
|
||||
*---------------------------------------------------------------------- */
|
||||
|
||||
addi r4,0,pb0ap
|
||||
mtdcr ebccfga,r4
|
||||
/* addis r4,0,0xFF8F */
|
||||
/* ori r4,r4,0xFE80 */
|
||||
/* addis r4,0,0x9B01 */
|
||||
/* ori r4,r4,0x5480 */
|
||||
addis r4,0,(FLASH_AP_B)@h
|
||||
ori r4,r4,(FLASH_AP_B)@l
|
||||
mtdcr ebccfgd,r4
|
||||
@@ -107,8 +103,6 @@ ext_bus_cntlr_init:
|
||||
addi r4,0,pb0cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x010(4MB),BU=0x3(R/W), */
|
||||
/* addis r4,0,((FLASH_BASE0_PRELIM & 0xFFF00000) | 0x00050000)@h */
|
||||
/* ori r4,r4,0xA000 / * BW=0x01(16 bits) */
|
||||
addis r4,0,(FLASH_CR_B)@h
|
||||
ori r4,r4,(FLASH_CR_B)@l
|
||||
mtdcr ebccfgd,r4
|
||||
@@ -123,21 +117,13 @@ ext_bus_cntlr_init:
|
||||
/* 0x7F8FFE80 slowest boot */
|
||||
addi r4,0,pb0ap
|
||||
mtdcr ebccfga,r4
|
||||
#if 0
|
||||
addis r4,0,0x9B01
|
||||
ori r4,r4,0x5480
|
||||
#else
|
||||
addis r4,0,(MPS_AP_B)@h
|
||||
ori r4,r4,(MPS_AP_B)@l
|
||||
#endif
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb0cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x010(4MB),BU=0x3(R/W), */
|
||||
/* addis r4,0,((FLASH_BASE0_PRELIM & 0xFFF00000) | 0x00050000)@h */
|
||||
/* ori r4,r4,0x8000 / * BW=0x0( 8 bits) */
|
||||
|
||||
addis r4,0,(MPS_CR_B)@h
|
||||
ori r4,r4,(MPS_CR_B)@l
|
||||
|
||||
@@ -178,18 +164,18 @@ ext_bus_cntlr_init:
|
||||
ori r4,r4,0x0000
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb6cr
|
||||
addi r4,0,pb6cr
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x0000
|
||||
ori r4,r4,0x0000
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb7cr
|
||||
addi r4,0,pb7cr
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x0000
|
||||
ori r4,r4,0x0000
|
||||
mtdcr ebccfgd,r4
|
||||
nop /* pass2 DCR errata #8 */
|
||||
nop /* pass2 DCR errata #8 */
|
||||
blr
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
|
||||
@@ -667,9 +667,16 @@ static int test_dram (unsigned long ramsize)
|
||||
/* used to check if the time in RTC is valid */
|
||||
static unsigned long start;
|
||||
static struct rtc_time tm;
|
||||
extern flash_info_t flash_info[]; /* info for FLASH chips */
|
||||
|
||||
int misc_init_r (void)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
/* adjust flash start and size as well as the offset */
|
||||
gd->bd->bi_flashstart=0-flash_info[0].size;
|
||||
gd->bd->bi_flashsize=flash_info[0].size-CFG_MONITOR_LEN;
|
||||
gd->bd->bi_flashoffset=0;
|
||||
|
||||
/* check, if RTC is running */
|
||||
rtc_get (&tm);
|
||||
start=get_timer(0);
|
||||
|
||||
@@ -137,13 +137,13 @@ void user_led0(unsigned char on);
|
||||
(FLASH_WBF << 12) + (FLASH_TH << 9) + (FLASH_RE << 8) + (FLASH_SOR << 7) + (FLASH_BEM << 6) + (FLASH_PEN << 5))
|
||||
|
||||
/* Size: 0=1MB, 1=2MB, 2=4MB, 3=8MB, 4=16MB, 5=32MB, 6=64MB, 7=128MB */
|
||||
#define FLASH_BS 2 /* 4 MByte */
|
||||
#define FLASH_BS FLASH_SIZE_PRELIM /* 4 MByte */
|
||||
/* Usage: 0=disabled, 1=Read only, 2=Write Only, 3=R/W */
|
||||
#define FLASH_BU 3 /* R/W */
|
||||
/* Bus width: 0=8Bit, 1=16Bit, 2=32Bit, 3=Reserved */
|
||||
#define FLASH_BW 1 /* 16Bit */
|
||||
/* CR register for Boot */
|
||||
#define FLASH_CR_B ((FLASH_BASE0_PRELIM & 0xfff00000) + (FLASH_BS << 17) + (FLASH_BU << 15) + (FLASH_BW << 13))
|
||||
#define FLASH_CR_B ((FLASH_BASE_PRELIM & 0xfff00000) + (FLASH_BS << 17) + (FLASH_BU << 15) + (FLASH_BW << 13))
|
||||
/* CR register for non Boot */
|
||||
#define FLASH_CR ((MULTI_PURPOSE_SOCKET_ADDR & 0xfff00000) + (FLASH_BS << 17) + (FLASH_BU << 15) + (FLASH_BW << 13))
|
||||
|
||||
@@ -172,11 +172,12 @@ void user_led0(unsigned char on);
|
||||
|
||||
/* Size: 0=1MB, 1=2MB, 2=4MB, 3=8MB, 4=16MB, 5=32MB, 6=64MB, 7=128MB */
|
||||
#define MPS_BS 2 /* 4 MByte */
|
||||
#define MPS_BS_B FLASH_SIZE_PRELIM /* 1 MByte */
|
||||
/* Usage: 0=disabled, 1=Read only, 2=Write Only, 3=R/W */
|
||||
#define MPS_BU 3 /* R/W */
|
||||
/* Bus width: 0=8Bit, 1=16Bit, 2=32Bit, 3=Reserved */
|
||||
#define MPS_BW 0 /* 8Bit */
|
||||
/* CR register for Boot */
|
||||
#define MPS_CR_B ((FLASH_BASE0_PRELIM & 0xfff00000) + (MPS_BS << 17) + (MPS_BU << 15) + (MPS_BW << 13))
|
||||
#define MPS_CR_B ((FLASH_BASE_PRELIM & 0xfff00000) + (MPS_BS_B << 17) + (MPS_BU << 15) + (MPS_BW << 13))
|
||||
/* CR register for non Boot */
|
||||
#define MPS_CR ((MULTI_PURPOSE_SOCKET_ADDR & 0xfff00000) + (MPS_BS << 17) + (MPS_BU << 15) + (MPS_BW << 13))
|
||||
|
||||
@@ -41,17 +41,21 @@
|
||||
|
||||
#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
|
||||
|
||||
#include "configs/PIP405.h"
|
||||
#include <configs/PIP405.h>
|
||||
#include <ppc_asm.tmpl>
|
||||
#include <ppc_defs.h>
|
||||
|
||||
#include <asm/cache.h>
|
||||
#include <asm/mmu.h>
|
||||
#include "pip405.h"
|
||||
|
||||
.globl ext_bus_cntlr_init
|
||||
ext_bus_cntlr_init:
|
||||
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 */
|
||||
|
||||
.globl ext_bus_cntlr_init
|
||||
ext_bus_cntlr_init:
|
||||
mflr r4 /* save link register */
|
||||
bl ..getAddr
|
||||
..getAddr:
|
||||
mflr r3 /* get address of ..getAddr */
|
||||
@@ -82,7 +86,7 @@ ext_bus_cntlr_init:
|
||||
mfdcr r4,ebccfgd
|
||||
|
||||
andi. r0, r4, 0x2000 /* mask out irrelevant bits */
|
||||
beq 0f /* jump if 8 bit bus width */
|
||||
beq 0f /* jump if 8 bit bus width */
|
||||
|
||||
/* setup 16 bit things
|
||||
*-----------------------------------------------------------------------
|
||||
@@ -90,74 +94,49 @@ ext_bus_cntlr_init:
|
||||
*---------------------------------------------------------------------- */
|
||||
|
||||
addi r4,0,pb0ap
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x9B01
|
||||
ori r4,r4,0x5480
|
||||
mtdcr ebccfgd,r4
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,(FLASH_AP_B)@h
|
||||
ori r4,r4,(FLASH_AP_B)@l
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb0cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x011(8MB),BU=0x3(R/W), */
|
||||
addis r4,0,((FLASH_BASE0_PRELIM & 0xFFF00000) | 0x00050000)@h
|
||||
ori r4,r4,0xA000 /* BW=0x01(16 bits) */
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Memory Bank 1 (Multi Purpose Socket) initialization
|
||||
*----------------------------------------------------------------------*/
|
||||
addi r4,0,pb1ap
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x0281
|
||||
ori r4,r4,0x5480
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb1cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x011(8MB),BU=0x3(R/W), */
|
||||
addis r4,0,((MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000) | 0x00050000)@h
|
||||
ori r4,r4,0x8000 /* BW=0x0( 8 bits) */
|
||||
mtdcr ebccfgd,r4
|
||||
addi r4,0,pb0cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x010(4MB),BU=0x3(R/W), */
|
||||
addis r4,0,(FLASH_CR_B)@h
|
||||
ori r4,r4,(FLASH_CR_B)@l
|
||||
mtdcr ebccfgd,r4
|
||||
b 1f
|
||||
|
||||
0:
|
||||
/* 8Bit boot mode: */
|
||||
/* 8Bit boot mode: */
|
||||
/*-----------------------------------------------------------------------
|
||||
* Memory Bank 0 Multi Purpose Socket initialization
|
||||
*----------------------------------------------------------------------- */
|
||||
|
||||
* Memory Bank 0 Multi Purpose Socket initialization
|
||||
*----------------------------------------------------------------------- */
|
||||
/* 0x7F8FFE80 slowest boot */
|
||||
addi r4,0,pb0ap
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x9B01
|
||||
ori r4,r4,0x5480
|
||||
mtdcr ebccfgd,r4
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,(MPS_AP_B)@h
|
||||
ori r4,r4,(MPS_AP_B)@l
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb0cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x011(4MB),BU=0x3(R/W), */
|
||||
addis r4,0,((FLASH_BASE0_PRELIM & 0xFFF00000) | 0x00050000)@h
|
||||
ori r4,r4,0x8000 /* BW=0x0( 8 bits) */
|
||||
mtdcr ebccfgd,r4
|
||||
addi r4,0,pb0cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x010(4MB),BU=0x3(R/W), */
|
||||
addis r4,0,(MPS_CR_B)@h
|
||||
ori r4,r4,(MPS_CR_B)@l
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Memory Bank 1 (Flash) initialization
|
||||
*-----------------------------------------------------------------------*/
|
||||
addi r4,0,pb1ap
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x0281
|
||||
ori r4,r4,0x5480
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb1cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x011(8MB),BU=0x3(R/W), */
|
||||
addis r4,0,((MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000) | 0x00050000)@h
|
||||
ori r4,r4,0xA000 /* BW=0x0( 8 bits) */
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
1:
|
||||
/*-----------------------------------------------------------------------
|
||||
* Memory Bank 2-3-4-5-6 (not used) initialization
|
||||
*-----------------------------------------------------------------------*/
|
||||
addi r4,0,pb1cr
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x0000
|
||||
ori r4,r4,0x0000
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb2cr
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x0000
|
||||
@@ -182,28 +161,18 @@ ext_bus_cntlr_init:
|
||||
ori r4,r4,0x0000
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb6cr
|
||||
addi r4,0,pb6cr
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x0000
|
||||
ori r4,r4,0x0000
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Memory Bank 7 (Config Register) initialization
|
||||
*----------------------------------------------------------------------- */
|
||||
addi r4,0,pb7ap
|
||||
mtdcr ebccfga,r4
|
||||
addis r4,0,0x0181 /* Doc says TWT=3 and Openios TWT=3!! */
|
||||
ori r4,r4,0x5280 /* disable Ready, BEM=0 */
|
||||
mtdcr ebccfgd,r4
|
||||
|
||||
addi r4,0,pb7cr
|
||||
mtdcr ebccfga,r4
|
||||
/* BS=0x0(1MB),BU=0x3(R/W), */
|
||||
addis r4,0,((CONFIG_PORT_ADDR & 0xFFF00000) | 0x00010000)@h
|
||||
ori r4,r4,0x8000 /* BW=0x0(8 bits) */
|
||||
addis r4,0,0x0000
|
||||
ori r4,r4,0x0000
|
||||
mtdcr ebccfgd,r4
|
||||
nop /* pass2 DCR errata #8 */
|
||||
nop /* pass2 DCR errata #8 */
|
||||
blr
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
@@ -217,3 +186,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
|
||||
|
||||
@@ -194,6 +194,11 @@ int board_pre_init (void)
|
||||
#ifdef SDRAM_DEBUG
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
#endif
|
||||
/* set up the config port */
|
||||
mtdcr (ebccfga, pb7ap);
|
||||
mtdcr (ebccfgd, CONFIG_PORT_AP);
|
||||
mtdcr (ebccfga, pb7cr);
|
||||
mtdcr (ebccfgd, CONFIG_PORT_CR);
|
||||
|
||||
memclk = get_bus_freq (tmemclk);
|
||||
tmemclk = 1000000000 / (memclk / 100); /* in 10 ps units */
|
||||
@@ -657,8 +662,20 @@ static int test_dram (unsigned long ramsize)
|
||||
}
|
||||
|
||||
|
||||
extern flash_info_t flash_info[]; /* info for FLASH chips */
|
||||
|
||||
int misc_init_r (void)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
/* adjust flash start and size as well as the offset */
|
||||
gd->bd->bi_flashstart=0-flash_info[0].size;
|
||||
gd->bd->bi_flashsize=flash_info[0].size-CFG_MONITOR_LEN;
|
||||
gd->bd->bi_flashoffset=0;
|
||||
|
||||
/* if PIP405 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
* Global routines used for PIP405
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
extern int mem_test(unsigned long start, unsigned long ramsize,int mode);
|
||||
|
||||
@@ -35,13 +36,13 @@ void user_led1(unsigned char on);
|
||||
|
||||
|
||||
#define PLD_BASE_ADDRESS CFG_ISA_IO_BASE_ADDRESS + 0x800
|
||||
#define PLD_PART_REG PLD_BASE_ADDRESS + 0
|
||||
#define PLD_VERS_REG PLD_BASE_ADDRESS + 1
|
||||
#define PLD_PART_REG PLD_BASE_ADDRESS + 0
|
||||
#define PLD_VERS_REG PLD_BASE_ADDRESS + 1
|
||||
#define PLD_BOARD_CFG_REG PLD_BASE_ADDRESS + 2
|
||||
#define PLD_LED_USER_REG PLD_BASE_ADDRESS + 3
|
||||
#define PLD_SYS_MAN_REG PLD_BASE_ADDRESS + 4
|
||||
#define PLD_FLASH_COM_REG PLD_BASE_ADDRESS + 5
|
||||
#define PLD_CAN_REG PLD_BASE_ADDRESS + 6
|
||||
#define PLD_CAN_REG PLD_BASE_ADDRESS + 6
|
||||
#define PLD_SER_PWR_REG PLD_BASE_ADDRESS + 7
|
||||
#define PLD_COM_PWR_REG PLD_BASE_ADDRESS + 8
|
||||
#define PLD_NIC_VGA_REG PLD_BASE_ADDRESS + 9
|
||||
@@ -50,86 +51,32 @@ void user_led1(unsigned char on);
|
||||
#define PIIX4_VENDOR_ID 0x8086
|
||||
#define PIIX4_IDE_DEV_ID 0x7111
|
||||
|
||||
|
||||
/* timings */
|
||||
/* PLD (CS7) */
|
||||
#define PLD_BME 0 /* Burst disable */
|
||||
#define PLD_TWE 5 /* 5 * 30ns 120ns Waitstates (access=TWT+1+TH) */
|
||||
#define PLD_CSN 1 /* Chipselect is driven inactive for 1 Cycle BTW transfers */
|
||||
#define PLD_OEN 1 /* Cycles from CS low to OE low */
|
||||
#define PLD_WBN 1 /* Cycles from CS low to WE low */
|
||||
#define PLD_WBF 1 /* Cycles from WE high to CS high */
|
||||
#define PLD_TH 2 /* Number of hold cycles after transfer */
|
||||
#define PLD_RE 0 /* Ready disabled */
|
||||
#define PLD_SOR 1 /* Sample on Ready disabled */
|
||||
#define PLD_BEM 0 /* Byte Write only active on Write cycles */
|
||||
#define PLD_PEN 0 /* Parity disable */
|
||||
#define PLD_AP ((PLD_BME << 31) + (PLD_TWE << 23) + (PLD_CSN << 18) + (PLD_OEN << 16) + (PLD_WBN << 14) + \
|
||||
(PLD_WBF << 12) + (PLD_TH << 9) + (PLD_RE << 8) + (PLD_SOR << 7) + (PLD_BEM << 6) + (PLD_PEN << 5))
|
||||
|
||||
/* Size: 0=1MB, 1=2MB, 2=4MB, 3=8MB, 4=16MB, 5=32MB, 6=64MB, 7=128MB */
|
||||
#define PLD_BS 0 /* 1 MByte */
|
||||
/* Usage: 0=disabled, 1=Read only, 2=Write Only, 3=R/W */
|
||||
#define PLD_BU 3 /* R/W */
|
||||
/* Bus width: 0=8Bit, 1=16Bit, 2=32Bit, 3=Reserved */
|
||||
#define PLD_BW 0 /* 16Bit */
|
||||
#define PLD_CR ((PER_PLD_ADDR & 0xfff00000) + (PLD_BS << 17) + (PLD_BU << 15) + (PLD_BW << 13))
|
||||
|
||||
#endif
|
||||
|
||||
/* timings */
|
||||
|
||||
#define PER_BOARD_ADDR (PER_UART1_ADDR+(1024*1024))
|
||||
/* Dummy CS to get the board revision */
|
||||
#define BOARD_BME 0 /* Burst disable */
|
||||
#define BOARD_TWE 255 /* 255 * 30ns 120ns Waitstates (access=TWT+1+TH) */
|
||||
#define BOARD_CSN 1 /* Chipselect is driven inactive for 1 Cycle BTW transfers */
|
||||
#define BOARD_OEN 1 /* Cycles from CS low to OE low */
|
||||
#define BOARD_WBN 1 /* Cycles from CS low to WE low */
|
||||
#define BOARD_WBF 1 /* Cycles from WE high to CS high */
|
||||
#define BOARD_TH 2 /* Number of hold cycles after transfer */
|
||||
#define BOARD_RE 0 /* Ready disabled */
|
||||
#define BOARD_SOR 1 /* Sample on Ready disabled */
|
||||
#define BOARD_BEM 0 /* Byte Write only active on Write cycles */
|
||||
#define BOARD_PEN 0 /* Parity disable */
|
||||
#define BOARD_AP ((BOARD_BME << 31) + (BOARD_TWE << 23) + (BOARD_CSN << 18) + (BOARD_OEN << 16) + (BOARD_WBN << 14) + \
|
||||
(BOARD_WBF << 12) + (BOARD_TH << 9) + (BOARD_RE << 8) + (BOARD_SOR << 7) + (BOARD_BEM << 6) + (BOARD_PEN << 5))
|
||||
/* CS Config register (CS7) */
|
||||
#define CONFIG_PORT_BME 0 /* Burst disable */
|
||||
#define CONFIG_PORT_TWE 255 /* 255 * 30ns 120ns Waitstates (access=TWT+1+TH) */
|
||||
#define CONFIG_PORT_CSN 1 /* Chipselect is driven inactive for 1 Cycle BTW transfers */
|
||||
#define CONFIG_PORT_OEN 1 /* Cycles from CS low to OE low */
|
||||
#define CONFIG_PORT_WBN 1 /* Cycles from CS low to WE low */
|
||||
#define CONFIG_PORT_WBF 1 /* Cycles from WE high to CS high */
|
||||
#define CONFIG_PORT_TH 2 /* Number of hold cycles after transfer */
|
||||
#define CONFIG_PORT_RE 0 /* Ready disabled */
|
||||
#define CONFIG_PORT_SOR 1 /* Sample on Ready disabled */
|
||||
#define CONFIG_PORT_BEM 0 /* Byte Write only active on Write cycles */
|
||||
#define CONFIG_PORT_PEN 0 /* Parity disable */
|
||||
#define CONFIG_PORT_AP ((CONFIG_PORT_BME << 31) + (CONFIG_PORT_TWE << 23) + (CONFIG_PORT_CSN << 18) + (CONFIG_PORT_OEN << 16) + (CONFIG_PORT_WBN << 14) + \
|
||||
(CONFIG_PORT_WBF << 12) + (CONFIG_PORT_TH << 9) + (CONFIG_PORT_RE << 8) + (CONFIG_PORT_SOR << 7) + (CONFIG_PORT_BEM << 6) + (CONFIG_PORT_PEN << 5))
|
||||
|
||||
/* Size: 0=1MB, 1=2MB, 2=4MB, 3=8MB, 4=16MB, 5=32MB, 6=64MB, 7=128MB */
|
||||
#define BOARD_BS 0 /* 1 MByte */
|
||||
#define CONFIG_PORT_BS 0 /* 1 MByte */
|
||||
/* Usage: 0=disabled, 1=Read only, 2=Write Only, 3=R/W */
|
||||
#define BOARD_BU 3 /* R/W */
|
||||
#define CONFIG_PORT_BU 3 /* R/W */
|
||||
/* Bus width: 0=8Bit, 1=16Bit, 2=32Bit, 3=Reserved */
|
||||
#define BOARD_BW 0 /* 16Bit */
|
||||
#define BOARD_CR ((PER_BOARD_ADDR & 0xfff00000) + (BOARD_BS << 17) + (BOARD_BU << 15) + (BOARD_BW << 13))
|
||||
|
||||
|
||||
/* UART0 CS2 */
|
||||
#define UART0_BME 0 /* Burst disable */
|
||||
#define UART0_TWE 7 /* 7 * 30ns 210ns Waitstates (access=TWT+1+TH) */
|
||||
#define UART0_CSN 1 /* Chipselect is driven inactive for 1 Cycle BTW transfers */
|
||||
#define UART0_OEN 1 /* Cycles from CS low to OE low */
|
||||
#define UART0_WBN 1 /* Cycles from CS low to WE low */
|
||||
#define UART0_WBF 1 /* Cycles from WE high to CS high */
|
||||
#define UART0_TH 2 /* Number of hold cycles after transfer */
|
||||
#define UART0_RE 0 /* Ready disabled */
|
||||
#define UART0_SOR 1 /* Sample on Ready disabled */
|
||||
#define UART0_BEM 0 /* Byte Write only active on Write cycles */
|
||||
#define UART0_PEN 0 /* Parity disable */
|
||||
#define UART0_AP ((UART0_BME << 31) + (UART0_TWE << 23) + (UART0_CSN << 18) + (UART0_OEN << 16) + (UART0_WBN << 14) + \
|
||||
(UART0_WBF << 12) + (UART0_TH << 9) + (UART0_RE << 8) + (UART0_SOR << 7) + (UART0_BEM << 6) + (UART0_PEN << 5))
|
||||
|
||||
/* Size: 0=1MB, 1=2MB, 2=4MB, 3=8MB, 4=16MB, 5=32MB, 6=64MB, 7=128MB */
|
||||
#define UART0_BS 0 /* 1 MByte */
|
||||
/* Usage: 0=disabled, 1=Read only, 2=Write Only, 3=R/W */
|
||||
#define UART0_BU 3 /* R/W */
|
||||
/* Bus width: 0=8Bit, 1=16Bit, 2=32Bit, 3=Reserved */
|
||||
#define UART0_BW 0 /* 8Bit */
|
||||
#define UART0_CR ((PER_UART0_ADDR & 0xfff00000) + (UART0_BS << 17) + (UART0_BU << 15) + (UART0_BW << 13))
|
||||
|
||||
/* UART1 CS3 */
|
||||
#define UART1_AP UART0_AP /* same timing as UART0 */
|
||||
#define UART1_CR ((PER_UART1_ADDR & 0xfff00000) + (UART0_BS << 17) + (UART0_BU << 15) + (UART0_BW << 13))
|
||||
|
||||
#define CONFIG_PORT_BW 0 /* 16Bit */
|
||||
#define CONFIG_PORT_CR ((CONFIG_PORT_ADDR & 0xfff00000) + (CONFIG_PORT_BS << 17) + (CONFIG_PORT_BU << 15) + (CONFIG_PORT_BW << 13))
|
||||
|
||||
/* Flash CS0 or CS 1 */
|
||||
/* 0x7F8FFE80 slowest timing at all... */
|
||||
@@ -149,19 +96,19 @@ void user_led1(unsigned char on);
|
||||
#define FLASH_PEN 0 /* Parity disable */
|
||||
/* Access Parameter Register for non Boot */
|
||||
#define FLASH_AP ((FLASH_BME << 31) + (FLASH_TWE << 23) + (FLASH_CSN << 18) + (FLASH_OEN << 16) + (FLASH_WBN << 14) + \
|
||||
(FLASH_WBF << 12) + (FLASH_TH << 9) + (FLASH_RE << 8) + (FLASH_SOR << 7) + (FLASH_BEM << 6) + (FLASH_PEN << 5))
|
||||
(FLASH_WBF << 12) + (FLASH_TH << 9) + (FLASH_RE << 8) + (FLASH_SOR << 7) + (FLASH_BEM << 6) + (FLASH_PEN << 5))
|
||||
/* Access Parameter Register for Boot */
|
||||
#define FLASH_AP_B ((FLASH_BME_B << 31) + (FLASH_FWT_B << 26) + (FLASH_BWT_B << 23) + (FLASH_CSN << 18) + (FLASH_OEN << 16) + (FLASH_WBN << 14) + \
|
||||
(FLASH_WBF << 12) + (FLASH_TH << 9) + (FLASH_RE << 8) + (FLASH_SOR << 7) + (FLASH_BEM << 6) + (FLASH_PEN << 5))
|
||||
(FLASH_WBF << 12) + (FLASH_TH << 9) + (FLASH_RE << 8) + (FLASH_SOR << 7) + (FLASH_BEM << 6) + (FLASH_PEN << 5))
|
||||
|
||||
/* Size: 0=1MB, 1=2MB, 2=4MB, 3=8MB, 4=16MB, 5=32MB, 6=64MB, 7=128MB */
|
||||
#define FLASH_BS 2 /* 4 MByte */
|
||||
#define FLASH_BS FLASH_SIZE_PRELIM /* 4 MByte */
|
||||
/* Usage: 0=disabled, 1=Read only, 2=Write Only, 3=R/W */
|
||||
#define FLASH_BU 3 /* R/W */
|
||||
/* Bus width: 0=8Bit, 1=16Bit, 2=32Bit, 3=Reserved */
|
||||
#define FLASH_BW 1 /* 16Bit */
|
||||
/* CR register for Boot */
|
||||
#define FLASH_CR_B ((FLASH_BASE0_PRELIM & 0xfff00000) + (FLASH_BS << 17) + (FLASH_BU << 15) + (FLASH_BW << 13))
|
||||
#define FLASH_CR_B ((FLASH_BASE_PRELIM & 0xfff00000) + (FLASH_BS << 17) + (FLASH_BU << 15) + (FLASH_BW << 13))
|
||||
/* CR register for non Boot */
|
||||
#define FLASH_CR ((MULTI_PURPOSE_SOCKET_ADDR & 0xfff00000) + (FLASH_BS << 17) + (FLASH_BU << 15) + (FLASH_BW << 13))
|
||||
|
||||
@@ -183,18 +130,19 @@ void user_led1(unsigned char on);
|
||||
#define MPS_PEN 0 /* Parity disable */
|
||||
/* Access Parameter Register for non Boot */
|
||||
#define MPS_AP ((MPS_BME << 31) + (MPS_TWE << 23) + (MPS_CSN << 18) + (MPS_OEN << 16) + (MPS_WBN << 14) + \
|
||||
(MPS_WBF << 12) + (MPS_TH << 9) + (MPS_RE << 8) + (MPS_SOR << 7) + (MPS_BEM << 6) + (MPS_PEN << 5))
|
||||
(MPS_WBF << 12) + (MPS_TH << 9) + (MPS_RE << 8) + (MPS_SOR << 7) + (MPS_BEM << 6) + (MPS_PEN << 5))
|
||||
/* Access Parameter Register for Boot */
|
||||
#define MPS_AP_B ((MPS_BME_B << 31) + (MPS_FWT_B << 26) + (MPS_BWT_B << 23) + (MPS_CSN << 18) + (MPS_OEN << 16) + (MPS_WBN << 14) + \
|
||||
(MPS_WBF << 12) + (MPS_TH << 9) + (MPS_RE << 8) + (MPS_SOR << 7) + (MPS_BEM << 6) + (MPS_PEN << 5))
|
||||
#define MPS_AP_B ((MPS_BME_B << 31) + (MPS_FWT_B << 26) + (MPS_BWT_B << 23) + (MPS_CSN << 18) + (MPS_OEN << 16) + (MPS_WBN << 14) + \
|
||||
(MPS_WBF << 12) + (MPS_TH << 9) + (MPS_RE << 8) + (MPS_SOR << 7) + (MPS_BEM << 6) + (MPS_PEN << 5))
|
||||
|
||||
/* Size: 0=1MB, 1=2MB, 2=4MB, 3=8MB, 4=16MB, 5=32MB, 6=64MB, 7=128MB */
|
||||
#define MPS_BS 2 /* 4 MByte */
|
||||
#define MPS_BS_B FLASH_SIZE_PRELIM /* 1 MByte */
|
||||
/* Usage: 0=disabled, 1=Read only, 2=Write Only, 3=R/W */
|
||||
#define MPS_BU 3 /* R/W */
|
||||
/* Bus width: 0=8Bit, 1=16Bit, 2=32Bit, 3=Reserved */
|
||||
#define MPS_BW 0 /* 8Bit */
|
||||
/* CR register for Boot */
|
||||
#define MPS_CR_B ((FLASH_BASE0_PRELIM & 0xfff00000) + (MPS_BS << 17) + (MPS_BU << 15) + (MPS_BW << 13))
|
||||
#define MPS_CR_B ((FLASH_BASE_PRELIM & 0xfff00000) + (MPS_BS << 17) + (MPS_BU << 15) + (MPS_BW << 13))
|
||||
/* CR register for non Boot */
|
||||
#define MPS_CR ((MULTI_PURPOSE_SOCKET_ADDR & 0xfff00000) + (MPS_BS << 17) + (MPS_BU << 15) + (MPS_BW << 13))
|
||||
|
||||
@@ -144,7 +144,7 @@ int dram_init(void)
|
||||
* NAND flash initialization.
|
||||
*/
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
|
||||
extern void
|
||||
extern ulong
|
||||
nand_probe(ulong physadr);
|
||||
|
||||
|
||||
@@ -177,10 +177,15 @@ void
|
||||
nand_init(void)
|
||||
{
|
||||
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
|
||||
unsigned totlen;
|
||||
|
||||
NF_Init();
|
||||
#ifdef DEBUG
|
||||
printf("NAND flash probing at 0x%.8lX\n", (ulong)nand);
|
||||
nand_probe((ulong)nand);
|
||||
#endif
|
||||
totlen = nand_probe((ulong)nand) >> 20;
|
||||
|
||||
printf ("%4lu MB\n", totlen >> 20);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -420,16 +420,13 @@ int board_pre_init(void)
|
||||
|
||||
#include <linux/mtd/nand.h>
|
||||
|
||||
extern void nand_probe(ulong physadr);
|
||||
extern ulong nand_probe(ulong physadr);
|
||||
extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
|
||||
|
||||
void nand_init(void)
|
||||
{
|
||||
nand_probe(CFG_NAND_BASE);
|
||||
if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
|
||||
nand_dev_desc[0].name = "NetVia NAND flash";
|
||||
puts("NAND: ");
|
||||
print_size(nand_dev_desc[0].totlen, "\n");
|
||||
}
|
||||
unsigned long totlen = nand_probe(CFG_NAND_BASE);
|
||||
|
||||
printf ("%4lu MB\n", totlen >> 20);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc8xx.h>
|
||||
/* environment.h defines the various CFG_ENV_... values in terms
|
||||
* of whichever ones are given in the configuration file.
|
||||
*/
|
||||
#include <environment.h>
|
||||
|
||||
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
|
||||
|
||||
@@ -104,6 +108,19 @@ unsigned long flash_init (void)
|
||||
&flash_info[0]);
|
||||
#endif
|
||||
|
||||
#ifdef CFG_ENV_ADDR
|
||||
flash_protect ( FLAG_PROTECT_SET,
|
||||
CFG_ENV_ADDR,
|
||||
CFG_ENV_ADDR + CFG_ENV_SIZE - 1, &flash_info[0]);
|
||||
#endif
|
||||
|
||||
#ifdef CFG_ENV_ADDR_REDUND
|
||||
flash_protect ( FLAG_PROTECT_SET,
|
||||
CFG_ENV_ADDR_REDUND,
|
||||
CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
|
||||
&flash_info[0]);
|
||||
#endif
|
||||
|
||||
return (size_b);
|
||||
}
|
||||
|
||||
@@ -154,6 +171,21 @@ static void flash_get_offsets (ulong base, flash_info_t *info)
|
||||
for( i = 0; i < info->sector_count; i++ )
|
||||
info->start[i] = base + (i * sect_size);
|
||||
}
|
||||
else if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_AMD
|
||||
&& (info->flash_id & FLASH_TYPEMASK) == FLASH_AM800T) {
|
||||
|
||||
int sect_size; /* number of bytes/sector */
|
||||
|
||||
sect_size = 0x00010000 * (sizeof(FPW)/2);
|
||||
|
||||
/* set up sector start address table (top boot sector type) */
|
||||
for (i = 0; i < info->sector_count - 3; i++)
|
||||
info->start[i] = base + (i * sect_size);
|
||||
i = info->sector_count - 1;
|
||||
info->start[i--] = base + (info->size - 0x00004000) * (sizeof(FPW)/2);
|
||||
info->start[i--] = base + (info->size - 0x00006000) * (sizeof(FPW)/2);
|
||||
info->start[i--] = base + (info->size - 0x00008000) * (sizeof(FPW)/2);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
@@ -196,6 +228,9 @@ void flash_print_info (flash_info_t *info)
|
||||
}
|
||||
|
||||
switch (info->flash_id & FLASH_TYPEMASK) {
|
||||
case FLASH_AM800T:
|
||||
fmt = "29LV800B%s (8 Mbit, %s)\n";
|
||||
break;
|
||||
case FLASH_AM640U:
|
||||
fmt = "29LV641D (64 Mbit, uniform sectors)\n";
|
||||
break;
|
||||
@@ -295,6 +330,12 @@ ulong flash_get_size (FPWV *addr, flash_info_t *info)
|
||||
/* Check 16 bits or 32 bits of ID so work on 32 or 16 bit bus. */
|
||||
if (info->flash_id != FLASH_UNKNOWN) switch (addr[1]) {
|
||||
|
||||
case (FPW)AMD_ID_LV800T:
|
||||
info->flash_id += FLASH_AM800T;
|
||||
info->sector_count = 19;
|
||||
info->size = 0x00100000 * (sizeof(FPW)/2);
|
||||
break; /* => 1 or 2 MiB */
|
||||
|
||||
case (FPW)AMD_ID_LV640U: /* 29LV640 and 29LV641 have same ID */
|
||||
info->flash_id += FLASH_AM640U;
|
||||
info->sector_count = 128;
|
||||
@@ -401,6 +442,7 @@ static void flash_sync_real_protect(flash_info_t *info)
|
||||
break;
|
||||
|
||||
case FLASH_AM640U:
|
||||
case FLASH_AM800T:
|
||||
default:
|
||||
/* no hardware protect that we support */
|
||||
break;
|
||||
@@ -438,6 +480,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
|
||||
case FLASH_28F320C3B:
|
||||
case FLASH_28F640C3B:
|
||||
case FLASH_AM640U:
|
||||
case FLASH_AM800T:
|
||||
break;
|
||||
case FLASH_UNKNOWN:
|
||||
default:
|
||||
@@ -735,6 +778,7 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
|
||||
break;
|
||||
|
||||
case FLASH_AM640U:
|
||||
case FLASH_AM800T:
|
||||
default:
|
||||
/* no hardware protect that we support */
|
||||
info->protect[sector] = prot;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <common.h>
|
||||
#include <config.h>
|
||||
#include <jffs2/jffs2.h>
|
||||
#include <mpc8xx.h>
|
||||
#include <net.h> /* for eth_init() */
|
||||
#include <rtc.h>
|
||||
@@ -329,11 +330,9 @@ int misc_init_r (void)
|
||||
#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");
|
||||
}
|
||||
unsigned long totlen = nand_probe(CFG_NAND_BASE);
|
||||
|
||||
printf ("%4lu MB\n", totlen >> 20);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -602,3 +601,70 @@ long int initdram(int board_type)
|
||||
|
||||
return (size_sdram);
|
||||
}
|
||||
|
||||
#ifdef CFG_JFFS_CUSTOM_PART
|
||||
|
||||
static struct part_info part;
|
||||
|
||||
#define jffs2_block(i) \
|
||||
((struct jffs2_unknown_node*)(CFG_JFFS2_BASE + (i) * 65536))
|
||||
|
||||
struct part_info* jffs2_part_info(int part_num)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
bd_t *bd = gd->bd;
|
||||
char* s;
|
||||
int i;
|
||||
int bootnor = 0; /* assume booting from NAND flash */
|
||||
|
||||
if (part_num != 0)
|
||||
return 0; /* only support one partition */
|
||||
|
||||
if (part.usr_priv == (void*)1)
|
||||
return ∂ /* already have part info */
|
||||
|
||||
memset(&part, 0, sizeof(part));
|
||||
|
||||
if (nand_dev_desc[0].ChipID == NAND_ChipID_UNKNOWN)
|
||||
bootnor = 1;
|
||||
else if (bd->bi_flashsize < 0x800000)
|
||||
bootnor = 0;
|
||||
else for (i = 0; !bootnor && i < 4; ++i) {
|
||||
/* boot from NOR if JFFS2 info in any of
|
||||
* first 4 erase blocks
|
||||
*/
|
||||
|
||||
if (jffs2_block(i)->magic == JFFS2_MAGIC_BITMASK)
|
||||
bootnor = 1;
|
||||
}
|
||||
|
||||
if (bootnor) {
|
||||
/* no NAND flash or boot in NOR, use NOR flash */
|
||||
part.offset = (unsigned char *)CFG_JFFS2_BASE;
|
||||
part.size = CFG_JFFS2_SIZE;
|
||||
}
|
||||
else {
|
||||
char readcmd[60];
|
||||
|
||||
/* boot info in NAND flash, get and use copy in RAM */
|
||||
|
||||
/* override info from environment if present */
|
||||
s = getenv("fsaddr");
|
||||
part.offset = s ? (void *)simple_strtoul(s, NULL, 16)
|
||||
: (void *)CFG_JFFS2_RAMBASE;
|
||||
s = getenv("fssize");
|
||||
part.size = s ? simple_strtoul(s, NULL, 16)
|
||||
: CFG_JFFS2_RAMSIZE;
|
||||
|
||||
/* read from nand flash */
|
||||
sprintf(readcmd, "nand read.jffs2 %x 0 %x",
|
||||
(uint32_t)part.offset, part.size);
|
||||
run_command(readcmd, 0);
|
||||
}
|
||||
|
||||
part.erasesize = 0; /* unused */
|
||||
part.usr_priv=(void*)1; /* ready */
|
||||
|
||||
return ∂
|
||||
}
|
||||
#endif /* ifdef CFG_JFFS_CUSTOM_PART */
|
||||
|
||||
@@ -28,3 +28,4 @@
|
||||
TEXT_BASE = 0xFFF00000
|
||||
|
||||
PLATFORM_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
|
||||
PLATFORM_LIBS += $(shell $(CC) -print-libgcc-file-name)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <common.h>
|
||||
#include <mpc824x.h>
|
||||
#include <pci.h>
|
||||
|
||||
int checkboard (void)
|
||||
{
|
||||
@@ -84,3 +85,11 @@ Done:
|
||||
return CFG_MAX_RAM_SIZE;
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct pci_controller hose;
|
||||
|
||||
void pci_init_board(void)
|
||||
{
|
||||
pci_mpc824x_init(&hose);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
|
||||
|
||||
LIB = lib$(BOARD).a
|
||||
|
||||
OBJS := trab.o flash.o vfd.o
|
||||
OBJS := trab.o flash.o vfd.o cmd_trab.o memory.o tsc2000.o
|
||||
SOBJS := memsetup.o
|
||||
|
||||
$(LIB): $(OBJS) $(SOBJS)
|
||||
|
||||
71
board/trab/Pt1000_temp_data.h
Normal file
71
board/trab/Pt1000_temp_data.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Data file for tsc2000 driver.
|
||||
* Copyright (C) 2002, 2003 DENX Software Engineering, Wolfgang Denk, wd@denx.de
|
||||
*/
|
||||
|
||||
#ifndef _PT1000_TEMP_DATA_H
|
||||
#define _PT1000_TEMP_DATA_H
|
||||
|
||||
long Pt1000_temp_table[][2] = {
|
||||
/* For quick range checking the largest element
|
||||
* is placed at index 0.
|
||||
* U, nV T, C*100
|
||||
*/
|
||||
{ 44000000 , 12165 },
|
||||
{ -10000000 , -2644 },
|
||||
{ -9000000 , -2381 },
|
||||
{ -8000000 , -2118 },
|
||||
{ -7000000 , -1855 },
|
||||
{ -6000000 , -1591 },
|
||||
{ -5000000 , -1327 },
|
||||
{ -4000000 , -1063 },
|
||||
{ -3000000 , -798 },
|
||||
{ -2000000 , -532 },
|
||||
{ -1000000 , -266 },
|
||||
{ 0 , 000 },
|
||||
{ 1000000 , 267 },
|
||||
{ 2000000 , 534 },
|
||||
{ 3000000 , 802 },
|
||||
{ 4000000 , 1070 },
|
||||
{ 5000000 , 1338 },
|
||||
{ 6000000 , 1607 },
|
||||
{ 7000000 , 1876 },
|
||||
{ 8000000 , 2146 },
|
||||
{ 9000000 , 2416 },
|
||||
{ 10000000 , 2687 },
|
||||
{ 11000000 , 2958 },
|
||||
{ 12000000 , 3230 },
|
||||
{ 13000000 , 3502 },
|
||||
{ 14000000 , 3774 },
|
||||
{ 15000000 , 4047 },
|
||||
{ 16000000 , 4321 },
|
||||
{ 17000000 , 4595 },
|
||||
{ 18000000 , 4869 },
|
||||
{ 19000000 , 5144 },
|
||||
{ 20000000 , 5419 },
|
||||
{ 21000000 , 5694 },
|
||||
{ 22000000 , 5971 },
|
||||
{ 23000000 , 6247 },
|
||||
{ 24000000 , 6524 },
|
||||
{ 25000000 , 6802 },
|
||||
{ 26000000 , 7080 },
|
||||
{ 27000000 , 7358 },
|
||||
{ 28000000 , 7637 },
|
||||
{ 29000000 , 7916 },
|
||||
{ 30000000 , 8196 },
|
||||
{ 31000000 , 8476 },
|
||||
{ 32000000 , 8757 },
|
||||
{ 33000000 , 9039 },
|
||||
{ 34000000 , 9320 },
|
||||
{ 35000000 , 9602 },
|
||||
{ 36000000 , 9885 },
|
||||
{ 37000000 , 10168 },
|
||||
{ 38000000 , 10452 },
|
||||
{ 39000000 , 10736 },
|
||||
{ 40000000 , 11021 },
|
||||
{ 41000000 , 11306 },
|
||||
{ 42000000 , 11592 },
|
||||
{ 43000000 , 11879 },
|
||||
{ 44000000 , 12165 },
|
||||
};
|
||||
#endif /* _PT1000_TEMP_DATA_H */
|
||||
821
board/trab/cmd_trab.c
Normal file
821
board/trab/cmd_trab.c
Normal file
@@ -0,0 +1,821 @@
|
||||
/*
|
||||
* (C) Copyright 2003
|
||||
* Martin Krause, TQ-Systems GmbH, martin.krause@tqs.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 <command.h>
|
||||
#include <s3c2400.h>
|
||||
|
||||
/*
|
||||
* TRAB board specific commands. Especially commands for burn-in and function
|
||||
* test.
|
||||
*/
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_BSP)
|
||||
|
||||
/* limits for valid range of VCC5V in mV */
|
||||
#define VCC5V_MIN 4500
|
||||
#define VCC5V_MAX 5500
|
||||
|
||||
/*
|
||||
* Test strings for EEPROM test. Length of string 2 must not exceed length of
|
||||
* string 1. Otherwise a buffer overrun could occur!
|
||||
*/
|
||||
#define EEPROM_TEST_STRING_1 "0987654321 :tset a si siht"
|
||||
#define EEPROM_TEST_STRING_2 "this is a test: 1234567890"
|
||||
|
||||
/*
|
||||
* min/max limits for valid contact temperature during burn in test (in
|
||||
* degree Centigrade * 100)
|
||||
*/
|
||||
#define MIN_CONTACT_TEMP -1000
|
||||
#define MAX_CONTACT_TEMP +9000
|
||||
|
||||
/* blinking frequency of status LED */
|
||||
#define LED_BLINK_FREQ 5
|
||||
|
||||
/* delay time between burn in cycles in seconds */
|
||||
#ifndef BURN_IN_CYCLE_DELAY /* if not defined in include/configs/trab.h */
|
||||
#define BURN_IN_CYCLE_DELAY 5
|
||||
#endif
|
||||
|
||||
/* physical SRAM parameters */
|
||||
#define SRAM_ADDR 0x02000000 /* GCS1 */
|
||||
#define SRAM_SIZE 0x40000 /* 256 kByte */
|
||||
|
||||
/* CPLD-Register for controlling TRAB hardware functions */
|
||||
#define CPLD_BUTTONS ((volatile unsigned long *)0x04020000)
|
||||
#define CPLD_FILL_LEVEL ((volatile unsigned long *)0x04008000)
|
||||
#define CPLD_ROTARY_SWITCH ((volatile unsigned long *)0x04018000)
|
||||
#define CPLD_RS485_RE ((volatile unsigned long *)0x04028000)
|
||||
|
||||
/* I2C EEPROM device address */
|
||||
#define I2C_EEPROM_DEV_ADDR 0x54
|
||||
|
||||
/* EEPROM address map */
|
||||
#define EE_ADDR_TEST 128
|
||||
#define EE_ADDR_MAX_CYCLES 256
|
||||
#define EE_ADDR_STATUS 258
|
||||
#define EE_ADDR_PASS_CYCLES 259
|
||||
#define EE_ADDR_FIRST_ERROR_CYCLE 261
|
||||
#define EE_ADDR_FIRST_ERROR_NUM 263
|
||||
#define EE_ADDR_FIRST_ERROR_NAME 264
|
||||
#define EE_ADDR_ACT_CYCLE 280
|
||||
|
||||
/* Bit definitions for ADCCON */
|
||||
#define ADC_ENABLE_START 0x1
|
||||
#define ADC_READ_START 0x2
|
||||
#define ADC_STDBM 0x4
|
||||
#define ADC_INP_AIN0 (0x0 << 3)
|
||||
#define ADC_INP_AIN1 (0x1 << 3)
|
||||
#define ADC_INP_AIN2 (0x2 << 3)
|
||||
#define ADC_INP_AIN3 (0x3 << 3)
|
||||
#define ADC_INP_AIN4 (0x4 << 3)
|
||||
#define ADC_INP_AIN5 (0x5 << 3)
|
||||
#define ADC_INP_AIN6 (0x6 << 3)
|
||||
#define ADC_INP_AIN7 (0x7 << 3)
|
||||
#define ADC_PRSCEN 0x4000
|
||||
#define ADC_ECFLG 0x800
|
||||
|
||||
/* misc */
|
||||
|
||||
/* externals */
|
||||
extern int memory_post_tests (unsigned long start, unsigned long size);
|
||||
extern int i2c_write (uchar, uint, int , uchar* , int);
|
||||
extern int i2c_read (uchar, uint, int , uchar* , int);
|
||||
extern void tsc2000_reg_init (void);
|
||||
extern s32 tsc2000_contact_temp (void);
|
||||
extern void spi_init(void);
|
||||
|
||||
/* function declarations */
|
||||
int do_dip (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
int do_vcc5v (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
int do_burn_in (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
int do_contact_temp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
int do_burn_in_status (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
|
||||
|
||||
/* helper functions */
|
||||
static void adc_init (void);
|
||||
static int adc_read (unsigned int channel);
|
||||
static int read_dip (void);
|
||||
static int read_vcc5v (void);
|
||||
static int test_dip (void);
|
||||
static int test_vcc5v (void);
|
||||
static int test_rotary_switch (void);
|
||||
static int test_sram (void);
|
||||
static int test_eeprom (void);
|
||||
static int test_contact_temp (void);
|
||||
static int i2c_write_multiple (uchar chip, uint addr, int alen,
|
||||
uchar *buffer, int len);
|
||||
static int i2c_read_multiple (uchar chip, uint addr, int alen,
|
||||
uchar *buffer, int len);
|
||||
static void led_set (unsigned int);
|
||||
static void led_blink (void);
|
||||
static void led_init (void);
|
||||
static void sdelay (unsigned long seconds); /* delay in seconds */
|
||||
static int dummy (void);
|
||||
static int read_max_cycles(void);
|
||||
static void test_function_table_init (void);
|
||||
static void global_vars_init (void);
|
||||
static int global_vars_write_to_eeprom (void);
|
||||
|
||||
/* globals */
|
||||
u16 max_cycles;
|
||||
u8 status;
|
||||
u16 pass_cycles;
|
||||
u16 first_error_cycle;
|
||||
u8 first_error_num;
|
||||
unsigned char first_error_name[16];
|
||||
u16 act_cycle;
|
||||
|
||||
typedef struct test_function_s {
|
||||
unsigned char *name;
|
||||
int (*pf)(void);
|
||||
} test_function_t;
|
||||
|
||||
/* max number of Burn In Functions */
|
||||
#define BIF_MAX 6
|
||||
|
||||
/* table with burn in functions */
|
||||
test_function_t test_function[BIF_MAX];
|
||||
|
||||
|
||||
int do_burn_in (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int cycle_status;
|
||||
|
||||
if (argc > 1) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
led_init ();
|
||||
global_vars_init ();
|
||||
test_function_table_init ();
|
||||
|
||||
if (global_vars_write_to_eeprom () != 0) {
|
||||
printf ("%s: error writing global_vars to eeprom\n",
|
||||
__FUNCTION__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (read_max_cycles () != 0) {
|
||||
printf ("%s: error reading max_cycles from eeprom\n",
|
||||
__FUNCTION__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (max_cycles == 0) {
|
||||
printf ("%s: error, burn in max_cycles = 0\n", __FUNCTION__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
status = 0;
|
||||
for (act_cycle = 1; act_cycle <= max_cycles; act_cycle++) {
|
||||
|
||||
cycle_status = 0;
|
||||
for (i = 0; i < BIF_MAX; i++) {
|
||||
|
||||
/* call test function */
|
||||
if ((*test_function[i].pf)() != 0) {
|
||||
printf ("error in %s test\n",
|
||||
test_function[i].name);
|
||||
|
||||
/* is it the first error? */
|
||||
if (status == 0) {
|
||||
status = 1;
|
||||
first_error_cycle = act_cycle;
|
||||
|
||||
/* do not use error_num 0 */
|
||||
first_error_num = i+1;
|
||||
strncpy (first_error_name,
|
||||
test_function[i].name,
|
||||
sizeof (first_error_name));
|
||||
led_set (0);
|
||||
}
|
||||
cycle_status = 1;
|
||||
}
|
||||
}
|
||||
/* were all tests of actual cycle OK? */
|
||||
if (cycle_status == 0)
|
||||
pass_cycles++;
|
||||
|
||||
/* set status LED if no error is occoured since yet */
|
||||
if (status == 0)
|
||||
led_set (1);
|
||||
|
||||
printf ("%s: cycle %d finished\n", __FUNCTION__, act_cycle);
|
||||
|
||||
/* pause between cycles */
|
||||
sdelay (BURN_IN_CYCLE_DELAY);
|
||||
}
|
||||
|
||||
if (global_vars_write_to_eeprom () != 0) {
|
||||
led_set (0);
|
||||
printf ("%s: error writing global_vars to eeprom\n",
|
||||
__FUNCTION__);
|
||||
status = 1;
|
||||
}
|
||||
|
||||
if (status == 0) {
|
||||
led_blink (); /* endless loop!! */
|
||||
return (0);
|
||||
} else {
|
||||
led_set (0);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
burn_in, 1, 1, do_burn_in,
|
||||
"burn_in - start burn-in test application on TRAB\n",
|
||||
"\n"
|
||||
" - start burn-in test application\n"
|
||||
" The burn-in test could took a while to finish!\n"
|
||||
" The content of the onboard EEPROM is modified!\n"
|
||||
);
|
||||
|
||||
|
||||
int do_dip (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int i, dip;
|
||||
|
||||
if (argc > 1) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((dip = read_dip ()) == -1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
if ((dip & (1 << i)) == 0)
|
||||
printf("0");
|
||||
else
|
||||
printf("1");
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
dip, 1, 1, do_dip,
|
||||
"dip - read dip switch on TRAB\n",
|
||||
"\n"
|
||||
" - read state of dip switch (S1) on TRAB board\n"
|
||||
" read sequence: 1-2-3-4; ON=1; OFF=0; e.g.: \"0100\"\n"
|
||||
);
|
||||
|
||||
|
||||
int do_vcc5v (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int vcc5v;
|
||||
|
||||
if (argc > 1) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((vcc5v = read_vcc5v ()) == -1) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
printf ("%d", (vcc5v / 1000));
|
||||
printf (".%d", (vcc5v % 1000) / 100);
|
||||
printf ("%d V\n", (vcc5v % 100) / 10) ;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
vcc5v, 1, 1, do_vcc5v,
|
||||
"vcc5v - read VCC5V on TRAB\n",
|
||||
"\n"
|
||||
" - read actual value of voltage VCC5V\n"
|
||||
);
|
||||
|
||||
|
||||
int do_contact_temp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int contact_temp;
|
||||
|
||||
if (argc > 1) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
spi_init ();
|
||||
tsc2000_reg_init ();
|
||||
|
||||
contact_temp = tsc2000_contact_temp();
|
||||
printf ("%d degree C * 100\n", contact_temp) ;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
c_temp, 1, 1, do_contact_temp,
|
||||
"c_temp - read contact temperature on TRAB\n",
|
||||
"\n"
|
||||
" - reads the onboard temperature (=contact temperature)\n"
|
||||
);
|
||||
|
||||
|
||||
int do_burn_in_status (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1) {
|
||||
printf ("Usage:\n%s\n", cmdtp->usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
|
||||
(unsigned char*) &status, 1)) {
|
||||
return (1);
|
||||
}
|
||||
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
|
||||
(unsigned char*) &pass_cycles, 2)) {
|
||||
return (1);
|
||||
}
|
||||
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
|
||||
1, (unsigned char*) &first_error_cycle, 2)) {
|
||||
return (1);
|
||||
}
|
||||
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
|
||||
1, (unsigned char*) &first_error_num, 1)) {
|
||||
return (1);
|
||||
}
|
||||
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
|
||||
1, first_error_name,
|
||||
sizeof (first_error_name))) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (read_max_cycles () != 0) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
printf ("max_cycles = %d\n", max_cycles);
|
||||
printf ("status = %d\n", status);
|
||||
printf ("pass_cycles = %d\n", pass_cycles);
|
||||
printf ("first_error_cycle = %d\n", first_error_cycle);
|
||||
printf ("first_error_num = %d\n", first_error_num);
|
||||
printf ("first_error_name = %.*s\n",(int) sizeof(first_error_name),
|
||||
first_error_name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
bis, 1, 1, do_burn_in_status,
|
||||
"bis - print burn in status on TRAB\n",
|
||||
"\n"
|
||||
" - prints the status variables of the last burn in test\n"
|
||||
" stored in the onboard EEPROM on TRAB board\n"
|
||||
);
|
||||
|
||||
static int read_dip (void)
|
||||
{
|
||||
unsigned int result = 0;
|
||||
int adc_val;
|
||||
int i;
|
||||
|
||||
/***********************************************************
|
||||
DIP switch connection (according to wa4-cpu.sp.301.pdf, page 3):
|
||||
SW1 - AIN4
|
||||
SW2 - AIN5
|
||||
SW3 - AIN6
|
||||
SW4 - AIN7
|
||||
|
||||
"On" DIP switch position short-circuits the voltage from
|
||||
the input channel (i.e. '0' conversion result means "on").
|
||||
*************************************************************/
|
||||
|
||||
for (i = 7; i > 3; i--) {
|
||||
|
||||
if ((adc_val = adc_read (i)) == -1) {
|
||||
printf ("%s: Channel %d could not be read\n",
|
||||
__FUNCTION__, i);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Input voltage (switch open) is 1.8 V.
|
||||
* (Vin_High/VRef)*adc_res = (1,8V/2,5V)*1023) = 736
|
||||
* Set trigger at halve that value.
|
||||
*/
|
||||
if (adc_val < 368)
|
||||
result |= (1 << (i-4));
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static int read_vcc5v (void)
|
||||
{
|
||||
s32 result;
|
||||
|
||||
/* VCC5V is connected to channel 2 */
|
||||
|
||||
if ((result = adc_read (2)) == -1) {
|
||||
printf ("%s: VCC5V could not be read\n", __FUNCTION__);
|
||||
return (-1);
|
||||
}
|
||||
/*
|
||||
* Calculate voltage value. Split in two parts because there is no
|
||||
* floating point support. VCC5V is connected over an resistor divider:
|
||||
* VCC5V=ADCval*2,5V/1023*(10K+30K)/10K.
|
||||
*/
|
||||
result = result * 10 * 1000 / 1023; /* result in mV */
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static int test_dip (void)
|
||||
{
|
||||
static int first_run = 1;
|
||||
static int first_dip;
|
||||
|
||||
if (first_run) {
|
||||
if ((first_dip = read_dip ()) == -1) {
|
||||
return (1);
|
||||
}
|
||||
first_run = 0;
|
||||
debug ("%s: first_dip=%d\n", __FUNCTION__, first_dip);
|
||||
}
|
||||
if (first_dip != read_dip ()) {
|
||||
return (1);
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int test_vcc5v (void)
|
||||
{
|
||||
int vcc5v;
|
||||
|
||||
if ((vcc5v = read_vcc5v ()) == -1) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
if ((vcc5v > VCC5V_MAX) || (vcc5v < VCC5V_MIN)) {
|
||||
return (1);
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int test_rotary_switch (void)
|
||||
{
|
||||
static int first_run = 1;
|
||||
static int first_rs;
|
||||
|
||||
if (first_run) {
|
||||
/*
|
||||
* clear bits in CPLD, because they have random values after
|
||||
* power-up or reset.
|
||||
*/
|
||||
*CPLD_ROTARY_SWITCH |= (1 << 16) | (1 << 17);
|
||||
|
||||
first_rs = ((*CPLD_ROTARY_SWITCH >> 16) & 0x7);
|
||||
first_run = 0;
|
||||
debug ("%s: first_rs=%d\n", __FUNCTION__, first_rs);
|
||||
}
|
||||
|
||||
if (first_rs != ((*CPLD_ROTARY_SWITCH >> 16) & 0x7)) {
|
||||
return (1);
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int test_sram (void)
|
||||
{
|
||||
return (memory_post_tests (SRAM_ADDR, SRAM_SIZE));
|
||||
}
|
||||
|
||||
|
||||
static int test_eeprom (void)
|
||||
{
|
||||
unsigned char temp[sizeof (EEPROM_TEST_STRING_1)];
|
||||
int result = 0;
|
||||
|
||||
/* write test string 1, read back and verify */
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
|
||||
EEPROM_TEST_STRING_1,
|
||||
sizeof (EEPROM_TEST_STRING_1))) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
|
||||
temp, sizeof (EEPROM_TEST_STRING_1))) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (strcmp (temp, EEPROM_TEST_STRING_1) != 0) {
|
||||
result = 1;
|
||||
printf ("%s: error; read_str = \"%s\"\n", __FUNCTION__, temp);
|
||||
}
|
||||
|
||||
/* write test string 2, read back and verify */
|
||||
if (result == 0) {
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
|
||||
EEPROM_TEST_STRING_2,
|
||||
sizeof (EEPROM_TEST_STRING_2))) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_TEST, 1,
|
||||
temp, sizeof (EEPROM_TEST_STRING_2))) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
if (strcmp (temp, EEPROM_TEST_STRING_2) != 0) {
|
||||
result = 1;
|
||||
printf ("%s: error; read str = \"%s\"\n",
|
||||
__FUNCTION__, temp);
|
||||
}
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
static int test_contact_temp (void)
|
||||
{
|
||||
int contact_temp;
|
||||
|
||||
spi_init ();
|
||||
contact_temp = tsc2000_contact_temp ();
|
||||
|
||||
if ((contact_temp < MIN_CONTACT_TEMP)
|
||||
|| (contact_temp > MAX_CONTACT_TEMP))
|
||||
return (1);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static int i2c_write_multiple (uchar chip, uint addr, int alen,
|
||||
uchar *buffer, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (alen != 1) {
|
||||
printf ("%s: addr len other than 1 not supported\n",
|
||||
__FUNCTION__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i2c_write (chip, addr+i, alen, buffer+i, 1)) {
|
||||
printf ("%s: could not write to i2c device %d"
|
||||
", addr %d\n", __FUNCTION__, chip, addr);
|
||||
return (1);
|
||||
}
|
||||
#if 0
|
||||
printf ("chip=%#x, addr+i=%#x+%d=%p, alen=%d, *buffer+i="
|
||||
"%#x+%d=%p=\"%.1s\"\n", chip, addr, i, addr+i,
|
||||
alen, buffer, i, buffer+i, buffer+i);
|
||||
#endif
|
||||
|
||||
udelay (30000);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static int i2c_read_multiple (uchar chip, uint addr, int alen,
|
||||
uchar *buffer, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (alen != 1) {
|
||||
printf ("%s: addr len other than 1 not supported\n",
|
||||
__FUNCTION__);
|
||||
return (1);
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i2c_read (chip, addr+i, alen, buffer+i, 1)) {
|
||||
printf ("%s: could not read from i2c device %#x"
|
||||
", addr %d\n", __FUNCTION__, chip, addr);
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static int adc_read (unsigned int channel)
|
||||
{
|
||||
int j = 1000; /* timeout value for wait loop in us */
|
||||
S3C2400_ADC *padc;
|
||||
|
||||
padc = S3C2400_GetBase_ADC();
|
||||
channel &= 0x7;
|
||||
|
||||
adc_init ();
|
||||
|
||||
debug ("%s: adccon %#x\n", __FUNCTION__, padc->ADCCON);
|
||||
|
||||
padc->ADCCON &= ~ADC_STDBM; /* select normal mode */
|
||||
padc->ADCCON &= ~(0x7 << 3); /* clear the channel bits */
|
||||
padc->ADCCON |= ((channel << 3) | ADC_ENABLE_START);
|
||||
|
||||
debug ("%s: reading ch %d, addcon %#x\n", __FUNCTION__,
|
||||
(padc->ADCCON >> 3) & 0x7, padc->ADCCON);
|
||||
|
||||
while (j--) {
|
||||
if ((padc->ADCCON & ADC_ENABLE_START) == 0)
|
||||
break;
|
||||
udelay (1);
|
||||
}
|
||||
|
||||
if (j == 0) {
|
||||
printf("%s: ADC timeout\n", __FUNCTION__);
|
||||
padc->ADCCON |= ADC_STDBM; /* select standby mode */
|
||||
return -1;
|
||||
}
|
||||
|
||||
padc->ADCCON |= ADC_STDBM; /* select standby mode */
|
||||
|
||||
debug ("%s: return %#x, adccon %#x\n", __FUNCTION__,
|
||||
padc->ADCDAT & 0x3FF, padc->ADCCON);
|
||||
|
||||
return (padc->ADCDAT & 0x3FF);
|
||||
}
|
||||
|
||||
|
||||
static void adc_init (void)
|
||||
{
|
||||
S3C2400_ADC *padc;
|
||||
|
||||
padc = S3C2400_GetBase_ADC();
|
||||
|
||||
padc->ADCCON &= ~(0xff << 6); /* clear prescaler bits */
|
||||
padc->ADCCON |= ((65 << 6) | ADC_PRSCEN); /* set prescaler */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void led_set (unsigned int state)
|
||||
{
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
|
||||
led_init ();
|
||||
|
||||
switch (state) {
|
||||
case 0: /* turn LED off */
|
||||
gpio->PADAT |= (1 << 12);
|
||||
break;
|
||||
case 1: /* turn LED on */
|
||||
gpio->PADAT &= ~(1 << 12);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
static void led_blink (void)
|
||||
{
|
||||
led_init ();
|
||||
|
||||
/* blink LED. This function does not return! */
|
||||
while (1) {
|
||||
led_set (1);
|
||||
udelay (1000000 / LED_BLINK_FREQ / 2);
|
||||
led_set (0);
|
||||
udelay (1000000 / LED_BLINK_FREQ / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void led_init (void)
|
||||
{
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
|
||||
/* configure GPA12 as output and set to High -> LED off */
|
||||
gpio->PACON &= ~(1 << 12);
|
||||
gpio->PADAT |= (1 << 12);
|
||||
}
|
||||
|
||||
|
||||
static void sdelay (unsigned long seconds)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < seconds; i++) {
|
||||
udelay (1000000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int global_vars_write_to_eeprom (void)
|
||||
{
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_STATUS, 1,
|
||||
(unsigned char*) &status, 1)) {
|
||||
return (1);
|
||||
}
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_PASS_CYCLES, 1,
|
||||
(unsigned char*) &pass_cycles, 2)) {
|
||||
return (1);
|
||||
}
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_CYCLE,
|
||||
1, (unsigned char*) &first_error_cycle, 2)) {
|
||||
return (1);
|
||||
}
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NUM,
|
||||
1, (unsigned char*) &first_error_num, 1)) {
|
||||
return (1);
|
||||
}
|
||||
if (i2c_write_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_FIRST_ERROR_NAME,
|
||||
1, first_error_name,
|
||||
sizeof(first_error_name))) {
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void global_vars_init (void)
|
||||
{
|
||||
status = 1; /* error */
|
||||
pass_cycles = 0;
|
||||
first_error_cycle = 0;
|
||||
first_error_num = 0;
|
||||
first_error_name[0] = '\0';
|
||||
act_cycle = 0;
|
||||
max_cycles = 0;
|
||||
}
|
||||
|
||||
|
||||
static void test_function_table_init (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BIF_MAX; i++)
|
||||
test_function[i].pf = dummy;
|
||||
|
||||
/*
|
||||
* the length of "name" must not exceed 16, including the '\0'
|
||||
* termination. See also the EEPROM address map.
|
||||
*/
|
||||
test_function[0].pf = test_dip;
|
||||
test_function[0].name = "dip";
|
||||
|
||||
test_function[1].pf = test_vcc5v;
|
||||
test_function[1].name = "vcc5v";
|
||||
|
||||
test_function[2].pf = test_rotary_switch;
|
||||
test_function[2].name = "rotary_switch";
|
||||
|
||||
test_function[3].pf = test_sram;
|
||||
test_function[3].name = "sram";
|
||||
|
||||
test_function[4].pf = test_eeprom;
|
||||
test_function[4].name = "eeprom";
|
||||
|
||||
test_function[5].pf = test_contact_temp;
|
||||
test_function[5].name = "contact_temp";
|
||||
}
|
||||
|
||||
|
||||
static int read_max_cycles (void)
|
||||
{
|
||||
if (i2c_read_multiple (I2C_EEPROM_DEV_ADDR, EE_ADDR_MAX_CYCLES, 1,
|
||||
(unsigned char *) &max_cycles, 2) != 0) {
|
||||
return (1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int dummy(void)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif /* CFG_CMD_BSP */
|
||||
484
board/trab/memory.c
Normal file
484
board/trab/memory.c
Normal file
@@ -0,0 +1,484 @@
|
||||
/*
|
||||
* (C) Copyright 2002-2003
|
||||
* 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>
|
||||
|
||||
/* Memory test
|
||||
*
|
||||
* General observations:
|
||||
* o The recommended test sequence is to test the data lines: if they are
|
||||
* broken, nothing else will work properly. Then test the address
|
||||
* lines. Finally, test the cells in the memory now that the test
|
||||
* program knows that the address and data lines work properly.
|
||||
* This sequence also helps isolate and identify what is faulty.
|
||||
*
|
||||
* o For the address line test, it is a good idea to use the base
|
||||
* address of the lowest memory location, which causes a '1' bit to
|
||||
* walk through a field of zeros on the address lines and the highest
|
||||
* memory location, which causes a '0' bit to walk through a field of
|
||||
* '1's on the address line.
|
||||
*
|
||||
* o Floating buses can fool memory tests if the test routine writes
|
||||
* a value and then reads it back immediately. The problem is, the
|
||||
* write will charge the residual capacitance on the data bus so the
|
||||
* bus retains its state briefely. When the test program reads the
|
||||
* value back immediately, the capacitance of the bus can allow it
|
||||
* to read back what was written, even though the memory circuitry
|
||||
* is broken. To avoid this, the test program should write a test
|
||||
* pattern to the target location, write a different pattern elsewhere
|
||||
* to charge the residual capacitance in a differnt manner, then read
|
||||
* the target location back.
|
||||
*
|
||||
* o Always read the target location EXACTLY ONCE and save it in a local
|
||||
* variable. The problem with reading the target location more than
|
||||
* once is that the second and subsequent reads may work properly,
|
||||
* resulting in a failed test that tells the poor technician that
|
||||
* "Memory error at 00000000, wrote aaaaaaaa, read aaaaaaaa" which
|
||||
* doesn't help him one bit and causes puzzled phone calls. Been there,
|
||||
* done that.
|
||||
*
|
||||
* Data line test:
|
||||
* ---------------
|
||||
* This tests data lines for shorts and opens by forcing adjacent data
|
||||
* to opposite states. Because the data lines could be routed in an
|
||||
* arbitrary manner the must ensure test patterns ensure that every case
|
||||
* is tested. By using the following series of binary patterns every
|
||||
* combination of adjacent bits is test regardless of routing.
|
||||
*
|
||||
* ...101010101010101010101010
|
||||
* ...110011001100110011001100
|
||||
* ...111100001111000011110000
|
||||
* ...111111110000000011111111
|
||||
*
|
||||
* Carrying this out, gives us six hex patterns as follows:
|
||||
*
|
||||
* 0xaaaaaaaaaaaaaaaa
|
||||
* 0xcccccccccccccccc
|
||||
* 0xf0f0f0f0f0f0f0f0
|
||||
* 0xff00ff00ff00ff00
|
||||
* 0xffff0000ffff0000
|
||||
* 0xffffffff00000000
|
||||
*
|
||||
* To test for short and opens to other signals on our boards, we
|
||||
* simply test with the 1's complemnt of the paterns as well, resulting
|
||||
* in twelve patterns total.
|
||||
*
|
||||
* After writing a test pattern. a special pattern 0x0123456789ABCDEF is
|
||||
* written to a different address in case the data lines are floating.
|
||||
* Thus, if a byte lane fails, you will see part of the special
|
||||
* pattern in that byte lane when the test runs. For example, if the
|
||||
* xx__xxxxxxxxxxxx byte line fails, you will see aa23aaaaaaaaaaaa
|
||||
* (for the 'a' test pattern).
|
||||
*
|
||||
* Address line test:
|
||||
* ------------------
|
||||
* This function performs a test to verify that all the address lines
|
||||
* hooked up to the RAM work properly. If there is an address line
|
||||
* fault, it usually shows up as two different locations in the address
|
||||
* map (related by the faulty address line) mapping to one physical
|
||||
* memory storage location. The artifact that shows up is writing to
|
||||
* the first location "changes" the second location.
|
||||
*
|
||||
* To test all address lines, we start with the given base address and
|
||||
* xor the address with a '1' bit to flip one address line. For each
|
||||
* test, we shift the '1' bit left to test the next address line.
|
||||
*
|
||||
* In the actual code, we start with address sizeof(ulong) since our
|
||||
* test pattern we use is a ulong and thus, if we tried to test lower
|
||||
* order address bits, it wouldn't work because our pattern would
|
||||
* overwrite itself.
|
||||
*
|
||||
* Example for a 4 bit address space with the base at 0000:
|
||||
* 0000 <- base
|
||||
* 0001 <- test 1
|
||||
* 0010 <- test 2
|
||||
* 0100 <- test 3
|
||||
* 1000 <- test 4
|
||||
* Example for a 4 bit address space with the base at 0010:
|
||||
* 0010 <- base
|
||||
* 0011 <- test 1
|
||||
* 0000 <- (below the base address, skipped)
|
||||
* 0110 <- test 2
|
||||
* 1010 <- test 3
|
||||
*
|
||||
* The test locations are successively tested to make sure that they are
|
||||
* not "mirrored" onto the base address due to a faulty address line.
|
||||
* Note that the base and each test location are related by one address
|
||||
* line flipped. Note that the base address need not be all zeros.
|
||||
*
|
||||
* Memory tests 1-4:
|
||||
* -----------------
|
||||
* These tests verify RAM using sequential writes and reads
|
||||
* to/from RAM. There are several test cases that use different patterns to
|
||||
* verify RAM. Each test case fills a region of RAM with one pattern and
|
||||
* then reads the region back and compares its contents with the pattern.
|
||||
* The following patterns are used:
|
||||
*
|
||||
* 1a) zero pattern (0x00000000)
|
||||
* 1b) negative pattern (0xffffffff)
|
||||
* 1c) checkerboard pattern (0x55555555)
|
||||
* 1d) checkerboard pattern (0xaaaaaaaa)
|
||||
* 2) bit-flip pattern ((1 << (offset % 32))
|
||||
* 3) address pattern (offset)
|
||||
* 4) address pattern (~offset)
|
||||
*
|
||||
* Being run in normal mode, the test verifies only small 4Kb
|
||||
* regions of RAM around each 1Mb boundary. For example, for 64Mb
|
||||
* RAM the following areas are verified: 0x00000000-0x00000800,
|
||||
* 0x000ff800-0x00100800, 0x001ff800-0x00200800, ..., 0x03fff800-
|
||||
* 0x04000000. If the test is run in slow-test mode, it verifies
|
||||
* the whole RAM.
|
||||
*/
|
||||
|
||||
/* #ifdef CONFIG_POST */
|
||||
|
||||
#include <post.h>
|
||||
#include <watchdog.h>
|
||||
|
||||
/* #if CONFIG_POST & CFG_POST_MEMORY */
|
||||
|
||||
/*
|
||||
* Define INJECT_*_ERRORS for testing error detection in the presence of
|
||||
* _good_ hardware.
|
||||
*/
|
||||
#undef INJECT_DATA_ERRORS
|
||||
#undef INJECT_ADDRESS_ERRORS
|
||||
|
||||
#ifdef INJECT_DATA_ERRORS
|
||||
#warning "Injecting data line errors for testing purposes"
|
||||
#endif
|
||||
|
||||
#ifdef INJECT_ADDRESS_ERRORS
|
||||
#warning "Injecting address line errors for testing purposes"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* This function performs a double word move from the data at
|
||||
* the source pointer to the location at the destination pointer.
|
||||
* This is helpful for testing memory on processors which have a 64 bit
|
||||
* wide data bus.
|
||||
*
|
||||
* On those PowerPC with FPU, use assembly and a floating point move:
|
||||
* this does a 64 bit move.
|
||||
*
|
||||
* For other processors, let the compiler generate the best code it can.
|
||||
*/
|
||||
static void move64(unsigned long long *src, unsigned long long *dest)
|
||||
{
|
||||
#if defined(CONFIG_MPC8260) || defined(CONFIG_MPC824X)
|
||||
asm ("lfd 0, 0(3)\n\t" /* fpr0 = *scr */
|
||||
"stfd 0, 0(4)" /* *dest = fpr0 */
|
||||
: : : "fr0" ); /* Clobbers fr0 */
|
||||
return;
|
||||
#else
|
||||
*dest = *src;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* This is 64 bit wide test patterns. Note that they reside in ROM
|
||||
* (which presumably works) and the tests write them to RAM which may
|
||||
* not work.
|
||||
*
|
||||
* The "otherpattern" is written to drive the data bus to values other
|
||||
* than the test pattern. This is for detecting floating bus lines.
|
||||
*
|
||||
*/
|
||||
const static unsigned long long pattern[] = {
|
||||
0xaaaaaaaaaaaaaaaa,
|
||||
0xcccccccccccccccc,
|
||||
0xf0f0f0f0f0f0f0f0,
|
||||
0xff00ff00ff00ff00,
|
||||
0xffff0000ffff0000,
|
||||
0xffffffff00000000,
|
||||
0x00000000ffffffff,
|
||||
0x0000ffff0000ffff,
|
||||
0x00ff00ff00ff00ff,
|
||||
0x0f0f0f0f0f0f0f0f,
|
||||
0x3333333333333333,
|
||||
0x5555555555555555};
|
||||
const unsigned long long otherpattern = 0x0123456789abcdef;
|
||||
|
||||
|
||||
static int memory_post_dataline(unsigned long long * pmem)
|
||||
{
|
||||
unsigned long long temp64;
|
||||
int num_patterns = sizeof(pattern)/ sizeof(pattern[0]);
|
||||
int i;
|
||||
unsigned int hi, lo, pathi, patlo;
|
||||
int ret = 0;
|
||||
|
||||
for ( i = 0; i < num_patterns; i++) {
|
||||
move64((unsigned long long *)&(pattern[i]), pmem++);
|
||||
/*
|
||||
* Put a different pattern on the data lines: otherwise they
|
||||
* may float long enough to read back what we wrote.
|
||||
*/
|
||||
move64((unsigned long long *)&otherpattern, pmem--);
|
||||
move64(pmem, &temp64);
|
||||
|
||||
#ifdef INJECT_DATA_ERRORS
|
||||
temp64 ^= 0x00008000;
|
||||
#endif
|
||||
|
||||
if (temp64 != pattern[i]){
|
||||
pathi = (pattern[i]>>32) & 0xffffffff;
|
||||
patlo = pattern[i] & 0xffffffff;
|
||||
|
||||
hi = (temp64>>32) & 0xffffffff;
|
||||
lo = temp64 & 0xffffffff;
|
||||
|
||||
printf ("Memory (date line) error at %08lx, "
|
||||
"wrote %08x%08x, read %08x%08x !\n",
|
||||
(ulong)pmem, pathi, patlo, hi, lo);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int memory_post_addrline(ulong *testaddr, ulong *base, ulong size)
|
||||
{
|
||||
ulong *target;
|
||||
ulong *end;
|
||||
ulong readback;
|
||||
ulong xor;
|
||||
int ret = 0;
|
||||
|
||||
end = (ulong *)((ulong)base + size); /* pointer arith! */
|
||||
xor = 0;
|
||||
for(xor = sizeof(ulong); xor > 0; xor <<= 1) {
|
||||
target = (ulong *)((ulong)testaddr ^ xor);
|
||||
if((target >= base) && (target < end)) {
|
||||
*testaddr = ~*target;
|
||||
readback = *target;
|
||||
|
||||
#ifdef INJECT_ADDRESS_ERRORS
|
||||
if(xor == 0x00008000) {
|
||||
readback = *testaddr;
|
||||
}
|
||||
#endif
|
||||
if(readback == *testaddr) {
|
||||
printf ("Memory (address line) error at %08lx<->%08lx, "
|
||||
"XOR value %08lx !\n",
|
||||
(ulong)testaddr, (ulong)target,
|
||||
xor);
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int memory_post_test1 (unsigned long start,
|
||||
unsigned long size,
|
||||
unsigned long val)
|
||||
{
|
||||
unsigned long i;
|
||||
ulong *mem = (ulong *) start;
|
||||
ulong readback;
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < size / sizeof (ulong); i++) {
|
||||
mem[i] = val;
|
||||
if (i % 1024 == 0)
|
||||
WATCHDOG_RESET ();
|
||||
}
|
||||
|
||||
for (i = 0; i < size / sizeof (ulong) && ret == 0; i++) {
|
||||
readback = mem[i];
|
||||
if (readback != val) {
|
||||
printf ("Memory error at %08lx, "
|
||||
"wrote %08lx, read %08lx !\n",
|
||||
(ulong)(mem + i), val, readback);
|
||||
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
if (i % 1024 == 0)
|
||||
WATCHDOG_RESET ();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int memory_post_test2 (unsigned long start, unsigned long size)
|
||||
{
|
||||
unsigned long i;
|
||||
ulong *mem = (ulong *) start;
|
||||
ulong readback;
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < size / sizeof (ulong); i++) {
|
||||
mem[i] = 1 << (i % 32);
|
||||
if (i % 1024 == 0)
|
||||
WATCHDOG_RESET ();
|
||||
}
|
||||
|
||||
for (i = 0; i < size / sizeof (ulong) && ret == 0; i++) {
|
||||
readback = mem[i];
|
||||
if (readback != (1 << (i % 32))) {
|
||||
printf ("Memory error at %08lx, "
|
||||
"wrote %08x, read %08lx !\n",
|
||||
(ulong)(mem + i), 1 << (i % 32), readback);
|
||||
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
if (i % 1024 == 0)
|
||||
WATCHDOG_RESET ();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int memory_post_test3 (unsigned long start, unsigned long size)
|
||||
{
|
||||
unsigned long i;
|
||||
ulong *mem = (ulong *) start;
|
||||
ulong readback;
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < size / sizeof (ulong); i++) {
|
||||
mem[i] = i;
|
||||
if (i % 1024 == 0)
|
||||
WATCHDOG_RESET ();
|
||||
}
|
||||
|
||||
for (i = 0; i < size / sizeof (ulong) && ret == 0; i++) {
|
||||
readback = mem[i];
|
||||
if (readback != i) {
|
||||
printf ("Memory error at %08lx, "
|
||||
"wrote %08lx, read %08lx !\n",
|
||||
(ulong)(mem + i), i, readback);
|
||||
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
if (i % 1024 == 0)
|
||||
WATCHDOG_RESET ();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int memory_post_test4 (unsigned long start, unsigned long size)
|
||||
{
|
||||
unsigned long i;
|
||||
ulong *mem = (ulong *) start;
|
||||
ulong readback;
|
||||
int ret = 0;
|
||||
|
||||
for (i = 0; i < size / sizeof (ulong); i++) {
|
||||
mem[i] = ~i;
|
||||
if (i % 1024 == 0)
|
||||
WATCHDOG_RESET ();
|
||||
}
|
||||
|
||||
for (i = 0; i < size / sizeof (ulong) && ret == 0; i++) {
|
||||
readback = mem[i];
|
||||
if (readback != ~i) {
|
||||
printf ("Memory error at %08lx, "
|
||||
"wrote %08lx, read %08lx !\n",
|
||||
(ulong)(mem + i), ~i, readback);
|
||||
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
if (i % 1024 == 0)
|
||||
WATCHDOG_RESET ();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int memory_post_tests (unsigned long start, unsigned long size)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (ret == 0)
|
||||
ret = memory_post_dataline ((long long *)start);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_addrline ((long *)start, (long *)start, size);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_addrline ((long *)(start + size - 8),
|
||||
(long *)start, size);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_test1 (start, size, 0x00000000);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_test1 (start, size, 0xffffffff);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_test1 (start, size, 0x55555555);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_test1 (start, size, 0xaaaaaaaa);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_test2 (start, size);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_test3 (start, size);
|
||||
WATCHDOG_RESET ();
|
||||
if (ret == 0)
|
||||
ret = memory_post_test4 (start, size);
|
||||
WATCHDOG_RESET ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int memory_post_test (int flags)
|
||||
{
|
||||
int ret = 0;
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
bd_t *bd = gd->bd;
|
||||
unsigned long memsize = (bd->bi_memsize >= 256 << 20 ?
|
||||
256 << 20 : bd->bi_memsize) - (1 << 20);
|
||||
|
||||
|
||||
if (flags & POST_SLOWTEST) {
|
||||
ret = memory_post_tests (CFG_SDRAM_BASE, memsize);
|
||||
} else { /* POST_NORMAL */
|
||||
|
||||
unsigned long i;
|
||||
|
||||
for (i = 0; i < (memsize >> 20) && ret == 0; i++) {
|
||||
if (ret == 0)
|
||||
ret = memory_post_tests (i << 20, 0x800);
|
||||
if (ret == 0)
|
||||
ret = memory_post_tests ((i << 20) + 0xff800, 0x800);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif 0
|
||||
|
||||
/* #endif */ /* CONFIG_POST & CFG_POST_MEMORY */
|
||||
/* #endif */ /* CONFIG_POST */
|
||||
@@ -105,6 +105,10 @@ int board_init ()
|
||||
gpio->PGUP = 0x0;
|
||||
gpio->OPENCR= 0x0;
|
||||
|
||||
/* suppress flicker of the VFDs */
|
||||
gpio->MISCCR = 0x40;
|
||||
gpio->PFCON |= (2<<12);
|
||||
|
||||
/* arch number of SAMSUNG-Board */
|
||||
/* MACH_TYPE_SMDK2400 */
|
||||
/* XXX this isn't really correct, but keep it for now */
|
||||
|
||||
317
board/trab/tsc2000.c
Normal file
317
board/trab/tsc2000.c
Normal file
@@ -0,0 +1,317 @@
|
||||
/*
|
||||
* Functions to access the TSC2000 controller on TRAB board (used for scanning
|
||||
* thermo sensors)
|
||||
*
|
||||
* Copyright (C) 2003 Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
|
||||
*
|
||||
* Copyright (C) 2002 DENX Software Engineering, Wolfgang Denk, 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 <s3c2400.h>
|
||||
#include "tsc2000.h"
|
||||
|
||||
void spi_init(void)
|
||||
{
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
|
||||
int i;
|
||||
|
||||
/* Configure I/O ports. */
|
||||
gpio->PDCON = (gpio->PDCON & 0xF3FFFF) | 0x040000;
|
||||
gpio->PGCON = (gpio->PGCON & 0x0F3FFF) | 0x008000;
|
||||
gpio->PGCON = (gpio->PGCON & 0x0CFFFF) | 0x020000;
|
||||
gpio->PGCON = (gpio->PGCON & 0x03FFFF) | 0x080000;
|
||||
|
||||
CLR_CS_TOUCH();
|
||||
|
||||
spi->ch[0].SPPRE = 0x1F; /* Baud-rate ca. 514kHz */
|
||||
spi->ch[0].SPPIN = 0x01; /* SPI-MOSI holds Level after last bit */
|
||||
spi->ch[0].SPCON = 0x1A; /* Polling, Prescaler, Master, CPOL=0,
|
||||
CPHA=1 */
|
||||
|
||||
/* Dummy byte ensures clock to be low. */
|
||||
for (i = 0; i < 10; i++) {
|
||||
spi->ch[0].SPTDAT = 0xFF;
|
||||
}
|
||||
spi_wait_transmit_done();
|
||||
}
|
||||
|
||||
|
||||
static void spi_wait_transmit_done(void)
|
||||
{
|
||||
S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
|
||||
|
||||
while (!(spi->ch[0].SPSTA & 0x01)); /* wait until transfer is done */
|
||||
}
|
||||
|
||||
|
||||
static void tsc2000_write(unsigned short reg, unsigned short data)
|
||||
{
|
||||
S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
|
||||
unsigned int command;
|
||||
|
||||
SET_CS_TOUCH();
|
||||
command = reg;
|
||||
spi->ch[0].SPTDAT = (command & 0xFF00) >> 8;
|
||||
spi_wait_transmit_done();
|
||||
spi->ch[0].SPTDAT = (command & 0x00FF);
|
||||
spi_wait_transmit_done();
|
||||
spi->ch[0].SPTDAT = (data & 0xFF00) >> 8;
|
||||
spi_wait_transmit_done();
|
||||
spi->ch[0].SPTDAT = (data & 0x00FF);
|
||||
spi_wait_transmit_done();
|
||||
|
||||
CLR_CS_TOUCH();
|
||||
}
|
||||
|
||||
|
||||
static unsigned short tsc2000_read (unsigned short reg)
|
||||
{
|
||||
unsigned short command, data;
|
||||
S3C24X0_SPI * const spi = S3C24X0_GetBase_SPI();
|
||||
|
||||
SET_CS_TOUCH();
|
||||
command = 0x8000 | reg;
|
||||
|
||||
spi->ch[0].SPTDAT = (command & 0xFF00) >> 8;
|
||||
spi_wait_transmit_done();
|
||||
spi->ch[0].SPTDAT = (command & 0x00FF);
|
||||
spi_wait_transmit_done();
|
||||
|
||||
spi->ch[0].SPTDAT = 0xFF;
|
||||
spi_wait_transmit_done();
|
||||
data = spi->ch[0].SPRDAT;
|
||||
spi->ch[0].SPTDAT = 0xFF;
|
||||
spi_wait_transmit_done();
|
||||
|
||||
CLR_CS_TOUCH();
|
||||
return (spi->ch[0].SPRDAT & 0x0FF) | (data << 8);
|
||||
}
|
||||
|
||||
|
||||
static void tsc2000_set_mux (unsigned int channel)
|
||||
{
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
|
||||
CLR_MUX1_ENABLE; CLR_MUX2_ENABLE;
|
||||
CLR_MUX3_ENABLE; CLR_MUX4_ENABLE;
|
||||
switch (channel) {
|
||||
case 0:
|
||||
CLR_MUX0; CLR_MUX1;
|
||||
SET_MUX1_ENABLE;
|
||||
break;
|
||||
case 1:
|
||||
SET_MUX0; CLR_MUX1;
|
||||
SET_MUX1_ENABLE;
|
||||
break;
|
||||
case 2:
|
||||
CLR_MUX0; SET_MUX1;
|
||||
SET_MUX1_ENABLE;
|
||||
break;
|
||||
case 3:
|
||||
SET_MUX0; SET_MUX1;
|
||||
SET_MUX1_ENABLE;
|
||||
break;
|
||||
case 4:
|
||||
CLR_MUX0; CLR_MUX1;
|
||||
SET_MUX2_ENABLE;
|
||||
break;
|
||||
case 5:
|
||||
SET_MUX0; CLR_MUX1;
|
||||
SET_MUX2_ENABLE;
|
||||
break;
|
||||
case 6:
|
||||
CLR_MUX0; SET_MUX1;
|
||||
SET_MUX2_ENABLE;
|
||||
break;
|
||||
case 7:
|
||||
SET_MUX0; SET_MUX1;
|
||||
SET_MUX2_ENABLE;
|
||||
break;
|
||||
case 8:
|
||||
CLR_MUX0; CLR_MUX1;
|
||||
SET_MUX3_ENABLE;
|
||||
break;
|
||||
case 9:
|
||||
SET_MUX0; CLR_MUX1;
|
||||
SET_MUX3_ENABLE;
|
||||
break;
|
||||
case 10:
|
||||
CLR_MUX0; SET_MUX1;
|
||||
SET_MUX3_ENABLE;
|
||||
break;
|
||||
case 11:
|
||||
SET_MUX0; SET_MUX1;
|
||||
SET_MUX3_ENABLE;
|
||||
break;
|
||||
case 12:
|
||||
CLR_MUX0; CLR_MUX1;
|
||||
SET_MUX4_ENABLE;
|
||||
break;
|
||||
case 13:
|
||||
SET_MUX0; CLR_MUX1;
|
||||
SET_MUX4_ENABLE;
|
||||
break;
|
||||
case 14:
|
||||
CLR_MUX0; SET_MUX1;
|
||||
SET_MUX4_ENABLE;
|
||||
break;
|
||||
case 15:
|
||||
SET_MUX0; SET_MUX1;
|
||||
SET_MUX4_ENABLE;
|
||||
break;
|
||||
default:
|
||||
CLR_MUX0; CLR_MUX1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void tsc2000_set_range (unsigned int range)
|
||||
{
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
|
||||
switch (range) {
|
||||
case 1:
|
||||
CLR_SEL_TEMP_V_0; SET_SEL_TEMP_V_1;
|
||||
CLR_SEL_TEMP_V_2; CLR_SEL_TEMP_V_3;
|
||||
break;
|
||||
case 2:
|
||||
CLR_SEL_TEMP_V_0; CLR_SEL_TEMP_V_1;
|
||||
CLR_SEL_TEMP_V_2; SET_SEL_TEMP_V_3;
|
||||
break;
|
||||
case 3:
|
||||
SET_SEL_TEMP_V_0; CLR_SEL_TEMP_V_1;
|
||||
SET_SEL_TEMP_V_2; CLR_SEL_TEMP_V_3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static u16 tsc2000_read_channel (unsigned int channel)
|
||||
{
|
||||
u16 res;
|
||||
|
||||
tsc2000_set_mux(channel);
|
||||
udelay(3 * TSC2000_DELAY_BASE);
|
||||
|
||||
tsc2000_write(TSC2000_REG_ADC, 0x2036);
|
||||
adc_wait_conversion_done ();
|
||||
res = tsc2000_read(TSC2000_REG_AUX1);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
s32 tsc2000_contact_temp (void)
|
||||
{
|
||||
long adc_pt1000, offset;
|
||||
long u_pt1000;
|
||||
long contact_temp;
|
||||
|
||||
|
||||
tsc2000_reg_init ();
|
||||
tsc2000_set_range (3);
|
||||
|
||||
adc_pt1000 = tsc2000_read_channel (14);
|
||||
debug ("read channel 14 (pt1000 adc value): %ld\n", adc_pt1000);
|
||||
|
||||
offset = tsc2000_read_channel (15);
|
||||
debug ("read channel 15 (offset): %ld\n", offset);
|
||||
|
||||
/*
|
||||
* Formula for calculating voltage drop on PT1000 resistor: u_pt1000 =
|
||||
* x_range3 * (adc_raw - offset) / 10. Formula to calculate x_range3:
|
||||
* x_range3 = (2500 * (1000000 + err_vref + err_amp3)) / (4095*6). The
|
||||
* error correction Values err_vref and err_amp3 are assumed as 0 in
|
||||
* u-boot, because this could cause only a very small error (< 1%).
|
||||
*/
|
||||
u_pt1000 = (101750 * (adc_pt1000 - offset)) / 10;
|
||||
debug ("u_pt1000: %ld\n", u_pt1000);
|
||||
|
||||
if (tsc2000_interpolate(u_pt1000, Pt1000_temp_table,
|
||||
&contact_temp) == -1) {
|
||||
printf ("%s: error interpolating PT1000 vlaue\n",
|
||||
__FUNCTION__);
|
||||
return (-1000);
|
||||
}
|
||||
debug ("contact_temp: %ld\n", contact_temp);
|
||||
|
||||
return contact_temp;
|
||||
}
|
||||
|
||||
|
||||
void tsc2000_reg_init (void)
|
||||
{
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
|
||||
tsc2000_write(TSC2000_REG_ADC, 0x2036);
|
||||
tsc2000_write(TSC2000_REG_REF, 0x0011);
|
||||
tsc2000_write(TSC2000_REG_DACCTL, 0x0000);
|
||||
|
||||
CON_MUX0;
|
||||
CON_MUX1;
|
||||
|
||||
CON_MUX1_ENABLE;
|
||||
CON_MUX2_ENABLE;
|
||||
CON_MUX3_ENABLE;
|
||||
CON_MUX4_ENABLE;
|
||||
|
||||
CON_SEL_TEMP_V_0;
|
||||
CON_SEL_TEMP_V_1;
|
||||
CON_SEL_TEMP_V_2;
|
||||
CON_SEL_TEMP_V_3;
|
||||
|
||||
tsc2000_set_mux(0);
|
||||
tsc2000_set_range(0);
|
||||
}
|
||||
|
||||
|
||||
static int tsc2000_interpolate(long value, long data[][2], long *result)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* the data is sorted and the first element is upper
|
||||
* limit so we can easily check for out-of-band values
|
||||
*/
|
||||
if (data[0][0] < value || data[1][0] > value)
|
||||
return -1;
|
||||
|
||||
i = 1;
|
||||
while (data[i][0] < value)
|
||||
i++;
|
||||
|
||||
/* To prevent overflow we have to store the intermediate
|
||||
result in 'long long'.
|
||||
*/
|
||||
|
||||
*result = data[i-1][1] +
|
||||
((unsigned long long)(data[i][1] - data[i-1][1])
|
||||
* (unsigned long long)(value - data[i-1][0]))
|
||||
/ (data[i][0] - data[i-1][0]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void adc_wait_conversion_done(void)
|
||||
{
|
||||
while (!(tsc2000_read(TSC2000_REG_ADC) & (1 << 14)));
|
||||
}
|
||||
147
board/trab/tsc2000.h
Normal file
147
board/trab/tsc2000.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Functions to access the TSC2000 controller on TRAB board (used for scanning
|
||||
* thermo sensors)
|
||||
*
|
||||
* Copyright (C) 2003 Martin Krause, TQ-Systems GmbH, martin.krause@tqs.de
|
||||
*
|
||||
* Copyright (C) 2002 DENX Software Engineering, Wolfgang Denk, 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
|
||||
*/
|
||||
|
||||
#ifndef _TSC2000_H_
|
||||
#define _TSC2000_H_
|
||||
|
||||
#include "Pt1000_temp_data.h"
|
||||
|
||||
/* temperature channel multiplexer definitions */
|
||||
#define CON_MUX0 (gpio->PCCON = (gpio->PCCON & 0x0FFFFFCFF) | 0x00000100)
|
||||
#define CLR_MUX0 (gpio->PCDAT &= 0x0FFEF)
|
||||
#define SET_MUX0 (gpio->PCDAT |= 0x00010)
|
||||
|
||||
#define CON_MUX1 (gpio->PCCON = (gpio->PCCON & 0x0FFFFF3FF) | 0x00000400)
|
||||
#define CLR_MUX1 (gpio->PCDAT &= 0x0FFDF)
|
||||
#define SET_MUX1 (gpio->PCDAT |= 0x00020)
|
||||
|
||||
#define CON_MUX1_ENABLE (gpio->PCCON = (gpio->PCCON & 0x0FFFFCFFF) | 0x00001000)
|
||||
#define CLR_MUX1_ENABLE (gpio->PCDAT |= 0x00040)
|
||||
#define SET_MUX1_ENABLE (gpio->PCDAT &= 0x0FFBF)
|
||||
|
||||
#define CON_MUX2_ENABLE (gpio->PCCON = (gpio->PCCON & 0x0FFFF3FFF) | 0x00004000)
|
||||
#define CLR_MUX2_ENABLE (gpio->PCDAT |= 0x00080)
|
||||
#define SET_MUX2_ENABLE (gpio->PCDAT &= 0x0FF7F)
|
||||
|
||||
#define CON_MUX3_ENABLE (gpio->PCCON = (gpio->PCCON & 0x0FFFCFFFF) | 0x00010000)
|
||||
#define CLR_MUX3_ENABLE (gpio->PCDAT |= 0x00100)
|
||||
#define SET_MUX3_ENABLE (gpio->PCDAT &= 0x0FEFF)
|
||||
|
||||
#define CON_MUX4_ENABLE (gpio->PCCON = (gpio->PCCON & 0x0FFF3FFFF) | 0x00040000)
|
||||
#define CLR_MUX4_ENABLE (gpio->PCDAT |= 0x00200)
|
||||
#define SET_MUX4_ENABLE (gpio->PCDAT &= 0x0FDFF)
|
||||
|
||||
#define CON_SEL_TEMP_V_0 (gpio->PCCON = (gpio->PCCON & 0x0FFCFFFFF) | 0x00100000)
|
||||
#define CLR_SEL_TEMP_V_0 (gpio->PCDAT &= 0x0FBFF)
|
||||
#define SET_SEL_TEMP_V_0 (gpio->PCDAT |= 0x00400)
|
||||
|
||||
#define CON_SEL_TEMP_V_1 (gpio->PCCON = (gpio->PCCON & 0x0FF3FFFFF) | 0x00400000)
|
||||
#define CLR_SEL_TEMP_V_1 (gpio->PCDAT &= 0x0F7FF)
|
||||
#define SET_SEL_TEMP_V_1 (gpio->PCDAT |= 0x00800)
|
||||
|
||||
#define CON_SEL_TEMP_V_2 (gpio->PCCON = (gpio->PCCON & 0x0FCFFFFFF) | 0x01000000)
|
||||
#define CLR_SEL_TEMP_V_2 (gpio->PCDAT &= 0x0EFFF)
|
||||
#define SET_SEL_TEMP_V_2 (gpio->PCDAT |= 0x01000)
|
||||
|
||||
#define CON_SEL_TEMP_V_3 (gpio->PCCON = (gpio->PCCON & 0x0F3FFFFFF) | 0x04000000)
|
||||
#define CLR_SEL_TEMP_V_3 (gpio->PCDAT &= 0x0DFFF)
|
||||
#define SET_SEL_TEMP_V_3 (gpio->PCDAT |= 0x02000)
|
||||
|
||||
/* TSC2000 register definition */
|
||||
#define TSC2000_REG_X ((0 << 11) | (0 << 5))
|
||||
#define TSC2000_REG_Y ((0 << 11) | (1 << 5))
|
||||
#define TSC2000_REG_Z1 ((0 << 11) | (2 << 5))
|
||||
#define TSC2000_REG_Z2 ((0 << 11) | (3 << 5))
|
||||
#define TSC2000_REG_BAT1 ((0 << 11) | (5 << 5))
|
||||
#define TSC2000_REG_BAT2 ((0 << 11) | (6 << 5))
|
||||
#define TSC2000_REG_AUX1 ((0 << 11) | (7 << 5))
|
||||
#define TSC2000_REG_AUX2 ((0 << 11) | (8 << 5))
|
||||
#define TSC2000_REG_TEMP1 ((0 << 11) | (9 << 5))
|
||||
#define TSC2000_REG_TEMP2 ((0 << 11) | (0xA << 5))
|
||||
#define TSC2000_REG_DAC ((0 << 11) | (0xB << 5))
|
||||
#define TSC2000_REG_ZERO ((0 << 11) | (0x10 << 5))
|
||||
#define TSC2000_REG_ADC ((1 << 11) | (0 << 5))
|
||||
#define TSC2000_REG_DACCTL ((1 << 11) | (2 << 5))
|
||||
#define TSC2000_REG_REF ((1 << 11) | (3 << 5))
|
||||
#define TSC2000_REG_RESET ((1 << 11) | (4 << 5))
|
||||
#define TSC2000_REG_CONFIG ((1 << 11) | (5 << 5))
|
||||
|
||||
/* bit definition of TSC2000 ADC register */
|
||||
#define TC_PSM (1 << 15)
|
||||
#define TC_STS (1 << 14)
|
||||
#define TC_AD3 (1 << 13)
|
||||
#define TC_AD2 (1 << 12)
|
||||
#define TC_AD1 (1 << 11)
|
||||
#define TC_AD0 (1 << 10)
|
||||
#define TC_RS1 (1 << 9)
|
||||
#define TC_RS0 (1 << 8)
|
||||
#define TC_AV1 (1 << 7)
|
||||
#define TC_AV0 (1 << 6)
|
||||
#define TC_CL1 (1 << 5)
|
||||
#define TC_CL0 (1 << 4)
|
||||
#define TC_PV2 (1 << 3)
|
||||
#define TC_PV1 (1 << 2)
|
||||
#define TC_PV0 (1 << 1)
|
||||
|
||||
/* default value for TSC2000 ADC register for use with touch functions */
|
||||
#define DEFAULT_ADC (TC_PV1 | TC_AV0 | TC_AV1 | TC_RS0)
|
||||
|
||||
#define TSC2000_DELAY_BASE 500
|
||||
#define TSC2000_NO_SENSOR -0x10000
|
||||
|
||||
#define ERROR_BATTERY 220 /* must be adjusted, if R68 is changed on
|
||||
* TRAB */
|
||||
|
||||
static void tsc2000_write(unsigned short, unsigned short);
|
||||
static unsigned short tsc2000_read (unsigned short);
|
||||
static u16 tsc2000_read_channel (unsigned int);
|
||||
static void tsc2000_set_mux (unsigned int);
|
||||
static void tsc2000_set_range (unsigned int);
|
||||
void tsc2000_reg_init (void);
|
||||
s32 tsc2000_contact_temp (void);
|
||||
static void spi_wait_transmit_done (void);
|
||||
void spi_init(void);
|
||||
static int tsc2000_interpolate(long value, long data[][2], long *result);
|
||||
static void adc_wait_conversion_done(void);
|
||||
|
||||
|
||||
static inline void SET_CS_TOUCH(void)
|
||||
{
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
|
||||
gpio->PDDAT &= 0x5FF;
|
||||
}
|
||||
|
||||
|
||||
static inline void CLR_CS_TOUCH(void)
|
||||
{
|
||||
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
|
||||
|
||||
gpio->PDDAT |= 0x200;
|
||||
}
|
||||
|
||||
#endif /* _TSC2000_H_ */
|
||||
@@ -81,7 +81,7 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
for (i=0; i<6; ++i) {
|
||||
printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
|
||||
}
|
||||
#ifdef CONFIG_PN62
|
||||
#if (defined CONFIG_PN62) || (defined CONFIG_PPCHAMELEONEVB)
|
||||
printf ("\neth1addr =");
|
||||
for (i=0; i<6; ++i) {
|
||||
printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
|
||||
|
||||
@@ -525,7 +525,7 @@ static int DoC_Address(struct DiskOnChip *doc, int numbytes, unsigned long ofs,
|
||||
return DoC_WaitReady(doc);
|
||||
}
|
||||
|
||||
/* Read a buffer from DoC, taking care of Millennium odditys */
|
||||
/* Read a buffer from DoC, taking care of Millennium oddities */
|
||||
static void DoC_ReadBuf(struct DiskOnChip *doc, u_char * buf, int len)
|
||||
{
|
||||
volatile int dummy;
|
||||
@@ -558,7 +558,7 @@ static void DoC_ReadBuf(struct DiskOnChip *doc, u_char * buf, int len)
|
||||
}
|
||||
}
|
||||
|
||||
/* Write a buffer to DoC, taking care of Millennium odditys */
|
||||
/* Write a buffer to DoC, taking care of Millennium oddities */
|
||||
static void DoC_WriteBuf(struct DiskOnChip *doc, const u_char * buf, int len)
|
||||
{
|
||||
unsigned long docptr;
|
||||
@@ -861,8 +861,13 @@ static int find_boot_record(struct NFTLrecord *nftl)
|
||||
memcpy(mh, buf, sizeof(struct NFTLMediaHeader));
|
||||
|
||||
/* Do some sanity checks on it */
|
||||
if (mh->UnitSizeFactor != 0xff) {
|
||||
puts ("Sorry, we don't support UnitSizeFactor "
|
||||
if (mh->UnitSizeFactor == 0) {
|
||||
#ifdef NFTL_DEBUG
|
||||
puts ("UnitSizeFactor 0x00 detected.\n"
|
||||
"This violates the spec but we think we know what it means...\n");
|
||||
#endif
|
||||
} else if (mh->UnitSizeFactor != 0xff) {
|
||||
printf ("Sorry, we don't support UnitSizeFactor "
|
||||
"of != 1 yet.\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -950,6 +955,8 @@ static void DoC2k_init(struct DiskOnChip* this)
|
||||
|
||||
/* Ident all the chips present. */
|
||||
DoC_ScanChips(this);
|
||||
if ((!this->numchips) || (!this->chips))
|
||||
return;
|
||||
|
||||
nftl = &this->nftl;
|
||||
|
||||
@@ -992,7 +999,7 @@ int doc_read_ecc(struct DiskOnChip* this, loff_t from, size_t len,
|
||||
printf("ECC needs a full sector read (adr: %lx size %lx)\n",
|
||||
(long) from, (long) len);
|
||||
|
||||
#ifdef PHYCH_DEBUG
|
||||
#ifdef PSYCHO_DEBUG
|
||||
printf("DoC_Read (adr: %lx size %lx)\n", (long) from, (long) len);
|
||||
#endif
|
||||
|
||||
|
||||
159
common/cmd_fat.c
159
common/cmd_fat.c
@@ -36,76 +36,179 @@
|
||||
|
||||
#include <fat.h>
|
||||
|
||||
extern block_dev_desc_t *ide_get_dev (int dev);
|
||||
|
||||
|
||||
|
||||
block_dev_desc_t *get_dev (char* ifname, int dev)
|
||||
{
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_IDE)
|
||||
if (strncmp(ifname,"ide",3)==0) {
|
||||
extern block_dev_desc_t * ide_get_dev(int dev);
|
||||
return(ide_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
|
||||
if (strncmp(ifname,"scsi",4)==0) {
|
||||
extern block_dev_desc_t * scsi_get_dev(int dev);
|
||||
return(scsi_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_USB) && defined(CONFIG_USB_STORAGE))
|
||||
if (strncmp(ifname,"usb",3)==0) {
|
||||
extern block_dev_desc_t * usb_stor_get_dev(int dev);
|
||||
return(usb_stor_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
#if defined(CONFIG_MMC)
|
||||
if (strncmp(ifname,"mmc",3)==0) {
|
||||
extern block_dev_desc_t * mmc_get_dev(int dev);
|
||||
return(mmc_get_dev(dev));
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int do_fat_fsload (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
long size;
|
||||
unsigned long offset;
|
||||
unsigned long count;
|
||||
block_dev_desc_t *dev_desc=NULL;
|
||||
int dev=0;
|
||||
int part=1;
|
||||
char *ep;
|
||||
|
||||
if (argc < 3) {
|
||||
printf ("usage:fatload <filename> <addr> [bytes]\n");
|
||||
if (argc < 5) {
|
||||
printf ("usage: fatload <interface> <dev[:part]> <addr> <filename> [bytes]\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
offset = simple_strtoul (argv[2], NULL, 16);
|
||||
if (argc == 4)
|
||||
count = simple_strtoul (argv[3], NULL, 16);
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
if (dev_desc==NULL) {
|
||||
puts ("\n** Invalid boot device **\n");
|
||||
return 1;
|
||||
}
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return 1;
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
if (fat_register_device(dev_desc,part)!=0) {
|
||||
printf ("\n** Unable to use %s %d:%d for fatload **\n",argv[1],dev,part);
|
||||
return 1;
|
||||
}
|
||||
offset = simple_strtoul (argv[3], NULL, 16);
|
||||
if (argc == 6)
|
||||
count = simple_strtoul (argv[5], NULL, 16);
|
||||
else
|
||||
count = 0;
|
||||
size = file_fat_read (argv[4], (unsigned char *) offset, count);
|
||||
|
||||
size = file_fat_read (argv[1], (unsigned char *) offset, count);
|
||||
|
||||
printf ("%ld bytes read\n", size);
|
||||
if(size==-1)
|
||||
printf("\n** Unable to read \"%s\" from %s %d:%d **\n",argv[4],argv[1],dev,part);
|
||||
else
|
||||
printf ("\n%ld bytes read\n", size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
U_BOOT_CMD(
|
||||
fatload, 4, 0, do_fat_fsload,
|
||||
fatload, 6, 0, do_fat_fsload,
|
||||
"fatload - load binary file from a dos filesystem\n",
|
||||
"[ off ] [ filename ]\n"
|
||||
" - load binary file from dos filesystem\n"
|
||||
" with offset 'off'\n"
|
||||
"<interface> <dev[:part]> <addr> <filename> [bytes]\n"
|
||||
" - load binary file 'filename' from 'dev' on 'interface'\n"
|
||||
" to address 'addr' from dos filesystem\n"
|
||||
);
|
||||
|
||||
int do_fat_ls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
char *filename = "/";
|
||||
int ret;
|
||||
int dev=0;
|
||||
int part=1;
|
||||
char *ep;
|
||||
block_dev_desc_t *dev_desc=NULL;
|
||||
|
||||
if (argc == 2)
|
||||
ret = file_fat_ls (argv[1]);
|
||||
if (argc < 3) {
|
||||
printf ("usage: fatls <interface> <dev[:part]> [directory]\n");
|
||||
return (0);
|
||||
}
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
if (dev_desc==NULL) {
|
||||
puts ("\n** Invalid boot device **\n");
|
||||
return 1;
|
||||
}
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return 1;
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
if (fat_register_device(dev_desc,part)!=0) {
|
||||
printf ("\n** Unable to use %s %d:%d for fatls **\n",argv[1],dev,part);
|
||||
return 1;
|
||||
}
|
||||
if (argc == 4)
|
||||
ret = file_fat_ls (argv[3]);
|
||||
else
|
||||
ret = file_fat_ls (filename);
|
||||
|
||||
if(ret!=0)
|
||||
printf("No Fat FS detected\n");
|
||||
return (ret);
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
fatls, 2, 1, do_fat_ls,
|
||||
fatls, 4, 1, do_fat_ls,
|
||||
"fatls - list files in a directory (default /)\n",
|
||||
"[ directory ]\n"
|
||||
" - list files in a directory\n"
|
||||
"<interface> <dev[:part]> [directory]\n"
|
||||
" - list files from 'dev' on 'interface' in a 'directory'\n"
|
||||
);
|
||||
|
||||
int do_fat_fsinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
int dev=0;
|
||||
int part=1;
|
||||
char *ep;
|
||||
block_dev_desc_t *dev_desc=NULL;
|
||||
|
||||
ret = 0;
|
||||
|
||||
printf ("FAT info: %d\n", file_fat_detectfs ());
|
||||
|
||||
return (ret);
|
||||
if (argc < 2) {
|
||||
printf ("usage: fatinfo <interface> <dev[:part]>\n");
|
||||
return (0);
|
||||
}
|
||||
dev = (int)simple_strtoul (argv[2], &ep, 16);
|
||||
dev_desc=get_dev(argv[1],dev);
|
||||
if (dev_desc==NULL) {
|
||||
puts ("\n** Invalid boot device **\n");
|
||||
return 1;
|
||||
}
|
||||
if (*ep) {
|
||||
if (*ep != ':') {
|
||||
puts ("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||
return 1;
|
||||
}
|
||||
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||
}
|
||||
if (fat_register_device(dev_desc,part)!=0) {
|
||||
printf ("\n** Unable to use %s %d:%d for fatinfo **\n",argv[1],dev,part);
|
||||
return 1;
|
||||
}
|
||||
return (file_fat_detectfs ());
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
fatinfo, 1, 1, do_fat_fsinfo,
|
||||
fatinfo, 3, 1, do_fat_fsinfo,
|
||||
"fatinfo - print information about filesystem\n",
|
||||
"\n"
|
||||
" - print information about filesystem\n"
|
||||
"<interface> <dev[:part]>\n"
|
||||
" - print information about filesystem from 'dev' on 'interface'\n"
|
||||
);
|
||||
|
||||
#ifdef NOT_IMPLEMENTED_YET
|
||||
|
||||
@@ -174,7 +174,7 @@ do_jffs2_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (jffs2_part_info(tmp_part)){
|
||||
printf("Partiton changed to %d\n",tmp_part);
|
||||
printf("Partition changed to %d\n",tmp_part);
|
||||
part_num=tmp_part;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ static int NanD_WaitReady(struct nand_chip *nand, int ale_wait)
|
||||
else
|
||||
udelay(10);
|
||||
#else /* has functional r/b signal */
|
||||
NAND_WAIT_READY(nand);
|
||||
NAND_WAIT_READY(nand);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
@@ -639,7 +639,9 @@ static int NanD_IdentChip(struct nand_chip *nand, int floor, int chip)
|
||||
NAND_DISABLE_CE(nand); /* set pin high */
|
||||
/* No response - return failure */
|
||||
if (mfr == 0xff || mfr == 0) {
|
||||
#ifdef NAND_DEBUG
|
||||
printf("NanD_Command (ReadID) got %d %d\n", mfr, id);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -732,7 +734,9 @@ static void NanD_ScanChips(struct nand_chip *nand)
|
||||
|
||||
/* If there are none at all that we recognise, bail */
|
||||
if (!nand->numchips) {
|
||||
puts ("No flash chips recognised.\n");
|
||||
#ifdef NAND_DEBUG
|
||||
puts ("No NAND flash chips recognised.\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1406,7 +1410,7 @@ static inline int nandcheck(unsigned long potential, unsigned long physadr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nand_probe(unsigned long physadr)
|
||||
unsigned long nand_probe(unsigned long physadr)
|
||||
{
|
||||
struct nand_chip *nand = NULL;
|
||||
int i = 0, ChipID = 1;
|
||||
@@ -1432,10 +1436,12 @@ void nand_probe(unsigned long physadr)
|
||||
|
||||
for (i=0; i<CFG_MAX_NAND_DEVICE; i++) {
|
||||
if (nand_dev_desc[i].ChipID == NAND_ChipID_UNKNOWN) {
|
||||
nand = nand_dev_desc + i;
|
||||
nand = &nand_dev_desc[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!nand)
|
||||
return (0);
|
||||
|
||||
memset((char *)nand, 0, sizeof(struct nand_chip));
|
||||
|
||||
@@ -1447,7 +1453,7 @@ void nand_probe(unsigned long physadr)
|
||||
/* no chips found, clean up and quit */
|
||||
memset((char *)nand, 0, sizeof(struct nand_chip));
|
||||
nand->ChipID = NAND_ChipID_UNKNOWN;
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
|
||||
nand->ChipID = ChipID;
|
||||
@@ -1457,8 +1463,10 @@ void nand_probe(unsigned long physadr)
|
||||
nand->data_buf = malloc (nand->oobblock + nand->oobsize);
|
||||
if (!nand->data_buf) {
|
||||
puts ("Cannot allocate memory for data structures.\n");
|
||||
return;
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (nand->totlen);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTD_NAND_ECC
|
||||
|
||||
@@ -54,7 +54,7 @@ int do_vfd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argv[1][0] == '#') { /* select bitmap by number */
|
||||
if (argv[1][0] == '/') { /* select bitmap by number */
|
||||
bitmap = simple_strtoul(argv[1]+1, NULL, 10);
|
||||
return (trab_vfd(bitmap));
|
||||
}
|
||||
@@ -68,8 +68,10 @@ int do_vfd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
U_BOOT_CMD(
|
||||
vfd, 2, 0, do_vfd,
|
||||
"vfd - load a bitmap to the VFDs on TRAB\n",
|
||||
"N\n"
|
||||
"/N\n"
|
||||
" - load bitmap N to the VFDs (N is _decimal_ !!!)\n"
|
||||
"vfd ADDR\n"
|
||||
" - load bitmap at address ADDR\n"
|
||||
);
|
||||
#endif /* CFG_CMD_VFD */
|
||||
|
||||
|
||||
@@ -27,5 +27,9 @@ void jumptable_init (void)
|
||||
#if defined(CONFIG_I386) || defined(CONFIG_PPC)
|
||||
gd->jt[XF_install_hdlr] = (void *) irq_install_handler;
|
||||
gd->jt[XF_free_hdlr] = (void *) irq_free_handler;
|
||||
#endif
|
||||
#endif /* I386 || PPC */
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_I2C)
|
||||
gd->jt[XF_i2c_write] = (void *) i2c_write;
|
||||
gd->jt[XF_i2c_read] = (void *) i2c_read;
|
||||
#endif /* CFG_CMD_I2C */
|
||||
}
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
* (C) Copyright 2001
|
||||
* Denis Peter, MPL AG Switzerland
|
||||
*
|
||||
* For BBB support (C) Copyright 2003
|
||||
* Gary Jennejohn, DENX Software Engineering <gj@denx.de>
|
||||
*
|
||||
* Most of this source has been derived from the Linux USB
|
||||
* project.
|
||||
* project. BBB support based on /sys/dev/usb/umass.c from
|
||||
* FreeBSD.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
@@ -30,6 +34,13 @@
|
||||
* is only tested with a TEAC USB Floppy. Other Massstorages with CBI or CB
|
||||
* transport protocoll may work as well.
|
||||
*/
|
||||
/*
|
||||
* New Note:
|
||||
* Support for USB Mass Storage Devices (BBB) has been added. It has
|
||||
* only been tested with USB memory sticks.
|
||||
* Nota bene: if you are using the BBB support with a little-endian
|
||||
* CPU then you MUST define LITTLEENDIAN in the configuration file!
|
||||
*/
|
||||
|
||||
|
||||
#include <common.h>
|
||||
@@ -71,6 +82,41 @@ static ccb usb_ccb;
|
||||
|
||||
#define US_CBI_ADSC 0
|
||||
|
||||
/*
|
||||
* BULK only
|
||||
*/
|
||||
#define US_BBB_RESET 0xff
|
||||
#define US_BBB_GET_MAX_LUN 0xfe
|
||||
|
||||
/* Command Block Wrapper */
|
||||
typedef struct {
|
||||
__u32 dCBWSignature;
|
||||
# define CBWSIGNATURE 0x43425355
|
||||
__u32 dCBWTag;
|
||||
__u32 dCBWDataTransferLength;
|
||||
__u8 bCBWFlags;
|
||||
# define CBWFLAGS_OUT 0x00
|
||||
# define CBWFLAGS_IN 0x80
|
||||
__u8 bCBWLUN;
|
||||
__u8 bCDBLength;
|
||||
# define CBWCDBLENGTH 16
|
||||
__u8 CBWCDB[CBWCDBLENGTH];
|
||||
} umass_bbb_cbw_t;
|
||||
#define UMASS_BBB_CBW_SIZE 31
|
||||
static __u32 CBWTag = 0;
|
||||
|
||||
/* Command Status Wrapper */
|
||||
typedef struct {
|
||||
__u32 dCSWSignature;
|
||||
# define CSWSIGNATURE 0x53425355
|
||||
__u32 dCSWTag;
|
||||
__u32 dCSWDataResidue;
|
||||
__u8 bCSWStatus;
|
||||
# define CSWSTATUS_GOOD 0x0
|
||||
# define CSWSTATUS_FAILED 0x1
|
||||
# define CSWSTATUS_PHASE 0x2
|
||||
} umass_bbb_csw_t;
|
||||
#define UMASS_BBB_CSW_SIZE 13
|
||||
|
||||
#define USB_MAX_STOR_DEV 5
|
||||
static int usb_max_devs; /* number of highest available usb device */
|
||||
@@ -138,6 +184,9 @@ int usb_stor_scan(int mode)
|
||||
unsigned char i;
|
||||
struct usb_device *dev;
|
||||
|
||||
/* GJ */
|
||||
memset(usb_stor_buf, 0, sizeof(usb_stor_buf));
|
||||
|
||||
if(mode==1) {
|
||||
printf("scanning bus for storage devices...\n");
|
||||
}
|
||||
@@ -293,6 +342,51 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usb_stor_BBB_reset(struct us_data *us)
|
||||
{
|
||||
int result;
|
||||
unsigned int pipe;
|
||||
|
||||
/*
|
||||
* Reset recovery (5.3.4 in Universal Serial Bus Mass Storage Class)
|
||||
*
|
||||
* For Reset Recovery the host shall issue in the following order:
|
||||
* a) a Bulk-Only Mass Storage Reset
|
||||
* b) a Clear Feature HALT to the Bulk-In endpoint
|
||||
* c) a Clear Feature HALT to the Bulk-Out endpoint
|
||||
*
|
||||
* This is done in 3 steps.
|
||||
*
|
||||
* If the reset doesn't succeed, the device should be port reset.
|
||||
*
|
||||
* This comment stolen from FreeBSD's /sys/dev/usb/umass.c.
|
||||
*/
|
||||
USB_STOR_PRINTF("BBB_reset\n");
|
||||
result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0),
|
||||
US_BBB_RESET, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
||||
0, us->ifnum, 0, 0, USB_CNTL_TIMEOUT*5);
|
||||
if((result < 0) && (us->pusb_dev->status & USB_ST_STALLED))
|
||||
{
|
||||
USB_STOR_PRINTF("RESET:stall\n");
|
||||
return -1;
|
||||
}
|
||||
/* long wait for reset */
|
||||
wait_ms(150);
|
||||
USB_STOR_PRINTF("BBB_reset result %d: status %X reset\n",result,us->pusb_dev->status);
|
||||
pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
|
||||
result = usb_clear_halt(us->pusb_dev, pipe);
|
||||
/* long wait for reset */
|
||||
wait_ms(150);
|
||||
USB_STOR_PRINTF("BBB_reset result %d: status %X clearing IN endpoint\n",result,us->pusb_dev->status);
|
||||
/* long wait for reset */
|
||||
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
|
||||
result = usb_clear_halt(us->pusb_dev, pipe);
|
||||
wait_ms(150);
|
||||
USB_STOR_PRINTF("BBB_reset result %d: status %X clearing OUT endpoint\n",result,us->pusb_dev->status);
|
||||
USB_STOR_PRINTF("BBB_reset done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: this reset function doesn't really reset the port, and it
|
||||
* should. Actually it should probably do what it's doing here, and
|
||||
* reset the port physically
|
||||
@@ -320,6 +414,52 @@ static int usb_stor_CB_reset(struct us_data *us)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the command for a BBB device. Note that the actual SCSI
|
||||
* command is copied into cbw.CBWCDB.
|
||||
*/
|
||||
int usb_stor_BBB_comdat(ccb *srb, struct us_data *us)
|
||||
{
|
||||
int result;
|
||||
int actlen;
|
||||
int dir_in;
|
||||
unsigned int pipe;
|
||||
umass_bbb_cbw_t cbw;
|
||||
|
||||
dir_in = US_DIRECTION(srb->cmd[0]);
|
||||
|
||||
#ifdef BBB_COMDAT_TRACE
|
||||
printf("dir %d lun %d cmdlen %d cmd %p datalen %d pdata %p\n", dir_in, srb->lun, srb->cmdlen, srb->cmd, srb->datalen, srb->pdata);
|
||||
if (srb->cmdlen) {
|
||||
for(result = 0;result < srb->cmdlen;result++)
|
||||
printf("cmd[%d] %#x ", result, srb->cmd[result]);
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
/* sanity checks */
|
||||
if (!(srb->cmdlen <= CBWCDBLENGTH)) {
|
||||
USB_STOR_PRINTF("usb_stor_BBB_comdat:cmdlen too large\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* always OUT to the ep */
|
||||
pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
|
||||
|
||||
cbw.dCBWSignature = swap_32(CBWSIGNATURE);
|
||||
cbw.dCBWTag = swap_32(CBWTag++);
|
||||
cbw.dCBWDataTransferLength = swap_32(srb->datalen);
|
||||
cbw.bCBWFlags = (dir_in? CBWFLAGS_IN : CBWFLAGS_OUT);
|
||||
cbw.bCBWLUN = srb->lun;
|
||||
cbw.bCDBLength = srb->cmdlen;
|
||||
/* copy the command data into the CBW command data buffer */
|
||||
/* DST SRC LEN!!! */
|
||||
memcpy(cbw.CBWCDB, srb->cmd, srb->cmdlen);
|
||||
result = usb_bulk_msg(us->pusb_dev, pipe, &cbw, UMASS_BBB_CBW_SIZE, &actlen, USB_CNTL_TIMEOUT*5);
|
||||
if (result < 0)
|
||||
USB_STOR_PRINTF("usb_stor_BBB_comdat:usb_bulk_msg error\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
/* FIXME: we also need a CBI_command which sets up the completion
|
||||
* interrupt, and waits for it
|
||||
*/
|
||||
@@ -422,6 +562,134 @@ int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
|
||||
#define USB_TRANSPORT_UNKNOWN_RETRY 5
|
||||
#define USB_TRANSPORT_NOT_READY_RETRY 10
|
||||
|
||||
/* clear a stall on an endpoint - special for BBB devices */
|
||||
int usb_stor_BBB_clear_endpt_stall(struct us_data *us, __u8 endpt)
|
||||
{
|
||||
int result;
|
||||
|
||||
/* ENDPOINT_HALT = 0, so set value to 0 */
|
||||
result = usb_control_msg(us->pusb_dev, usb_sndctrlpipe(us->pusb_dev,0),
|
||||
USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT,
|
||||
0, endpt, 0, 0, USB_CNTL_TIMEOUT*5);
|
||||
return result;
|
||||
}
|
||||
|
||||
int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
|
||||
{
|
||||
int result, retry;
|
||||
int dir_in;
|
||||
int actlen, data_actlen;
|
||||
unsigned int pipe, pipein, pipeout;
|
||||
umass_bbb_csw_t csw;
|
||||
#ifdef BBB_XPORT_TRACE
|
||||
unsigned char *ptr;
|
||||
int index;
|
||||
#endif
|
||||
|
||||
dir_in = US_DIRECTION(srb->cmd[0]);
|
||||
|
||||
/* COMMAND phase */
|
||||
USB_STOR_PRINTF("COMMAND phase\n");
|
||||
result = usb_stor_BBB_comdat(srb, us);
|
||||
if (result < 0) {
|
||||
USB_STOR_PRINTF("failed to send CBW status %ld\n",
|
||||
us->pusb_dev->status);
|
||||
usb_stor_BBB_reset(us);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
}
|
||||
wait_ms(5);
|
||||
pipein = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
|
||||
pipeout = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
|
||||
/* DATA phase + error handling */
|
||||
USB_STOR_PRINTF("DATA phase\n");
|
||||
data_actlen = 0;
|
||||
/* no data, go immediately to the STATUS phase */
|
||||
if (srb->datalen == 0)
|
||||
goto st;
|
||||
if (dir_in)
|
||||
pipe = pipein;
|
||||
else
|
||||
pipe = pipeout;
|
||||
result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata, srb->datalen, &data_actlen, USB_CNTL_TIMEOUT*5);
|
||||
/* special handling of STALL in DATA phase */
|
||||
if((result < 0) && (us->pusb_dev->status & USB_ST_STALLED)) {
|
||||
USB_STOR_PRINTF("DATA:stall\n");
|
||||
/* clear the STALL on the endpoint */
|
||||
result = usb_stor_BBB_clear_endpt_stall(us, dir_in? us->ep_in : us->ep_out);
|
||||
if (result >= 0)
|
||||
/* continue on to STATUS phase */
|
||||
goto st;
|
||||
}
|
||||
if (result < 0) {
|
||||
USB_STOR_PRINTF("usb_bulk_msg error status %ld\n",
|
||||
us->pusb_dev->status);
|
||||
usb_stor_BBB_reset(us);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
}
|
||||
#ifdef BBB_XPORT_TRACE
|
||||
for (index = 0; index < data_actlen; index++)
|
||||
printf("pdata[%d] %#x ", index, srb->pdata[index]);
|
||||
printf("\n");
|
||||
#endif
|
||||
/* STATUS phase + error handling */
|
||||
st:
|
||||
retry = 0;
|
||||
again:
|
||||
USB_STOR_PRINTF("STATUS phase\n");
|
||||
result = usb_bulk_msg(us->pusb_dev, pipein, &csw, UMASS_BBB_CSW_SIZE, &actlen, USB_CNTL_TIMEOUT*5);
|
||||
/* special handling of STALL in STATUS phase */
|
||||
if((result < 0) && (retry < 1) && (us->pusb_dev->status & USB_ST_STALLED)) {
|
||||
USB_STOR_PRINTF("STATUS:stall\n");
|
||||
/* clear the STALL on the endpoint */
|
||||
result = usb_stor_BBB_clear_endpt_stall(us, us->ep_in);
|
||||
if (result >= 0 && (retry++ < 1))
|
||||
/* do a retry */
|
||||
goto again;
|
||||
}
|
||||
if (result < 0) {
|
||||
USB_STOR_PRINTF("usb_bulk_msg error status %ld\n",
|
||||
us->pusb_dev->status);
|
||||
usb_stor_BBB_reset(us);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
}
|
||||
#ifdef BBB_XPORT_TRACE
|
||||
ptr = (unsigned char *)&csw;
|
||||
for (index = 0; index < UMASS_BBB_CSW_SIZE; index++)
|
||||
printf("ptr[%d] %#x ", index, ptr[index]);
|
||||
printf("\n");
|
||||
#endif
|
||||
/* misuse pipe to get the residue */
|
||||
pipe = swap_32(csw.dCSWDataResidue);
|
||||
if (pipe == 0 && srb->datalen != 0 && srb->datalen - data_actlen != 0)
|
||||
pipe = srb->datalen - data_actlen;
|
||||
if (CSWSIGNATURE != swap_32(csw.dCSWSignature)) {
|
||||
USB_STOR_PRINTF("!CSWSIGNATURE\n");
|
||||
usb_stor_BBB_reset(us);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
} else if ((CBWTag - 1) != swap_32(csw.dCSWTag)) {
|
||||
USB_STOR_PRINTF("!Tag\n");
|
||||
usb_stor_BBB_reset(us);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
} else if (csw.bCSWStatus > CSWSTATUS_PHASE) {
|
||||
USB_STOR_PRINTF(">PHASE\n");
|
||||
usb_stor_BBB_reset(us);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
} else if (csw.bCSWStatus == CSWSTATUS_PHASE) {
|
||||
USB_STOR_PRINTF("=PHASE\n");
|
||||
usb_stor_BBB_reset(us);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
} else if (data_actlen > srb->datalen) {
|
||||
USB_STOR_PRINTF("transferred %dB instead of %dB\n",
|
||||
data_actlen, srb->datalen);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
} else if (csw.bCSWStatus == CSWSTATUS_FAILED) {
|
||||
USB_STOR_PRINTF("FAILED\n");
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int usb_stor_CB_transport(ccb *srb, struct us_data *us)
|
||||
{
|
||||
int result,status;
|
||||
@@ -495,29 +763,28 @@ do_retry:
|
||||
return USB_STOR_TRANSPORT_GOOD;
|
||||
/* Check the auto request result */
|
||||
switch(srb->sense_buf[2]) {
|
||||
case 0x01: /* Recovered Error */
|
||||
return USB_STOR_TRANSPORT_GOOD;
|
||||
break;
|
||||
case 0x02: /* Not Ready */
|
||||
if(notready++ > USB_TRANSPORT_NOT_READY_RETRY) {
|
||||
printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X 0x%02X (NOT READY)\n",
|
||||
srb->cmd[0],srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
}
|
||||
else {
|
||||
wait_ms(100);
|
||||
goto do_retry;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(retry++ > USB_TRANSPORT_UNKNOWN_RETRY) {
|
||||
printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||
srb->cmd[0],srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
}
|
||||
else
|
||||
goto do_retry;
|
||||
break;
|
||||
case 0x01: /* Recovered Error */
|
||||
return USB_STOR_TRANSPORT_GOOD;
|
||||
break;
|
||||
case 0x02: /* Not Ready */
|
||||
if(notready++ > USB_TRANSPORT_NOT_READY_RETRY) {
|
||||
printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X 0x%02X (NOT READY)\n",
|
||||
srb->cmd[0],srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
} else {
|
||||
wait_ms(100);
|
||||
goto do_retry;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if(retry++ > USB_TRANSPORT_UNKNOWN_RETRY) {
|
||||
printf("cmd 0x%02X returned 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||
srb->cmd[0],srb->sense_buf[0],srb->sense_buf[2],srb->sense_buf[12],srb->sense_buf[13]);
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
} else {
|
||||
goto do_retry;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return USB_STOR_TRANSPORT_FAILED;
|
||||
}
|
||||
@@ -538,7 +805,8 @@ static int usb_inquiry(ccb *srb,struct us_data *ss)
|
||||
USB_STOR_PRINTF("inquiry returns %d\n",i);
|
||||
if(i==0)
|
||||
break;
|
||||
}while(retry--);
|
||||
} while(retry--);
|
||||
|
||||
if(!retry) {
|
||||
printf("error in inquiry\n");
|
||||
return -1;
|
||||
@@ -567,17 +835,18 @@ static int usb_request_sense(ccb *srb,struct us_data *ss)
|
||||
static int usb_test_unit_ready(ccb *srb,struct us_data *ss)
|
||||
{
|
||||
int retries=10;
|
||||
|
||||
do {
|
||||
memset(&srb->cmd[0],0,12);
|
||||
srb->cmd[0]=SCSI_TST_U_RDY;
|
||||
srb->cmd[1]=srb->lun<<5;
|
||||
srb->datalen=0;
|
||||
srb->cmdlen=12;
|
||||
if(ss->transport(srb,ss)==USB_STOR_TRANSPORT_GOOD)
|
||||
{
|
||||
if(ss->transport(srb,ss)==USB_STOR_TRANSPORT_GOOD) {
|
||||
return 0;
|
||||
}
|
||||
} while(retries--);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -594,7 +863,8 @@ static int usb_read_capacity(ccb *srb,struct us_data *ss)
|
||||
if(ss->transport(srb,ss)==USB_STOR_TRANSPORT_GOOD) {
|
||||
return 0;
|
||||
}
|
||||
}while(retry--);
|
||||
} while(retry--);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -654,8 +924,7 @@ unsigned long usb_stor_read(int device, unsigned long blknr, unsigned long blkcn
|
||||
srb->pdata=(unsigned char *)buf_addr;
|
||||
if(blks>USB_MAX_READ_BLK) {
|
||||
smallblks=USB_MAX_READ_BLK;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
smallblks=(unsigned short) blks;
|
||||
}
|
||||
retry_it:
|
||||
@@ -751,6 +1020,11 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data
|
||||
ss->transport = usb_stor_CB_transport;
|
||||
ss->transport_reset = usb_stor_CB_reset;
|
||||
break;
|
||||
case US_PR_BULK:
|
||||
USB_STOR_PRINTF("Bulk/Bulk/Bulk\n");
|
||||
ss->transport = usb_stor_BBB_transport;
|
||||
ss->transport_reset = usb_stor_BBB_reset;
|
||||
break;
|
||||
default:
|
||||
printf("USB Starage Transport unknown / not yet implemented\n");
|
||||
return 0;
|
||||
@@ -793,23 +1067,22 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data
|
||||
return 0;
|
||||
}
|
||||
/* set class specific stuff */
|
||||
/* We only handle certain protocols. Currently, this is
|
||||
* the only one.
|
||||
/* We only handle certain protocols. Currently, these are
|
||||
* the only ones.
|
||||
*/
|
||||
if (ss->subclass != US_SC_UFI) {
|
||||
if (ss->subclass != US_SC_UFI && ss->subclass != US_SC_SCSI) {
|
||||
printf("Sorry, protocol %d not yet supported.\n",ss->subclass);
|
||||
return 0;
|
||||
}
|
||||
if(ss->ep_int) /* we had found an interrupt endpoint, prepare irq pipe */
|
||||
{
|
||||
if(ss->ep_int) { /* we had found an interrupt endpoint, prepare irq pipe */
|
||||
/* set up the IRQ pipe and handler */
|
||||
|
||||
ss->irqinterval = (ss->irqinterval > 0) ? ss->irqinterval : 255;
|
||||
ss->irqpipe = usb_rcvintpipe(ss->pusb_dev, ss->ep_int);
|
||||
ss->irqmaxp = usb_maxpacket(dev, ss->irqpipe);
|
||||
dev->irq_handle=usb_stor_irq;
|
||||
dev->privptr=(void *)ss;
|
||||
}
|
||||
dev->privptr=(void *)ss;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -865,6 +1138,19 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
|
||||
if(cap[0]>(0x200000 * 10)) /* greater than 10 GByte */
|
||||
cap[0]>>=16;
|
||||
#endif
|
||||
#ifdef LITTLEENDIAN
|
||||
cap[0] = ((unsigned long)(
|
||||
(((unsigned long)(cap[0]) & (unsigned long)0x000000ffUL) << 24) |
|
||||
(((unsigned long)(cap[0]) & (unsigned long)0x0000ff00UL) << 8) |
|
||||
(((unsigned long)(cap[0]) & (unsigned long)0x00ff0000UL) >> 8) |
|
||||
(((unsigned long)(cap[0]) & (unsigned long)0xff000000UL) >> 24) ));
|
||||
cap[1] = ((unsigned long)(
|
||||
(((unsigned long)(cap[1]) & (unsigned long)0x000000ffUL) << 24) |
|
||||
(((unsigned long)(cap[1]) & (unsigned long)0x0000ff00UL) << 8) |
|
||||
(((unsigned long)(cap[1]) & (unsigned long)0x00ff0000UL) >> 8) |
|
||||
(((unsigned long)(cap[1]) & (unsigned long)0xff000000UL) >> 24) ));
|
||||
#endif
|
||||
/* this assumes bigendian! */
|
||||
cap[0]+=1;
|
||||
capacity=&cap[0];
|
||||
blksz=&cap[1];
|
||||
@@ -881,5 +1167,5 @@ int usb_stor_get_info(struct usb_device *dev,struct us_data *ss,block_dev_desc_t
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* CONFIG_USB_STORAGE */
|
||||
#endif /* CFG_CMD_USB */
|
||||
|
||||
@@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
|
||||
LIB = lib$(CPU).a
|
||||
|
||||
START = start.o
|
||||
OBJS = serial.o interrupts.o cpu.o speed.o
|
||||
OBJS = serial.o interrupts.o cpu.o speed.o usb_ohci.o
|
||||
|
||||
all: .depend $(START) $(LIB)
|
||||
|
||||
|
||||
1560
cpu/arm920t/usb_ohci.c
Normal file
1560
cpu/arm920t/usb_ohci.c
Normal file
File diff suppressed because it is too large
Load Diff
420
cpu/arm920t/usb_ohci.h
Normal file
420
cpu/arm920t/usb_ohci.h
Normal file
@@ -0,0 +1,420 @@
|
||||
/*
|
||||
* URB OHCI HCD (Host Controller Driver) for USB.
|
||||
*
|
||||
* (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
|
||||
* (C) Copyright 2000-2001 David Brownell <dbrownell@users.sourceforge.net>
|
||||
*
|
||||
* usb-ohci.h
|
||||
*/
|
||||
|
||||
|
||||
static int cc_to_error[16] = {
|
||||
|
||||
/* mapping of the OHCI CC status to error codes */
|
||||
/* No Error */ 0,
|
||||
/* CRC Error */ USB_ST_CRC_ERR,
|
||||
/* Bit Stuff */ USB_ST_BIT_ERR,
|
||||
/* Data Togg */ USB_ST_CRC_ERR,
|
||||
/* Stall */ USB_ST_STALLED,
|
||||
/* DevNotResp */ -1,
|
||||
/* PIDCheck */ USB_ST_BIT_ERR,
|
||||
/* UnExpPID */ USB_ST_BIT_ERR,
|
||||
/* DataOver */ USB_ST_BUF_ERR,
|
||||
/* DataUnder */ USB_ST_BUF_ERR,
|
||||
/* reservd */ -1,
|
||||
/* reservd */ -1,
|
||||
/* BufferOver */ USB_ST_BUF_ERR,
|
||||
/* BuffUnder */ USB_ST_BUF_ERR,
|
||||
/* Not Access */ -1,
|
||||
/* Not Access */ -1
|
||||
};
|
||||
|
||||
/* ED States */
|
||||
|
||||
#define ED_NEW 0x00
|
||||
#define ED_UNLINK 0x01
|
||||
#define ED_OPER 0x02
|
||||
#define ED_DEL 0x04
|
||||
#define ED_URB_DEL 0x08
|
||||
|
||||
/* usb_ohci_ed */
|
||||
struct ed {
|
||||
__u32 hwINFO;
|
||||
__u32 hwTailP;
|
||||
__u32 hwHeadP;
|
||||
__u32 hwNextED;
|
||||
|
||||
struct ed *ed_prev;
|
||||
__u8 int_period;
|
||||
__u8 int_branch;
|
||||
__u8 int_load;
|
||||
__u8 int_interval;
|
||||
__u8 state;
|
||||
__u8 type;
|
||||
__u16 last_iso;
|
||||
struct ed *ed_rm_list;
|
||||
|
||||
struct usb_device *usb_dev;
|
||||
__u32 unused[3];
|
||||
} __attribute((aligned(16)));
|
||||
typedef struct ed ed_t;
|
||||
|
||||
|
||||
/* TD info field */
|
||||
#define TD_CC 0xf0000000
|
||||
#define TD_CC_GET(td_p) ((td_p >>28) & 0x0f)
|
||||
#define TD_CC_SET(td_p, cc) (td_p) = ((td_p) & 0x0fffffff) | (((cc) & 0x0f) << 28)
|
||||
#define TD_EC 0x0C000000
|
||||
#define TD_T 0x03000000
|
||||
#define TD_T_DATA0 0x02000000
|
||||
#define TD_T_DATA1 0x03000000
|
||||
#define TD_T_TOGGLE 0x00000000
|
||||
#define TD_R 0x00040000
|
||||
#define TD_DI 0x00E00000
|
||||
#define TD_DI_SET(X) (((X) & 0x07)<< 21)
|
||||
#define TD_DP 0x00180000
|
||||
#define TD_DP_SETUP 0x00000000
|
||||
#define TD_DP_IN 0x00100000
|
||||
#define TD_DP_OUT 0x00080000
|
||||
|
||||
#define TD_ISO 0x00010000
|
||||
#define TD_DEL 0x00020000
|
||||
|
||||
/* CC Codes */
|
||||
#define TD_CC_NOERROR 0x00
|
||||
#define TD_CC_CRC 0x01
|
||||
#define TD_CC_BITSTUFFING 0x02
|
||||
#define TD_CC_DATATOGGLEM 0x03
|
||||
#define TD_CC_STALL 0x04
|
||||
#define TD_DEVNOTRESP 0x05
|
||||
#define TD_PIDCHECKFAIL 0x06
|
||||
#define TD_UNEXPECTEDPID 0x07
|
||||
#define TD_DATAOVERRUN 0x08
|
||||
#define TD_DATAUNDERRUN 0x09
|
||||
#define TD_BUFFEROVERRUN 0x0C
|
||||
#define TD_BUFFERUNDERRUN 0x0D
|
||||
#define TD_NOTACCESSED 0x0F
|
||||
|
||||
|
||||
#define MAXPSW 1
|
||||
|
||||
struct td {
|
||||
__u32 hwINFO;
|
||||
__u32 hwCBP; /* Current Buffer Pointer */
|
||||
__u32 hwNextTD; /* Next TD Pointer */
|
||||
__u32 hwBE; /* Memory Buffer End Pointer */
|
||||
|
||||
__u16 hwPSW[MAXPSW];
|
||||
__u8 unused;
|
||||
__u8 index;
|
||||
struct ed *ed;
|
||||
struct td *next_dl_td;
|
||||
struct usb_device *usb_dev;
|
||||
int transfer_len;
|
||||
__u32 data;
|
||||
|
||||
__u32 unused2[2];
|
||||
} __attribute((aligned(32)));
|
||||
typedef struct td td_t;
|
||||
|
||||
#define OHCI_ED_SKIP (1 << 14)
|
||||
|
||||
/*
|
||||
* The HCCA (Host Controller Communications Area) is a 256 byte
|
||||
* structure defined in the OHCI spec. that the host controller is
|
||||
* told the base address of. It must be 256-byte aligned.
|
||||
*/
|
||||
|
||||
#define NUM_INTS 32 /* part of the OHCI standard */
|
||||
struct ohci_hcca {
|
||||
__u32 int_table[NUM_INTS]; /* Interrupt ED table */
|
||||
__u16 frame_no; /* current frame number */
|
||||
__u16 pad1; /* set to 0 on each frame_no change */
|
||||
__u32 done_head; /* info returned for an interrupt */
|
||||
u8 reserved_for_hc[116];
|
||||
} __attribute((aligned(256)));
|
||||
|
||||
|
||||
/*
|
||||
* Maximum number of root hub ports.
|
||||
*/
|
||||
#define MAX_ROOT_PORTS 15 /* maximum OHCI root hub ports */
|
||||
|
||||
/*
|
||||
* This is the structure of the OHCI controller's memory mapped I/O
|
||||
* region. This is Memory Mapped I/O. You must use the readl() and
|
||||
* writel() macros defined in asm/io.h to access these!!
|
||||
*/
|
||||
struct ohci_regs {
|
||||
/* control and status registers */
|
||||
__u32 revision;
|
||||
__u32 control;
|
||||
__u32 cmdstatus;
|
||||
__u32 intrstatus;
|
||||
__u32 intrenable;
|
||||
__u32 intrdisable;
|
||||
/* memory pointers */
|
||||
__u32 hcca;
|
||||
__u32 ed_periodcurrent;
|
||||
__u32 ed_controlhead;
|
||||
__u32 ed_controlcurrent;
|
||||
__u32 ed_bulkhead;
|
||||
__u32 ed_bulkcurrent;
|
||||
__u32 donehead;
|
||||
/* frame counters */
|
||||
__u32 fminterval;
|
||||
__u32 fmremaining;
|
||||
__u32 fmnumber;
|
||||
__u32 periodicstart;
|
||||
__u32 lsthresh;
|
||||
/* Root hub ports */
|
||||
struct ohci_roothub_regs {
|
||||
__u32 a;
|
||||
__u32 b;
|
||||
__u32 status;
|
||||
__u32 portstatus[MAX_ROOT_PORTS];
|
||||
} roothub;
|
||||
} __attribute((aligned(32)));
|
||||
|
||||
|
||||
/* OHCI CONTROL AND STATUS REGISTER MASKS */
|
||||
|
||||
/*
|
||||
* HcControl (control) register masks
|
||||
*/
|
||||
#define OHCI_CTRL_CBSR (3 << 0) /* control/bulk service ratio */
|
||||
#define OHCI_CTRL_PLE (1 << 2) /* periodic list enable */
|
||||
#define OHCI_CTRL_IE (1 << 3) /* isochronous enable */
|
||||
#define OHCI_CTRL_CLE (1 << 4) /* control list enable */
|
||||
#define OHCI_CTRL_BLE (1 << 5) /* bulk list enable */
|
||||
#define OHCI_CTRL_HCFS (3 << 6) /* host controller functional state */
|
||||
#define OHCI_CTRL_IR (1 << 8) /* interrupt routing */
|
||||
#define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */
|
||||
#define OHCI_CTRL_RWE (1 << 10) /* remote wakeup enable */
|
||||
|
||||
/* pre-shifted values for HCFS */
|
||||
# define OHCI_USB_RESET (0 << 6)
|
||||
# define OHCI_USB_RESUME (1 << 6)
|
||||
# define OHCI_USB_OPER (2 << 6)
|
||||
# define OHCI_USB_SUSPEND (3 << 6)
|
||||
|
||||
/*
|
||||
* HcCommandStatus (cmdstatus) register masks
|
||||
*/
|
||||
#define OHCI_HCR (1 << 0) /* host controller reset */
|
||||
#define OHCI_CLF (1 << 1) /* control list filled */
|
||||
#define OHCI_BLF (1 << 2) /* bulk list filled */
|
||||
#define OHCI_OCR (1 << 3) /* ownership change request */
|
||||
#define OHCI_SOC (3 << 16) /* scheduling overrun count */
|
||||
|
||||
/*
|
||||
* masks used with interrupt registers:
|
||||
* HcInterruptStatus (intrstatus)
|
||||
* HcInterruptEnable (intrenable)
|
||||
* HcInterruptDisable (intrdisable)
|
||||
*/
|
||||
#define OHCI_INTR_SO (1 << 0) /* scheduling overrun */
|
||||
#define OHCI_INTR_WDH (1 << 1) /* writeback of done_head */
|
||||
#define OHCI_INTR_SF (1 << 2) /* start frame */
|
||||
#define OHCI_INTR_RD (1 << 3) /* resume detect */
|
||||
#define OHCI_INTR_UE (1 << 4) /* unrecoverable error */
|
||||
#define OHCI_INTR_FNO (1 << 5) /* frame number overflow */
|
||||
#define OHCI_INTR_RHSC (1 << 6) /* root hub status change */
|
||||
#define OHCI_INTR_OC (1 << 30) /* ownership change */
|
||||
#define OHCI_INTR_MIE (1 << 31) /* master interrupt enable */
|
||||
|
||||
|
||||
|
||||
/* Virtual Root HUB */
|
||||
struct virt_root_hub {
|
||||
int devnum; /* Address of Root Hub endpoint */
|
||||
void *dev; /* was urb */
|
||||
void *int_addr;
|
||||
int send;
|
||||
int interval;
|
||||
};
|
||||
|
||||
/* USB HUB CONSTANTS (not OHCI-specific; see hub.h) */
|
||||
|
||||
/* destination of request */
|
||||
#define RH_INTERFACE 0x01
|
||||
#define RH_ENDPOINT 0x02
|
||||
#define RH_OTHER 0x03
|
||||
|
||||
#define RH_CLASS 0x20
|
||||
#define RH_VENDOR 0x40
|
||||
|
||||
/* Requests: bRequest << 8 | bmRequestType */
|
||||
#define RH_GET_STATUS 0x0080
|
||||
#define RH_CLEAR_FEATURE 0x0100
|
||||
#define RH_SET_FEATURE 0x0300
|
||||
#define RH_SET_ADDRESS 0x0500
|
||||
#define RH_GET_DESCRIPTOR 0x0680
|
||||
#define RH_SET_DESCRIPTOR 0x0700
|
||||
#define RH_GET_CONFIGURATION 0x0880
|
||||
#define RH_SET_CONFIGURATION 0x0900
|
||||
#define RH_GET_STATE 0x0280
|
||||
#define RH_GET_INTERFACE 0x0A80
|
||||
#define RH_SET_INTERFACE 0x0B00
|
||||
#define RH_SYNC_FRAME 0x0C80
|
||||
/* Our Vendor Specific Request */
|
||||
#define RH_SET_EP 0x2000
|
||||
|
||||
|
||||
/* Hub port features */
|
||||
#define RH_PORT_CONNECTION 0x00
|
||||
#define RH_PORT_ENABLE 0x01
|
||||
#define RH_PORT_SUSPEND 0x02
|
||||
#define RH_PORT_OVER_CURRENT 0x03
|
||||
#define RH_PORT_RESET 0x04
|
||||
#define RH_PORT_POWER 0x08
|
||||
#define RH_PORT_LOW_SPEED 0x09
|
||||
|
||||
#define RH_C_PORT_CONNECTION 0x10
|
||||
#define RH_C_PORT_ENABLE 0x11
|
||||
#define RH_C_PORT_SUSPEND 0x12
|
||||
#define RH_C_PORT_OVER_CURRENT 0x13
|
||||
#define RH_C_PORT_RESET 0x14
|
||||
|
||||
/* Hub features */
|
||||
#define RH_C_HUB_LOCAL_POWER 0x00
|
||||
#define RH_C_HUB_OVER_CURRENT 0x01
|
||||
|
||||
#define RH_DEVICE_REMOTE_WAKEUP 0x00
|
||||
#define RH_ENDPOINT_STALL 0x01
|
||||
|
||||
#define RH_ACK 0x01
|
||||
#define RH_REQ_ERR -1
|
||||
#define RH_NACK 0x00
|
||||
|
||||
|
||||
/* OHCI ROOT HUB REGISTER MASKS */
|
||||
|
||||
/* roothub.portstatus [i] bits */
|
||||
#define RH_PS_CCS 0x00000001 /* current connect status */
|
||||
#define RH_PS_PES 0x00000002 /* port enable status*/
|
||||
#define RH_PS_PSS 0x00000004 /* port suspend status */
|
||||
#define RH_PS_POCI 0x00000008 /* port over current indicator */
|
||||
#define RH_PS_PRS 0x00000010 /* port reset status */
|
||||
#define RH_PS_PPS 0x00000100 /* port power status */
|
||||
#define RH_PS_LSDA 0x00000200 /* low speed device attached */
|
||||
#define RH_PS_CSC 0x00010000 /* connect status change */
|
||||
#define RH_PS_PESC 0x00020000 /* port enable status change */
|
||||
#define RH_PS_PSSC 0x00040000 /* port suspend status change */
|
||||
#define RH_PS_OCIC 0x00080000 /* over current indicator change */
|
||||
#define RH_PS_PRSC 0x00100000 /* port reset status change */
|
||||
|
||||
/* roothub.status bits */
|
||||
#define RH_HS_LPS 0x00000001 /* local power status */
|
||||
#define RH_HS_OCI 0x00000002 /* over current indicator */
|
||||
#define RH_HS_DRWE 0x00008000 /* device remote wakeup enable */
|
||||
#define RH_HS_LPSC 0x00010000 /* local power status change */
|
||||
#define RH_HS_OCIC 0x00020000 /* over current indicator change */
|
||||
#define RH_HS_CRWE 0x80000000 /* clear remote wakeup enable */
|
||||
|
||||
/* roothub.b masks */
|
||||
#define RH_B_DR 0x0000ffff /* device removable flags */
|
||||
#define RH_B_PPCM 0xffff0000 /* port power control mask */
|
||||
|
||||
/* roothub.a masks */
|
||||
#define RH_A_NDP (0xff << 0) /* number of downstream ports */
|
||||
#define RH_A_PSM (1 << 8) /* power switching mode */
|
||||
#define RH_A_NPS (1 << 9) /* no power switching */
|
||||
#define RH_A_DT (1 << 10) /* device type (mbz) */
|
||||
#define RH_A_OCPM (1 << 11) /* over current protection mode */
|
||||
#define RH_A_NOCP (1 << 12) /* no over current protection */
|
||||
#define RH_A_POTPGT (0xff << 24) /* power on to power good time */
|
||||
|
||||
/* urb */
|
||||
#define N_URB_TD 48
|
||||
typedef struct
|
||||
{
|
||||
ed_t *ed;
|
||||
__u16 length; /* number of tds associated with this request */
|
||||
__u16 td_cnt; /* number of tds already serviced */
|
||||
int state;
|
||||
unsigned long pipe;
|
||||
int actual_length;
|
||||
td_t *td[N_URB_TD]; /* list pointer to all corresponding TDs associated with this request */
|
||||
} urb_priv_t;
|
||||
#define URB_DEL 1
|
||||
|
||||
/*
|
||||
* This is the full ohci controller description
|
||||
*
|
||||
* Note how the "proper" USB information is just
|
||||
* a subset of what the full implementation needs. (Linus)
|
||||
*/
|
||||
|
||||
|
||||
typedef struct ohci {
|
||||
struct ohci_hcca *hcca; /* hcca */
|
||||
/*dma_addr_t hcca_dma;*/
|
||||
|
||||
int irq;
|
||||
int disabled; /* e.g. got a UE, we're hung */
|
||||
int sleeping;
|
||||
unsigned long flags; /* for HC bugs */
|
||||
|
||||
struct ohci_regs *regs; /* OHCI controller's memory */
|
||||
|
||||
ed_t *ed_rm_list[2]; /* lists of all endpoints to be removed */
|
||||
ed_t *ed_bulktail; /* last endpoint of bulk list */
|
||||
ed_t *ed_controltail; /* last endpoint of control list */
|
||||
int intrstatus;
|
||||
__u32 hc_control; /* copy of the hc control reg */
|
||||
struct usb_device *dev[32];
|
||||
struct virt_root_hub rh;
|
||||
|
||||
const char *slot_name;
|
||||
} ohci_t;
|
||||
|
||||
#define NUM_EDS 8 /* num of preallocated endpoint descriptors */
|
||||
|
||||
struct ohci_device {
|
||||
ed_t ed[NUM_EDS];
|
||||
int ed_cnt;
|
||||
};
|
||||
|
||||
/* hcd */
|
||||
/* endpoint */
|
||||
static int ep_link(ohci_t * ohci, ed_t * ed);
|
||||
static int ep_unlink(ohci_t * ohci, ed_t * ed);
|
||||
static ed_t * ep_add_ed(struct usb_device * usb_dev, unsigned long pipe);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/* we need more TDs than EDs */
|
||||
#define NUM_TD 64
|
||||
|
||||
/* +1 so we can align the storage */
|
||||
td_t gtd[NUM_TD+1];
|
||||
/* pointers to aligned storage */
|
||||
td_t *ptd;
|
||||
|
||||
/* TDs ... */
|
||||
static inline struct td *
|
||||
td_alloc (struct usb_device *usb_dev)
|
||||
{
|
||||
int i;
|
||||
struct td *td;
|
||||
|
||||
td = NULL;
|
||||
for (i = 0; i < NUM_TD; i++)
|
||||
{
|
||||
if (ptd[i].usb_dev == NULL)
|
||||
{
|
||||
td = &ptd[i];
|
||||
td->usb_dev = usb_dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return td;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ed_free (struct ed *ed)
|
||||
{
|
||||
ed->usb_dev = NULL;
|
||||
}
|
||||
@@ -24,14 +24,6 @@
|
||||
#include <common.h>
|
||||
#include <mpc5xxx.h>
|
||||
|
||||
#if defined(CONFIG_MGT5100)
|
||||
#define START_REG(start) ((start) >> 15)
|
||||
#define STOP_REG(start, size) (((start) + (size) - 1) >> 15)
|
||||
#elif defined(CONFIG_MPC5200)
|
||||
#define START_REG(start) ((start) >> 16)
|
||||
#define STOP_REG(start, size) (((start) + (size) - 1) >> 16)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Breath some life into the CPU...
|
||||
*
|
||||
@@ -159,6 +151,14 @@ void cpu_init_f (void)
|
||||
#if defined(CONFIG_MPC5200)
|
||||
/* enable timebase */
|
||||
*(vu_long *)(MPC5XXX_XLBARB + 0x40) |= (1 << 13);
|
||||
|
||||
/* Motorola reports IPB should better run at 133 MHz. */
|
||||
*(vu_long *)MPC5XXX_ADDECR |= 1;
|
||||
/* pci_clk_sel = 0x02, ipb_clk_sel = 0x00; */
|
||||
addecr = *(vu_long *)MPC5XXX_CDM_CFG;
|
||||
addecr &= ~0x103;
|
||||
addecr |= 0x02;
|
||||
*(vu_long *)MPC5XXX_CDM_CFG = addecr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -208,6 +208,7 @@ static void mpc5xxx_fec_set_hwaddr(mpc5xxx_fec_priv *fec, char *mac)
|
||||
/********************************************************************/
|
||||
static int mpc5xxx_fec_init(struct eth_device *dev, bd_t * bis)
|
||||
{
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
mpc5xxx_fec_priv *fec = (mpc5xxx_fec_priv *)dev->priv;
|
||||
struct mpc5xxx_sdma *sdma = (struct mpc5xxx_sdma *)MPC5XXX_SDMA;
|
||||
const uint8 phyAddr = 0; /* Only one PHY */
|
||||
@@ -269,10 +270,10 @@ static int mpc5xxx_fec_init(struct eth_device *dev, bd_t * bis)
|
||||
fec->eth->x_cntrl = 0x00000004; /* full-duplex, heartbeat disabled */
|
||||
|
||||
/*
|
||||
* Set MII_SPEED = (1/(mii_speed * 2)) * System Clock(25Mhz)
|
||||
* Set MII_SPEED = (1/(mii_speed * 2)) * System Clock
|
||||
* and do not drop the Preamble.
|
||||
*/
|
||||
fec->eth->mii_speed = (0x5 << 1); /* No MII for 7-wire mode */
|
||||
fec->eth->mii_speed = (((gd->ipb_clk >> 20) / 5) << 1); /* No MII for 7-wire mode */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -809,9 +810,13 @@ int mpc5xxx_fec_initialize(bd_t * bis)
|
||||
{
|
||||
mpc5xxx_fec_priv *fec;
|
||||
struct eth_device *dev;
|
||||
char *tmp, *end;
|
||||
char env_enetaddr[6];
|
||||
int i;
|
||||
|
||||
fec = (mpc5xxx_fec_priv *)malloc(sizeof(*fec));
|
||||
dev = (struct eth_device *)malloc(sizeof(*dev));
|
||||
memset(dev, 0, sizeof *dev);
|
||||
|
||||
fec->eth = (ethernet_regs *)MPC5XXX_FEC;
|
||||
fec->tbdBase = (FEC_TBD *)FEC_BD_BASE;
|
||||
@@ -830,6 +835,21 @@ int mpc5xxx_fec_initialize(bd_t * bis)
|
||||
sprintf(dev->name, "FEC ETHERNET");
|
||||
eth_register(dev);
|
||||
|
||||
/*
|
||||
* Try to set the mac address now. The fec mac address is
|
||||
* a garbage after reset. When not using fec for booting
|
||||
* the Linux fec driver will try to work with this garbage.
|
||||
*/
|
||||
tmp = getenv("ethaddr");
|
||||
if (tmp) {
|
||||
for (i=0; i<6; i++) {
|
||||
env_enetaddr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
|
||||
if (tmp)
|
||||
tmp = (*end) ? end+1 : end;
|
||||
}
|
||||
mpc5xxx_fec_set_hwaddr(fec, env_enetaddr);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ include $(TOPDIR)/config.mk
|
||||
|
||||
LIB = lib$(CPU).a
|
||||
|
||||
START = start.S drivers/i2c/i2c2.o
|
||||
START = start.S
|
||||
OBJS = traps.o cpu.o cpu_init.o interrupts.o speed.o \
|
||||
drivers/epic/epic1.o drivers/i2c/i2c1.o pci.o bedbug_603e.o
|
||||
drivers/epic/epic1.o drivers/i2c/i2c.o pci.o bedbug_603e.o
|
||||
|
||||
all: .depend $(START) $(LIB)
|
||||
|
||||
$(LIB): $(OBJS)
|
||||
$(AR) crv $@ $(OBJS) drivers/i2c/i2c2.o
|
||||
$(AR) crv $@ $(OBJS)
|
||||
|
||||
bedbug_603e.c:
|
||||
ln -s ../mpc8260/bedbug_603e.c bedbug_603e.c
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
##########################################################################
|
||||
#
|
||||
# Copyright Motorola, Inc. 1997
|
||||
# ALL RIGHTS RESERVED
|
||||
#
|
||||
# You are hereby granted a copyright license to use, modify, and
|
||||
# distribute the SOFTWARE so long as this entire notice is retained
|
||||
# without alteration in any modified and/or redistributed versions,
|
||||
# and that such modified versions are clearly identified as such.
|
||||
# No licenses are granted by implication, estoppel or otherwise under
|
||||
# any patents or trademarks of Motorola, Inc.
|
||||
#
|
||||
# The SOFTWARE is provided on an "AS IS" basis and without warranty.
|
||||
# To the maximum extent permitted by applicable law, MOTOROLA DISCLAIMS
|
||||
# ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
|
||||
# PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH
|
||||
# REGARD TO THE SOFTWARE (INCLUDING ANY MODIFIED VERSIONS
|
||||
# THEREOF) AND ANY ACCOMPANYING WRITTEN MATERIALS.
|
||||
#
|
||||
# To the maximum extent permitted by applicable law, IN NO EVENT SHALL
|
||||
# MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
|
||||
# (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF
|
||||
# BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
|
||||
# INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OF THE USE OR
|
||||
# INABILITY TO USE THE SOFTWARE.
|
||||
#
|
||||
############################################################################
|
||||
TARGET = libi2c.a
|
||||
|
||||
#DEBUG = -g
|
||||
DEBUG = -DI2CDBG
|
||||
LST = -Hanno -S
|
||||
OPTIM =
|
||||
CC = /risc/tools/pkgs/metaware/bin/hcppc
|
||||
CFLAGS = -Hnocopyr -c -Hsds -Hon=Char_default_unsigned -Hon=Char_is_rep -I../inc -I/risc/tools/pkgs/metaware/inc
|
||||
CCobj = $(CC) $(CFLAGS) $(DEBUG) $(OPTIM)
|
||||
PREP = $(CC) $(CFLAGS) -P
|
||||
|
||||
# Assembler used to build the .s files (for the board version)
|
||||
|
||||
ASOPT = -big_si -c
|
||||
ASDEBUG = -l -fm
|
||||
AS = /risc/tools/pkgs/metaware/bin/asppc
|
||||
|
||||
# Linker to bring .o files together into an executable.
|
||||
|
||||
LKOPT = -Bbase=0 -q -Qn -r
|
||||
LKCMD =
|
||||
LINK = /risc/tools/pkgs/metaware/bin/ldppc $(LKCMD) $(LKOPT)
|
||||
|
||||
# DOS Utilities
|
||||
|
||||
DEL = rm
|
||||
COPY = cp
|
||||
LIST = ls
|
||||
|
||||
OBJECTS = i2c1.o i2c2.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
objects: $(OBJECTS)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(LINK) $(OBJECTS) -o $@
|
||||
|
||||
clean:
|
||||
$(DEL) -f *.o *.i *.map *.lst $(TARGET) $(OBJECTS)
|
||||
|
||||
.s.o:
|
||||
$(DEL) -f $*.i
|
||||
$(PREP) -Hasmcpp $<
|
||||
$(AS) $(ASOPT) $*.i
|
||||
# $(AS) $(ASOPT) $(ASDEBUG) $*.i > $*.lst
|
||||
|
||||
.c.o:
|
||||
$(CCobj) $<
|
||||
|
||||
.c.s:
|
||||
$(CCobj) $(LST) $<
|
||||
|
||||
i2c1.o: i2c_export.h i2c.h i2c1.c
|
||||
|
||||
i2c2.o: i2c.h i2c2.s
|
||||
@@ -1,91 +0,0 @@
|
||||
##########################################################################
|
||||
#
|
||||
# makefile_pc for use with PC mksnt tools dink32/drivers/i2c
|
||||
#
|
||||
# Copyright Motorola, Inc. 1997
|
||||
# ALL RIGHTS RESERVED
|
||||
#
|
||||
# You are hereby granted a copyright license to use, modify, and
|
||||
# distribute the SOFTWARE so long as this entire notice is retained
|
||||
# without alteration in any modified and/or redistributed versions,
|
||||
# and that such modified versions are clearly identified as such.
|
||||
# No licenses are granted by implication, estoppel or otherwise under
|
||||
# any patents or trademarks of Motorola, Inc.
|
||||
#
|
||||
# The SOFTWARE is provided on an "AS IS" basis and without warranty.
|
||||
# To the maximum extent permitted by applicable law, MOTOROLA DISCLAIMS
|
||||
# ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
|
||||
# PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH
|
||||
# REGARD TO THE SOFTWARE (INCLUDING ANY MODIFIED VERSIONS
|
||||
# THEREOF) AND ANY ACCOMPANYING WRITTEN MATERIALS.
|
||||
#
|
||||
# To the maximum extent permitted by applicable law, IN NO EVENT SHALL
|
||||
# MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
|
||||
# (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF
|
||||
# BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
|
||||
# INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OF THE USE OR
|
||||
# INABILITY TO USE THE SOFTWARE.
|
||||
#
|
||||
############################################################################
|
||||
TARGET = libi2c.a
|
||||
|
||||
#DEBUG = -g
|
||||
DEBUG = -DI2CDBG
|
||||
LST = -Hanno -S
|
||||
OPTIM =
|
||||
CC = m:/old_tools/tools/hcppc/bin/hcppc
|
||||
CFLAGS = -Hnocopyr -c -Hsds -Hon=Char_default_unsigned -Hon=Char_is_rep -I../inc -I/risc/tools/pkgs/metaware/inc
|
||||
CCobj = $(CC) $(CFLAGS) $(DEBUG) $(OPTIM)
|
||||
PREP = $(CC) $(CFLAGS) -P
|
||||
|
||||
# Assembler used to build the .s files (for the board version)
|
||||
|
||||
ASOPT = -big_si -c
|
||||
ASDEBUG = -l -fm
|
||||
AS = m:/old_tools/tools/hcppc/bin/asppc
|
||||
|
||||
# Linker to bring .o files together into an executable.
|
||||
|
||||
LKOPT = -Bbase=0 -q -Qn -r
|
||||
LKCMD =
|
||||
LINK = m:/old_tools/tools/hcppc/bin/ldppc $(LKCMD) $(LKOPT)
|
||||
|
||||
# DOS Utilities
|
||||
|
||||
DEL = rm
|
||||
COPY = cp
|
||||
LIST = ls
|
||||
|
||||
OBJECTS = i2c1.o i2c2.o
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
objects: $(OBJECTS)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(LINK) $(OBJECTS) -o $@
|
||||
|
||||
clean:
|
||||
$(DEL) -f *.o *.i *.map *.lst $(TARGET) $(OBJECTS)
|
||||
|
||||
.s.o:
|
||||
$(DEL) -f $*.i
|
||||
$(PREP) -Hasmcpp $<
|
||||
$(AS) $(ASOPT) $*.i
|
||||
# $(AS) $(ASOPT) $(ASDEBUG) $*.i > $*.lst
|
||||
|
||||
.c.o:
|
||||
$(CCobj) $<
|
||||
|
||||
.c.s:
|
||||
$(CCobj) $(LST) $<
|
||||
|
||||
i2c1.o: i2c_export.h i2c.h i2c1.c
|
||||
$(CCobj) $<
|
||||
|
||||
|
||||
i2c2.o: i2c.h i2c2.s
|
||||
$(DEL) -f $*.i
|
||||
$(PREP) -Hasmcpp $<
|
||||
$(AS) $(ASOPT) $*.i
|
||||
@@ -1,104 +0,0 @@
|
||||
CONTENT:
|
||||
|
||||
i2c.h
|
||||
i2c1.c
|
||||
i2c2.s
|
||||
|
||||
WHAT ARE THESE FILES:
|
||||
|
||||
These files contain MPC8240 (Kahlua) I2C
|
||||
driver routines. The driver routines are not
|
||||
written for any specific operating system.
|
||||
They serves the purpose of code sample, and
|
||||
jump-start for using the MPC8240 I2C unit.
|
||||
|
||||
For the reason of correctness of C language
|
||||
syntax, these files are compiled by Metaware
|
||||
C compiler and assembler.
|
||||
|
||||
ENDIAN NOTATION:
|
||||
|
||||
The algorithm is designed for big-endian mode,
|
||||
software is responsible for byte swapping.
|
||||
|
||||
USAGE:
|
||||
|
||||
1. The host system that is running on MPC8240
|
||||
shall link the files listed here. The memory
|
||||
location of driver routines shall take into
|
||||
account of that driver routines need to run
|
||||
in supervisor mode and they process I2C
|
||||
interrupt.
|
||||
|
||||
2. The host system is responsible for configuring
|
||||
the MPC8240 including Embedded Utilities Memory
|
||||
Block. All I2C driver functions require the
|
||||
content of Embedded Utilities Memory Block
|
||||
Base Address Register, EUMBBAR, as the first
|
||||
parameter.
|
||||
|
||||
3. Before I2C unit of MPC8240 can be used,
|
||||
initialize I2C unit by calling I2C_Init
|
||||
with the corresponding parameters.
|
||||
|
||||
Note that the I2CFDR register shall be written
|
||||
once during the initialization. If it is written
|
||||
in the midst of transers, or after I2C STOPs or
|
||||
REPEAT STATRs, depending on the data written,
|
||||
a long reset time may be encountered.
|
||||
|
||||
4. After I2C unit has been successfully initialized,
|
||||
use the Application level API to send data or
|
||||
receive data upon the desired mode, Master or
|
||||
Slave.
|
||||
|
||||
5. If the host system is also using the EPIC unit
|
||||
on MPC8240, the system can register the
|
||||
I2C_ISR with the EPIC including other
|
||||
desired resources.
|
||||
|
||||
If the host system does not using the EPIC unit
|
||||
on MPC8240, I2C_Timer_Event function can
|
||||
be called for each desired time interval.
|
||||
|
||||
In both cases, the host system is free to provide
|
||||
its own timer event handler and interrupt service
|
||||
routine.
|
||||
|
||||
6. The I2C driver routines contains a set
|
||||
of utilities, Set and Get, for host system
|
||||
to query and modify the desired I2C registers.
|
||||
|
||||
7. It is the host system's responsibility of
|
||||
queueing the I2C I/O request. The host
|
||||
system shall check the I2C_ISR return code
|
||||
for I2C I/O status. If I2C_ISR returns
|
||||
I2CBUFFEMPTY or I2CBUFFFULL, it means
|
||||
I2C unit has completed a I/O request
|
||||
stated by the Application API.
|
||||
|
||||
8. If the host system has more than one master
|
||||
mode I2C unit I/O requests but doesn't want
|
||||
to be intervented by being addressed as slave,
|
||||
the host system can use the master mode
|
||||
Application API with stop_flag set to 0 in
|
||||
conjunction with is_cnt flag set to 1.
|
||||
The first API call sets both stop_flag and
|
||||
is_cnt to 0, indicating a START condition
|
||||
shall be generated but when the end of
|
||||
transaction is reached, do not generate a
|
||||
STOP condition. Once the host system is
|
||||
informed that the transaction has been
|
||||
completed, the next Application API call
|
||||
shall set is_cnt flag to 1, indicating a
|
||||
repeated START condition shall be generated.
|
||||
The last Application API call shall set
|
||||
stop_flag
|
||||
to 1.
|
||||
|
||||
9. The I2C_Timer_Event function containes
|
||||
a user defined function pointer. It
|
||||
serves the purpose of providing the
|
||||
host system a way to use its own event
|
||||
handler instead of the I2C_ISR provided
|
||||
here.
|
||||
284
cpu/mpc824x/drivers/i2c/i2c.c
Normal file
284
cpu/mpc824x/drivers/i2c/i2c.c
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* (C) Copyright 2003
|
||||
* Gleb Natapov <gnatapov@mrv.com>
|
||||
* Some bits are taken from linux driver writen by adrian@humboldt.co.uk
|
||||
*
|
||||
* Hardware I2C driver for MPC107 PCI bridge.
|
||||
*
|
||||
* 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>
|
||||
|
||||
#undef I2CDBG
|
||||
|
||||
#ifdef CONFIG_HARD_I2C
|
||||
#include <i2c.h>
|
||||
|
||||
#define TIMEOUT (CFG_HZ/4)
|
||||
|
||||
#define I2C_Addr ((unsigned *)(CFG_EUMB_ADDR + 0x3000))
|
||||
|
||||
#define I2CADR &I2C_Addr[0]
|
||||
#define I2CFDR &I2C_Addr[1]
|
||||
#define I2CCCR &I2C_Addr[2]
|
||||
#define I2CCSR &I2C_Addr[3]
|
||||
#define I2CCDR &I2C_Addr[4]
|
||||
|
||||
#define MPC107_CCR_MEN 0x80
|
||||
#define MPC107_CCR_MIEN 0x40
|
||||
#define MPC107_CCR_MSTA 0x20
|
||||
#define MPC107_CCR_MTX 0x10
|
||||
#define MPC107_CCR_TXAK 0x08
|
||||
#define MPC107_CCR_RSTA 0x04
|
||||
|
||||
#define MPC107_CSR_MCF 0x80
|
||||
#define MPC107_CSR_MAAS 0x40
|
||||
#define MPC107_CSR_MBB 0x20
|
||||
#define MPC107_CSR_MAL 0x10
|
||||
#define MPC107_CSR_SRW 0x04
|
||||
#define MPC107_CSR_MIF 0x02
|
||||
#define MPC107_CSR_RXAK 0x01
|
||||
|
||||
#define I2C_READ 1
|
||||
#define I2C_WRITE 0
|
||||
|
||||
/* taken from linux include/asm-ppc/io.h */
|
||||
inline unsigned in_le32 (volatile unsigned *addr)
|
||||
{
|
||||
unsigned ret;
|
||||
|
||||
__asm__ __volatile__ ("lwbrx %0,0,%1;\n"
|
||||
"twi 0,%0,0;\n"
|
||||
"isync":"=r" (ret): "r" (addr), "m" (*addr));
|
||||
return ret;
|
||||
}
|
||||
|
||||
inline void out_le32 (volatile unsigned *addr, int val)
|
||||
{
|
||||
__asm__ __volatile__ ("stwbrx %1,0,%2; eieio":"=m" (*addr):"r" (val),
|
||||
"r" (addr));
|
||||
}
|
||||
|
||||
#define writel(val, addr) out_le32(addr, val)
|
||||
#define readl(addr) in_le32(addr)
|
||||
|
||||
void i2c_init (int speed, int slaveadd)
|
||||
{
|
||||
/* stop I2C controller */
|
||||
writel (0x0, I2CCCR);
|
||||
/* set clock */
|
||||
writel (0x1020, I2CFDR);
|
||||
/* write slave address */
|
||||
writel (slaveadd, I2CADR);
|
||||
/* clear status register */
|
||||
writel (0x0, I2CCSR);
|
||||
/* start I2C controller */
|
||||
writel (MPC107_CCR_MEN, I2CCCR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static __inline__ int i2c_wait4bus (void)
|
||||
{
|
||||
ulong timeval = get_timer (0);
|
||||
|
||||
while (readl (I2CCSR) & MPC107_CSR_MBB)
|
||||
if (get_timer (timeval) > TIMEOUT)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __inline__ int i2c_wait (int write)
|
||||
{
|
||||
u32 csr;
|
||||
ulong timeval = get_timer (0);
|
||||
|
||||
do {
|
||||
csr = readl (I2CCSR);
|
||||
|
||||
if (!(csr & MPC107_CSR_MIF))
|
||||
continue;
|
||||
|
||||
writel (0x0, I2CCSR);
|
||||
|
||||
if (csr & MPC107_CSR_MAL) {
|
||||
#ifdef I2CDBG
|
||||
printf ("i2c_wait: MAL\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(csr & MPC107_CSR_MCF)) {
|
||||
#ifdef I2CDBG
|
||||
printf ("i2c_wait: unfinished\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (write == I2C_WRITE && (csr & MPC107_CSR_RXAK)) {
|
||||
#ifdef I2CDBG
|
||||
printf ("i2c_wait: No RXACK\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} while (get_timer (timeval) < TIMEOUT);
|
||||
|
||||
#ifdef I2CDBG
|
||||
printf ("i2c_wait: timed out\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
static __inline__ int i2c_write_addr (u8 dev, u8 dir, int rsta)
|
||||
{
|
||||
writel (MPC107_CCR_MEN | MPC107_CCR_MSTA | MPC107_CCR_MTX |
|
||||
(rsta ? MPC107_CCR_RSTA : 0), I2CCCR);
|
||||
|
||||
writel ((dev << 1) | dir, I2CCDR);
|
||||
|
||||
if (i2c_wait (I2C_WRITE) < 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static __inline__ int __i2c_write (u8 * data, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
writel (MPC107_CCR_MEN | MPC107_CCR_MSTA | MPC107_CCR_MTX, I2CCCR);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
writel (data[i], I2CCDR);
|
||||
|
||||
if (i2c_wait (I2C_WRITE) < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static __inline__ int __i2c_read (u8 * data, int length)
|
||||
{
|
||||
int i;
|
||||
|
||||
writel (MPC107_CCR_MEN | MPC107_CCR_MSTA |
|
||||
((length == 1) ? MPC107_CCR_TXAK : 0), I2CCCR);
|
||||
|
||||
/* dummy read */
|
||||
readl (I2CCDR);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (i2c_wait (I2C_READ) < 0)
|
||||
break;
|
||||
|
||||
/* Generate ack on last next to last byte */
|
||||
if (i == length - 2)
|
||||
writel (MPC107_CCR_MEN | MPC107_CCR_MSTA |
|
||||
MPC107_CCR_TXAK, I2CCCR);
|
||||
|
||||
/* Generate stop on last byte */
|
||||
if (i == length - 1)
|
||||
writel (MPC107_CCR_MEN | MPC107_CCR_TXAK, I2CCCR);
|
||||
|
||||
data[i] = readl (I2CCDR);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int i2c_read (u8 dev, uint addr, int alen, u8 * data, int length)
|
||||
{
|
||||
int i = 0;
|
||||
u8 *a = (u8 *) & addr;
|
||||
|
||||
if (i2c_wait4bus () < 0)
|
||||
goto exit;
|
||||
|
||||
if (i2c_write_addr (dev, I2C_WRITE, 0) == 0)
|
||||
goto exit;
|
||||
|
||||
if (__i2c_write (&a[4 - alen], alen) != alen)
|
||||
goto exit;
|
||||
|
||||
if (i2c_write_addr (dev, I2C_READ, 1) == 0)
|
||||
goto exit;
|
||||
|
||||
i = __i2c_read (data, length);
|
||||
|
||||
exit:
|
||||
writel (MPC107_CCR_MEN, I2CCCR);
|
||||
|
||||
return !(i == length);
|
||||
}
|
||||
|
||||
int i2c_write (u8 dev, uint addr, int alen, u8 * data, int length)
|
||||
{
|
||||
int i = 0;
|
||||
u8 *a = (u8 *) & addr;
|
||||
|
||||
if (i2c_wait4bus () < 0)
|
||||
goto exit;
|
||||
|
||||
if (i2c_write_addr (dev, I2C_WRITE, 0) == 0)
|
||||
goto exit;
|
||||
|
||||
if (__i2c_write (&a[4 - alen], alen) != alen)
|
||||
goto exit;
|
||||
|
||||
i = __i2c_write (data, length);
|
||||
|
||||
exit:
|
||||
writel (MPC107_CCR_MEN, I2CCCR);
|
||||
|
||||
return !(i == length);
|
||||
}
|
||||
|
||||
int i2c_probe (uchar chip)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
/*
|
||||
* Try to read the first location of the chip. The underlying
|
||||
* driver doesn't appear to support sending just the chip address
|
||||
* and looking for an <ACK> back.
|
||||
*/
|
||||
udelay (10000);
|
||||
return i2c_read (chip, 0, 1, (char *) &tmp, 1);
|
||||
}
|
||||
|
||||
uchar i2c_reg_read (uchar i2c_addr, uchar reg)
|
||||
{
|
||||
char buf[1];
|
||||
|
||||
i2c_read (i2c_addr, reg, 1, buf, 1);
|
||||
|
||||
return (buf[0]);
|
||||
}
|
||||
|
||||
void i2c_reg_write (uchar i2c_addr, uchar reg, uchar val)
|
||||
{
|
||||
i2c_write (i2c_addr, reg, 1, &val, 1);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_HARD_I2C */
|
||||
@@ -1,309 +0,0 @@
|
||||
#ifndef I2C_H
|
||||
#define I2C_H
|
||||
|
||||
/****************************************************
|
||||
*
|
||||
* Copyright Motrola 1999
|
||||
*
|
||||
****************************************************/
|
||||
#define get_eumbbar() CFG_EUMB_ADDR
|
||||
|
||||
#define I2CADR 0x00003000
|
||||
#define I2CFDR 0x00003004
|
||||
#define I2CCR 0x00003008
|
||||
#define I2CSR 0x0000300C
|
||||
#define I2CDR 0x00003010
|
||||
|
||||
typedef enum _i2cstatus
|
||||
{
|
||||
I2CSUCCESS = 0x3000,
|
||||
I2CADDRESS,
|
||||
I2CERROR,
|
||||
I2CBUFFFULL,
|
||||
I2CBUFFEMPTY,
|
||||
I2CXMITERROR,
|
||||
I2CRCVERROR,
|
||||
I2CBUSBUSY,
|
||||
I2CALOSS,
|
||||
I2CNOEVENT,
|
||||
} I2CStatus;
|
||||
|
||||
typedef enum i2c_control
|
||||
{
|
||||
MEN = 0x00000080,
|
||||
MIEN = 0x00000040,
|
||||
MSTA = 0x00000020,
|
||||
MTX = 0x00000010,
|
||||
TXAK = 0x00000008,
|
||||
RSTA = 0x00000004,
|
||||
} I2C_CONTROL;
|
||||
|
||||
typedef enum i2c_status
|
||||
{
|
||||
MCF = 0x00000080,
|
||||
MAAS = 0x00000040,
|
||||
MBB = 0x00000020,
|
||||
MAL = 0x00000010,
|
||||
SRW = 0x00000004,
|
||||
MIF = 0x00000002,
|
||||
RXAK = 0x00000001,
|
||||
} I2C_STATUS;
|
||||
|
||||
typedef struct _i2c_ctrl
|
||||
{
|
||||
unsigned int reserved0 : 24;
|
||||
unsigned int men : 1;
|
||||
unsigned int mien : 1;
|
||||
unsigned int msta : 1;
|
||||
unsigned int mtx : 1;
|
||||
unsigned int txak : 1;
|
||||
unsigned int rsta : 1;
|
||||
unsigned int reserved1 : 2;
|
||||
} I2C_CTRL;
|
||||
|
||||
typedef struct _i2c_stat
|
||||
{
|
||||
unsigned int rsrv0 : 24;
|
||||
unsigned int mcf : 1;
|
||||
unsigned int maas : 1;
|
||||
unsigned int mbb : 1;
|
||||
unsigned int mal : 1;
|
||||
unsigned int rsrv1 : 1;
|
||||
unsigned int srw : 1;
|
||||
unsigned int mif : 1;
|
||||
unsigned int rxak : 1;
|
||||
} I2C_STAT;
|
||||
|
||||
typedef enum _i2c_mode
|
||||
{
|
||||
RCV = 0,
|
||||
XMIT = 1,
|
||||
} I2C_MODE;
|
||||
|
||||
/******************** App. API ********************
|
||||
* The application API is for user level application
|
||||
* to use the funcitonality provided by I2C driver
|
||||
*
|
||||
* Note: Its App.s responsibility to swap the data
|
||||
* byte. In our API, we just transfer whatever
|
||||
* we are given
|
||||
**************************************************/
|
||||
/**
|
||||
* Note:
|
||||
*
|
||||
* In all following functions,
|
||||
* the caller shall pass the configured embedded utility memory
|
||||
* block base, EUMBBAR.
|
||||
**/
|
||||
|
||||
/* Send a buffer of data to the intended rcv_addr.
|
||||
* If stop_flag is set, after the whole buffer
|
||||
* is sent, generate a STOP signal provided that the
|
||||
* receiver doesn't signal the STOP in the middle.
|
||||
* I2C is the master performing transmitting. If
|
||||
* no STOP signal is generated at the end of current
|
||||
* transaction, the master can generate a START signal
|
||||
* to another slave addr.
|
||||
*
|
||||
* return I2CSUCCESS if no error.
|
||||
*/
|
||||
static I2CStatus I2C_put( unsigned int eumbbar,
|
||||
unsigned char rcv_addr, /* receiver's address */
|
||||
unsigned char *buffer_ptr, /* pointer of data to be sent */
|
||||
unsigned int length, /* number of byte of in the buffer */
|
||||
unsigned int stop_flag, /* 1 - signal STOP when buffer is empty
|
||||
* 0 - no STOP signal when buffer is empty
|
||||
*/
|
||||
unsigned int is_cnt ); /* 1 - this is a restart, don't check MBB
|
||||
* 0 - this is a new start, check MBB
|
||||
*/
|
||||
|
||||
/* Receive a buffer of data from the desired sender_addr
|
||||
* If stop_flag is set, when the buffer is full and the
|
||||
* sender does not signal STOP, generate a STOP signal.
|
||||
* I2C is the master performing receiving. If no STOP signal
|
||||
* is generated, the master can generate a START signal
|
||||
* to another slave addr.
|
||||
*
|
||||
* return I2CSUCCESS if no error.
|
||||
*/
|
||||
static I2CStatus I2C_get( unsigned int eumbbar,
|
||||
unsigned char sender_addr, /* sender's address */
|
||||
unsigned char *buffer_ptr, /* pointer of receiving buffer */
|
||||
unsigned int length, /* length of the receiving buffer */
|
||||
unsigned int stop_flag, /* 1 - signal STOP when buffer is full
|
||||
* 0 - no STOP signal when buffer is full
|
||||
*/
|
||||
unsigned int is_cnt ); /* 1 - this is a restart, don't check MBB
|
||||
* 0 - this is a new start, check MBB
|
||||
*/
|
||||
|
||||
#if 0 /* the I2C_write and I2C_read functions are not active */
|
||||
/* Send a buffer of data to the requiring master.
|
||||
* If stop_flag is set, after the whole buffer is sent,
|
||||
* generate a STOP signal provided that the requiring
|
||||
* receiver doesn't signal the STOP in the middle.
|
||||
* I2C is the slave performing transmitting.
|
||||
*
|
||||
* return I2CSUCCESS if no error.
|
||||
*
|
||||
* Note: due to the Kahlua design, slave transmitter
|
||||
* shall not signal STOP since there is no way
|
||||
* for master to detect it, causing I2C bus hung.
|
||||
*
|
||||
* For the above reason, the stop_flag is always
|
||||
* set, i.e., 1.
|
||||
*
|
||||
* programmer shall use the timer on Kahlua to
|
||||
* control the interval of data byte at the
|
||||
* master side.
|
||||
*/
|
||||
static I2CStatus I2C_write( unsigned int eumbbar,
|
||||
unsigned char *buffer_ptr, /* pointer of data to be sent */
|
||||
unsigned int length, /* number of byte of in the buffer */
|
||||
unsigned int stop_flag ); /* 1 - signal STOP when buffer is empty
|
||||
* 0 - no STOP signal when buffer is empty
|
||||
*/
|
||||
|
||||
/* Receive a buffer of data from the sending master.
|
||||
* If stop_flag is set, when the buffer is full and the
|
||||
* sender does not signal STOP, generate a STOP signal.
|
||||
* I2C is the slave performing receiving.
|
||||
*
|
||||
* return I2CSUCCESS if no error.
|
||||
*/
|
||||
static I2CStatus I2C_read(unsigned int eumbbar,
|
||||
unsigned char *buffer_ptr, /* pointer of receiving buffer */
|
||||
unsigned int length, /* length of the receiving buffer */
|
||||
unsigned int stop_flag ); /* 1 - signal STOP when buffer is full
|
||||
* 0 - no STOP signal when buffer is full
|
||||
*/
|
||||
#endif /* of if0 for turning off I2C_read & I2C_write */
|
||||
|
||||
/* if interrupt is not used, this is the timer event handler.
|
||||
* After each fixed time interval, this function can be called
|
||||
* to check the I2C status and call appropriate function to
|
||||
* handle the status event.
|
||||
*/
|
||||
static I2CStatus I2C_Timer_Event( unsigned int eumbbar, I2CStatus (*handler)( unsigned int ) );
|
||||
|
||||
/********************* Kernel API ************************
|
||||
* Kernel APIs are functions I2C driver provides to the
|
||||
* O.S.
|
||||
*********************************************************/
|
||||
|
||||
/******************* device I/O function ***************/
|
||||
|
||||
/* Generate a START signal in the desired mode.
|
||||
* I2C is the master.
|
||||
*
|
||||
* return I2CSUCCESS if no error.
|
||||
* I2CERROR if i2c unit is not enabled.
|
||||
* I2CBUSBUSY if bus cannot be granted
|
||||
*/
|
||||
static I2CStatus I2C_Start( unsigned int eumbbar,
|
||||
unsigned char slave_addr, /* address of the receiver */
|
||||
I2C_MODE mode, /* XMIT(1) - put (write)
|
||||
* RCV(0) - get (read)
|
||||
*/
|
||||
unsigned int is_cnt ); /* 1 - this is a restart, don't check MBB
|
||||
* 0 - this is a new start, check MBB
|
||||
*/
|
||||
|
||||
/* Generate a STOP signal to terminate the transaction. */
|
||||
static I2CStatus I2C_Stop( unsigned int eumbbar );
|
||||
|
||||
/* Do a one-byte master transmit.
|
||||
*
|
||||
* return I2CBUFFEMPTY if this is the last byte.
|
||||
* Otherwise return I2CSUCCESS
|
||||
*/
|
||||
static I2CStatus I2C_Master_Xmit( unsigned int eumbbar );
|
||||
|
||||
/* Do a one-byte master receive.
|
||||
*
|
||||
* return I2CBUFFFULL if this is the last byte.
|
||||
* Otherwise return I2CSUCCESS
|
||||
*/
|
||||
static I2CStatus I2C_Master_Rcv( unsigned int eumbbar );
|
||||
|
||||
/* Do a one-byte slave transmit.
|
||||
*
|
||||
* return I2CBUFFEMPTY if this is the last byte.
|
||||
* Otherwise return I2CSUCCESS
|
||||
*
|
||||
*/
|
||||
static I2CStatus I2C_Slave_Xmit( unsigned int eumbbar );
|
||||
|
||||
/* Do a one-byte slave receive.
|
||||
*
|
||||
* return I2CBUFFFULL if this is the last byte.
|
||||
* Otherwise return I2CSUCCESS
|
||||
*/
|
||||
static I2CStatus I2C_Slave_Rcv( unsigned int eumbbar );
|
||||
|
||||
/* Process slave address phase.
|
||||
*
|
||||
* return I2CADDRESS if this is slave receiver's address phase
|
||||
* Otherwise return the result of slave xmit one byte.
|
||||
*/
|
||||
static I2CStatus I2C_Slave_Addr( unsigned int eumbbar );
|
||||
|
||||
/******************* Device Control Fucntion ****************/
|
||||
/* Initialize I2C unit with desired frequency divider,
|
||||
* driver's slave address w/o interrupt enabled.
|
||||
*
|
||||
* This function must be called before I2C unit can
|
||||
* be used.
|
||||
*/
|
||||
static I2CStatus I2C_Init( unsigned int eumbbar,
|
||||
unsigned char fdr, /* frequency divider */
|
||||
unsigned char addr, /* driver's address used for receiving */
|
||||
unsigned int en_int); /* 1 - enable I2C interrupt
|
||||
* 0 - disable I2C interrup
|
||||
*/
|
||||
|
||||
/* I2C interrupt service routine.
|
||||
*
|
||||
* return I2CADDRESS if it is receiver's (either master or slave) address phase.
|
||||
* return the result of xmit or receive one byte
|
||||
*/
|
||||
static I2CStatus I2C_ISR(unsigned int eumbbar );
|
||||
|
||||
/* Set I2C Status, i.e., write to I2CSR */
|
||||
static void I2C_Set_Stat( unsigned int eumbbar, I2C_STAT stat );
|
||||
|
||||
/* Query I2C Status, i.e., read I2CSR */
|
||||
static I2C_STAT I2C_Get_Stat( unsigned int eumbbar );
|
||||
|
||||
/* Change I2C Control bits, i.e., write to I2CCR */
|
||||
static void I2C_Set_Ctrl( unsigned int eumbbar, I2C_CTRL ); /* new control value */
|
||||
|
||||
/* Query I2C Control bits, i.e., read I2CCR */
|
||||
static I2C_CTRL I2C_Get_Ctrl( unsigned int eumbbar );
|
||||
|
||||
/* This function performs the work for I2C_do_transaction. The work is
|
||||
* split into this function to enable I2C_do_transaction to first transmit
|
||||
* the data address to the I2C slave device without putting the data address
|
||||
* into the first byte of the buffer.
|
||||
*
|
||||
* en_int controls interrupt/polling mode
|
||||
* act is the type of transaction
|
||||
* i2c_addr is the I2C address of the slave device
|
||||
* len is the length of data to send or receive
|
||||
* buffer is the address of the data buffer
|
||||
* stop = I2C_NO_STOP, don't signal STOP at end of transaction
|
||||
* I2C_STOP, signal STOP at end of transaction
|
||||
* retry is the timeout retry value, currently ignored
|
||||
* rsta = I2C_NO_RESTART, this is not continuation of existing transaction
|
||||
* I2C_RESTART, this is a continuation of existing transaction
|
||||
*/
|
||||
static I2C_Status I2C_do_buffer( I2C_INTERRUPT_MODE en_int,
|
||||
I2C_TRANSACTION_MODE act,
|
||||
unsigned char i2c_addr,
|
||||
int len,
|
||||
unsigned char *buffer,
|
||||
I2C_STOP_MODE stop,
|
||||
int retry,
|
||||
I2C_RESTART_MODE rsta);
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,52 +0,0 @@
|
||||
/**************************************
|
||||
*
|
||||
* copyright @ Motorola, 1999
|
||||
*
|
||||
**************************************/
|
||||
|
||||
#include <config.h>
|
||||
#ifdef CONFIG_HARD_I2C
|
||||
#include <ppc_asm.tmpl>
|
||||
#include <asm/mmu.h>
|
||||
/**********************************************************
|
||||
* function: load_runtime_reg
|
||||
*
|
||||
* input: r3 - value of eumbbar
|
||||
* r4 - register offset in embedded utility space
|
||||
*
|
||||
* output: r3 - register content
|
||||
**********************************************************/
|
||||
.text
|
||||
.align 2
|
||||
.global load_runtime_reg
|
||||
load_runtime_reg:
|
||||
|
||||
/* xor r5,r5,r5
|
||||
* or r5,r5,r3
|
||||
*
|
||||
* lwbrx r3,r4,r5
|
||||
*/
|
||||
lwbrx r3,r4,r3
|
||||
sync
|
||||
|
||||
bclr 20, 0
|
||||
|
||||
/****************************************************************
|
||||
* function: store_runtime_reg
|
||||
*
|
||||
* input: r3 - value of eumbbar
|
||||
* r4 - register offset in embedded utility space
|
||||
* r5 - new value to be stored
|
||||
*
|
||||
****************************************************************/
|
||||
.text
|
||||
.align 2
|
||||
.global store_runtime_reg
|
||||
store_runtime_reg:
|
||||
|
||||
stwbrx r5, r4, r3
|
||||
sync
|
||||
|
||||
bclr 20,0
|
||||
|
||||
#endif /* CONFIG_HARD_I2C */
|
||||
@@ -1,103 +0,0 @@
|
||||
#ifndef I2C_EXPORT_H
|
||||
#define I2C_EXPORT_H
|
||||
|
||||
/****************************************************
|
||||
*
|
||||
* Copyright Motrola 1999
|
||||
*
|
||||
****************************************************/
|
||||
|
||||
/* These are the defined return values for the I2C_do_transaction function.
|
||||
* Any non-zero value indicates failure. Failure modes can be added for
|
||||
* more detailed error reporting.
|
||||
*/
|
||||
typedef enum _i2c_status
|
||||
{
|
||||
I2C_SUCCESS = 0,
|
||||
I2C_ERROR,
|
||||
} I2C_Status;
|
||||
|
||||
/* These are the defined tasks for I2C_do_transaction.
|
||||
* Modes for SLAVE_RCV and SLAVE_XMIT will be added.
|
||||
*/
|
||||
typedef enum _i2c_transaction_mode
|
||||
{
|
||||
I2C_MASTER_RCV = 0,
|
||||
I2C_MASTER_XMIT = 1,
|
||||
} I2C_TRANSACTION_MODE;
|
||||
|
||||
typedef enum _i2c_interrupt_mode
|
||||
{
|
||||
I2C_INT_DISABLE = 0,
|
||||
I2C_INT_ENABLE = 1,
|
||||
} I2C_INTERRUPT_MODE;
|
||||
|
||||
typedef enum _i2c_stop
|
||||
{
|
||||
I2C_NO_STOP = 0,
|
||||
I2C_STOP = 1,
|
||||
} I2C_STOP_MODE;
|
||||
|
||||
typedef enum _i2c_restart
|
||||
{
|
||||
I2C_NO_RESTART = 0,
|
||||
I2C_RESTART = 1,
|
||||
} I2C_RESTART_MODE;
|
||||
|
||||
/******************** App. API ********************
|
||||
* The application API is for user level application
|
||||
* to use the functionality provided by I2C driver.
|
||||
* This is a "generic" I2C interface, it should contain
|
||||
* nothing specific to the Kahlua implementation.
|
||||
* Only the generic functions are exported by the library.
|
||||
*
|
||||
* Note: Its App.s responsibility to swap the data
|
||||
* byte. In our API, we just transfer whatever
|
||||
* we are given
|
||||
**************************************************/
|
||||
|
||||
|
||||
/* Initialize I2C unit with the following:
|
||||
* driver's slave address
|
||||
* interrupt enabled
|
||||
* optional pointer to application layer print function
|
||||
*
|
||||
* These parameters may be added:
|
||||
* desired clock rate
|
||||
* digital filter frequency sampling rate
|
||||
*
|
||||
* This function must be called before I2C unit can be used.
|
||||
*/
|
||||
extern I2C_Status I2C_Initialize(
|
||||
unsigned char addr, /* driver's I2C slave address */
|
||||
I2C_INTERRUPT_MODE en_int, /* 1 - enable I2C interrupt
|
||||
* 0 - disable I2C interrupt
|
||||
*/
|
||||
int (*app_print_function)(char *,...)); /* pointer to optional "printf"
|
||||
* provided by application
|
||||
*/
|
||||
|
||||
/* Perform the given I2C transaction, only MASTER_XMIT and MASTER_RCV
|
||||
* are implemented. Both are only in polling mode.
|
||||
*
|
||||
* en_int controls interrupt/polling mode
|
||||
* act is the type of transaction
|
||||
* addr is the I2C address of the slave device
|
||||
* len is the length of data to send or receive
|
||||
* buffer is the address of the data buffer
|
||||
* stop = I2C_NO_STOP, don't signal STOP at end of transaction
|
||||
* I2C_STOP, signal STOP at end of transaction
|
||||
* retry is the timeout retry value, currently ignored
|
||||
* rsta = I2C_NO_RESTART, this is not continuation of existing transaction
|
||||
* I2C_RESTART, this is a continuation of existing transaction
|
||||
*/
|
||||
extern I2C_Status I2C_do_transaction( I2C_INTERRUPT_MODE en_int,
|
||||
I2C_TRANSACTION_MODE act,
|
||||
unsigned char i2c_addr,
|
||||
unsigned char data_addr,
|
||||
int len,
|
||||
char *buffer,
|
||||
I2C_STOP_MODE stop,
|
||||
int retry,
|
||||
I2C_RESTART_MODE rsta);
|
||||
#endif
|
||||
@@ -526,11 +526,26 @@ relocate_code:
|
||||
stwu r0,-4(r7)
|
||||
bdnz 3b
|
||||
|
||||
4:
|
||||
#if !defined(CONFIG_BMW)
|
||||
/* Unlock the data cache and invalidate locked area */
|
||||
xor r0, r0, r0
|
||||
mtspr 1011, r0
|
||||
lis r4, CFG_INIT_RAM_ADDR@h
|
||||
ori r4, r4, CFG_INIT_RAM_ADDR@l
|
||||
li r0, 128
|
||||
mtctr r0
|
||||
41:
|
||||
dcbi r0, r4
|
||||
addi r4, r4, 32
|
||||
bdnz 41b
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Now flush the cache: note that we must start from a cache aligned
|
||||
* address. Otherwise we might miss one cache line.
|
||||
*/
|
||||
4: cmpwi r6,0
|
||||
cmpwi r6,0
|
||||
add r5,r3,r5
|
||||
beq 7f /* Always flush prefetch queue in any case */
|
||||
subi r0,r6,1
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
#if defined(CONFIG_405GP) || defined(CONFIG_440) || defined(CONFIG_405EP)
|
||||
|
||||
#define EMAC_RESET_TIMEOUT 1000 /* 1000 ms reset timeout */
|
||||
#define PHY_AUTONEGOTIATE_TIMEOUT 2000 /* 2000 ms autonegotiate timeout */
|
||||
#define PHY_AUTONEGOTIATE_TIMEOUT 4000 /* 4000 ms autonegotiate timeout */
|
||||
|
||||
#define NUM_TX_BUFF 1
|
||||
/* AS.HARNOIS
|
||||
@@ -271,18 +271,18 @@ static int ppc_4xx_eth_init (struct eth_device *dev, bd_t * bis)
|
||||
puts ("Waiting for PHY auto negotiation to complete");
|
||||
i = 0;
|
||||
while (!(reg_short & PHY_BMSR_AUTN_COMP)) {
|
||||
if ((i++ % 100) == 0)
|
||||
putc ('.');
|
||||
udelay (10000); /* 10 ms */
|
||||
miiphy_read (CONFIG_PHY_ADDR, PHY_BMSR, ®_short);
|
||||
|
||||
/*
|
||||
* Timeout reached ?
|
||||
*/
|
||||
if (i * 10 > PHY_AUTONEGOTIATE_TIMEOUT) {
|
||||
if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
|
||||
puts (" TIMEOUT !\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if ((i++ % 1000) == 0)
|
||||
putc ('.');
|
||||
udelay (1000); /* 1 ms */
|
||||
miiphy_read (CONFIG_PHY_ADDR, PHY_BMSR, ®_short);
|
||||
}
|
||||
puts (" done\n");
|
||||
udelay (500000); /* another 500 ms (results in faster booting) */
|
||||
|
||||
118
cpu/ppc4xx/cpu.c
118
cpu/ppc4xx/cpu.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* (C) Copyright 2000
|
||||
* (C) Copyright 2000-2003
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
@@ -22,8 +22,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* m8xx.c
|
||||
*
|
||||
* CPU specific code
|
||||
*
|
||||
* written or collected and sometimes rewritten by
|
||||
@@ -50,15 +48,15 @@ int checkcpu (void)
|
||||
{
|
||||
#if defined(CONFIG_405GP) || \
|
||||
defined(CONFIG_405CR) || \
|
||||
defined(CONFIG_IOP480) || \
|
||||
defined(CONFIG_440) || \
|
||||
defined(CONFIG_405EP)
|
||||
defined(CONFIG_405EP) || \
|
||||
defined(CONFIG_440) || \
|
||||
defined(CONFIG_IOP480)
|
||||
uint pvr = get_pvr();
|
||||
#endif
|
||||
#if defined(CONFIG_405GP) || \
|
||||
defined(CONFIG_405CR) || \
|
||||
defined(CONFIG_IOP480) || \
|
||||
defined(CONFIG_405EP)
|
||||
defined(CONFIG_405EP) || \
|
||||
defined(CONFIG_IOP480)
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
ulong clock = gd->cpu_clk;
|
||||
@@ -73,17 +71,17 @@ int checkcpu (void)
|
||||
get_sys_info(&sys_info);
|
||||
|
||||
#if CONFIG_405GP
|
||||
puts("IBM PowerPC 405GP");
|
||||
puts ("IBM PowerPC 405GP");
|
||||
if (pvr == PVR_405GPR_RB) {
|
||||
putc('r');
|
||||
}
|
||||
puts(" Rev. ");
|
||||
puts (" Rev. ");
|
||||
#endif
|
||||
#if CONFIG_405CR
|
||||
puts("IBM PowerPC 405CR Rev. ");
|
||||
puts ("IBM PowerPC 405CR Rev. ");
|
||||
#endif
|
||||
#if CONFIG_405EP
|
||||
puts("IBM PowerPC 405EP Rev. ");
|
||||
puts ("IBM PowerPC 405EP Rev. ");
|
||||
#endif
|
||||
switch (pvr) {
|
||||
case PVR_405GP_RB:
|
||||
@@ -112,79 +110,71 @@ int checkcpu (void)
|
||||
putc('B');
|
||||
break;
|
||||
default:
|
||||
printf("? (PVR=%08x)", pvr);
|
||||
printf ("? (PVR=%08x)", pvr);
|
||||
break;
|
||||
}
|
||||
|
||||
printf(" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
|
||||
printf (" at %s MHz (PLB=%lu, OPB=%lu, EBC=%lu MHz)\n", strmhz(buf, clock),
|
||||
sys_info.freqPLB / 1000000,
|
||||
sys_info.freqPLB / sys_info.pllOpbDiv / 1000000,
|
||||
sys_info.freqPLB / sys_info.pllExtBusDiv / 1000000);
|
||||
|
||||
#if defined(CONFIG_405GP)
|
||||
if (mfdcr(strap) & PSR_PCI_ASYNC_EN)
|
||||
printf(" PCI async ext clock used, ");
|
||||
else
|
||||
printf(" PCI sync clock at %lu MHz, ",
|
||||
if (mfdcr(strap) & PSR_PCI_ASYNC_EN) {
|
||||
printf (" PCI async ext clock used, ");
|
||||
} else {
|
||||
printf (" PCI sync clock at %lu MHz, ",
|
||||
sys_info.freqPLB / sys_info.pllPciDiv / 1000000);
|
||||
if (mfdcr(strap) & PSR_PCI_ARBIT_EN)
|
||||
printf("internal PCI arbiter enabled\n");
|
||||
else
|
||||
printf("external PCI arbiter enabled\n");
|
||||
}
|
||||
printf ("%sternal PCI arbiter enabled\n",
|
||||
(mfdcr(strap) & PSR_PCI_ARBIT_EN) ? "in" : "ex");
|
||||
#elif defined(CONFIG_405EP)
|
||||
if (mfdcr(cpc0_boot) & CPC0_BOOT_SEP)
|
||||
printf(" IIC Boot EEPROM enabled\n");
|
||||
else
|
||||
printf(" IIC Boot EEPROM disabled\n");
|
||||
printf(" PCI async ext clock used, ");
|
||||
if (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN)
|
||||
printf("internal PCI arbiter enabled\n");
|
||||
else
|
||||
printf("external PCI arbiter enabled\n");
|
||||
printf (" IIC Boot EEPROM %sabled\n",
|
||||
(mfdcr(cpc0_boot) & CPC0_BOOT_SEP) ? "en" : "dis");
|
||||
printf (" PCI async ext clock used, ");
|
||||
printf ("%sternal PCI arbiter enabled\n",
|
||||
(mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN) ? "in" : "ex");
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_405EP)
|
||||
printf(" 16 kB I-Cache 16 kB D-Cache");
|
||||
printf (" 16 kB I-Cache 16 kB D-Cache");
|
||||
#else
|
||||
if ((pvr | 0x00000001) == PVR_405GPR_RB) {
|
||||
printf(" 16 kB I-Cache 16 kB D-Cache");
|
||||
} else {
|
||||
printf(" 16 kB I-Cache 8 kB D-Cache");
|
||||
}
|
||||
printf (" 16 kB I-Cache %d kB D-Cache",
|
||||
((pvr | 0x00000001) == PVR_405GPR_RB) ? 16 : 8);
|
||||
#endif
|
||||
#endif /* defined(CONFIG_405GP) || defined(CONFIG_405CR) */
|
||||
|
||||
#ifdef CONFIG_IOP480
|
||||
printf("PLX IOP480 (PVR=%08x)", pvr);
|
||||
printf(" at %s MHz:", strmhz(buf, clock));
|
||||
printf(" %u kB I-Cache", 4);
|
||||
printf(" %u kB D-Cache", 2);
|
||||
printf ("PLX IOP480 (PVR=%08x)", pvr);
|
||||
printf (" at %s MHz:", strmhz(buf, clock));
|
||||
printf (" %u kB I-Cache", 4);
|
||||
printf (" %u kB D-Cache", 2);
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_440)
|
||||
puts("IBM PowerPC 440 Rev. ");
|
||||
switch(pvr)
|
||||
{
|
||||
puts ("IBM PowerPC 440 Rev. ");
|
||||
switch(pvr) {
|
||||
case PVR_440GP_RB:
|
||||
putc('B');
|
||||
/* See errata 1.12: CHIP_4 */
|
||||
if( ( mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0) )
|
||||
||( mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1) ) ){
|
||||
puts("\n\t CPC0_SYSx DCRs corrupted. Resetting chip ...\n");
|
||||
udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
|
||||
do_chip_reset( mfdcr(cpc0_strp0), mfdcr(cpc0_strp1) );
|
||||
}
|
||||
/* See errata 1.12: CHIP_4 */
|
||||
if ((mfdcr(cpc0_sys0) != mfdcr(cpc0_strp0)) ||
|
||||
(mfdcr(cpc0_sys1) != mfdcr(cpc0_strp1)) ){
|
||||
puts ( "\n\t CPC0_SYSx DCRs corrupted. "
|
||||
"Resetting chip ...\n");
|
||||
udelay( 1000 * 1000 ); /* Give time for serial buf to clear */
|
||||
do_chip_reset ( mfdcr(cpc0_strp0),
|
||||
mfdcr(cpc0_strp1) );
|
||||
}
|
||||
break;
|
||||
case PVR_440GP_RC:
|
||||
putc('C');
|
||||
break;
|
||||
default:
|
||||
printf("UNKNOWN (PVR=%08x)", pvr);
|
||||
printf ("UNKNOWN (PVR=%08x)", pvr);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("\n");
|
||||
puts ("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -208,18 +198,18 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
||||
|
||||
#if defined(CONFIG_440)
|
||||
static
|
||||
int do_chip_reset( unsigned long sys0, unsigned long sys1 )
|
||||
int do_chip_reset (unsigned long sys0, unsigned long sys1)
|
||||
{
|
||||
/* Changes to cpc0_sys0 and cpc0_sys1 require chip
|
||||
* reset.
|
||||
*/
|
||||
mtdcr( cntrl0, mfdcr(cntrl0) | 0x80000000 ); /* Set SWE */
|
||||
mtdcr( cpc0_sys0, sys0 );
|
||||
mtdcr( cpc0_sys1, sys1 );
|
||||
mtdcr( cntrl0, mfdcr(cntrl0) & ~0x80000000 ); /* Clr SWE */
|
||||
mtspr( dbcr0, 0x20000000); /* Reset the chip */
|
||||
/* Changes to cpc0_sys0 and cpc0_sys1 require chip
|
||||
* reset.
|
||||
*/
|
||||
mtdcr (cntrl0, mfdcr (cntrl0) | 0x80000000); /* Set SWE */
|
||||
mtdcr (cpc0_sys0, sys0);
|
||||
mtdcr (cpc0_sys1, sys1);
|
||||
mtdcr (cntrl0, mfdcr (cntrl0) & ~0x80000000); /* Clr SWE */
|
||||
mtspr (dbcr0, 0x20000000); /* Reset the chip */
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -101,6 +101,9 @@ int miiphy_read (unsigned char addr, unsigned char reg,
|
||||
sta_reg = reg; /* reg address */
|
||||
/* set clock (50Mhz) and read flags */
|
||||
sta_reg = (sta_reg | EMAC_STACR_READ) & ~EMAC_STACR_CLK_100MHZ;
|
||||
#ifdef CONFIG_PHY_CLK_FREQ
|
||||
sta_reg = sta_reg | CONFIG_PHY_CLK_FREQ;
|
||||
#endif
|
||||
sta_reg = sta_reg | (addr << 5); /* Phy address */
|
||||
|
||||
out32 (EMAC_STACR, sta_reg);
|
||||
@@ -156,6 +159,9 @@ int miiphy_write (unsigned char addr, unsigned char reg,
|
||||
sta_reg = reg; /* reg address */
|
||||
/* set clock (50Mhz) and read flags */
|
||||
sta_reg = (sta_reg | EMAC_STACR_WRITE) & ~EMAC_STACR_CLK_100MHZ;
|
||||
#ifdef CONFIG_PHY_CLK_FREQ
|
||||
sta_reg = sta_reg | CONFIG_PHY_CLK_FREQ; /* Set clock frequency (PLB freq. dependend) */
|
||||
#endif
|
||||
sta_reg = sta_reg | ((unsigned long) addr << 5); /* Phy address */
|
||||
memcpy (&sta_reg, &value, 2); /* put in data */
|
||||
|
||||
|
||||
@@ -702,7 +702,8 @@ _start:
|
||||
/* NEVER RETURNS! */
|
||||
bl board_init_f /* run first part of init code (from Flash) */
|
||||
|
||||
#endif /* CONFIG_405GP || CONFIG_405CR */
|
||||
#endif /* CONFIG_405GP || CONFIG_405CR || CONFIG_405 || CONFIG_405EP */
|
||||
/*----------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -26,11 +26,19 @@
|
||||
#include <mmc.h>
|
||||
#include <asm/errno.h>
|
||||
#include <asm/arch/hardware.h>
|
||||
#include <part.h>
|
||||
|
||||
#ifdef CONFIG_MMC
|
||||
|
||||
extern int
|
||||
fat_register_read(int(*block_read)(int device, ulong blknr, ulong blkcnt, uchar *buffer));
|
||||
fat_register_device(block_dev_desc_t *dev_desc, int part_no);
|
||||
|
||||
static block_dev_desc_t mmc_dev;
|
||||
|
||||
block_dev_desc_t * mmc_get_dev(int dev)
|
||||
{
|
||||
return ((block_dev_desc_t *)&mmc_dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME needs to read cid and csd info to determine block size
|
||||
@@ -379,9 +387,9 @@ mmc_write(uchar *src, ulong dst, int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ulong
|
||||
/****************************************************/
|
||||
mmc_bread(int dev_num, ulong blknr, ulong blkcnt, uchar *dst)
|
||||
mmc_bread(int dev_num, ulong blknr, ulong blkcnt, ulong *dst)
|
||||
/****************************************************/
|
||||
{
|
||||
int mmc_block_size = MMC_BLOCK_SIZE;
|
||||
@@ -441,6 +449,21 @@ mmc_init(int verbose)
|
||||
printf("Month = %d\n",cid->month);
|
||||
printf("Year = %d\n",1997 + cid->year);
|
||||
}
|
||||
/* fill in device description */
|
||||
mmc_dev.if_type = IF_TYPE_MMC;
|
||||
mmc_dev.dev = 0;
|
||||
mmc_dev.lun = 0;
|
||||
mmc_dev.type = 0;
|
||||
/* FIXME fill in the correct size (is set to 32MByte) */
|
||||
mmc_dev.blksz = 512;
|
||||
mmc_dev.lba = 0x10000;
|
||||
sprintf(mmc_dev.vendor,"Man %02x%02x%02x Snr %02x%02x%02x",
|
||||
cid->id[0], cid->id[1], cid->id[2],
|
||||
cid->sn[0], cid->sn[1], cid->sn[2]);
|
||||
sprintf(mmc_dev.product,"%s",cid->name);
|
||||
sprintf(mmc_dev.revision,"%x %x",cid->hwrev, cid->fwrev);
|
||||
mmc_dev.removable = 0;
|
||||
mmc_dev.block_read = mmc_bread;
|
||||
|
||||
/* MMC exists, get CSD too */
|
||||
resp = mmc_cmd(MMC_CMD_SET_RCA, MMC_DEFAULT_RCA, 0, MMC_CMDAT_R1);
|
||||
@@ -458,7 +481,7 @@ mmc_init(int verbose)
|
||||
MMC_CLKRT = 0; /* 20 MHz */
|
||||
resp = mmc_cmd(7, MMC_DEFAULT_RCA, 0, MMC_CMDAT_R1);
|
||||
|
||||
fat_register_read(mmc_bread);
|
||||
fat_register_device(&mmc_dev,1); /* partitions start counting with 1 */
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,9 @@
|
||||
#define PRINTF(fmt,args...)
|
||||
#endif
|
||||
|
||||
#if (CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI)
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) )
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/*
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
#include <ide.h>
|
||||
#include "part_dos.h"
|
||||
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI)) && defined(CONFIG_DOS_PARTITION)
|
||||
#if ((CONFIG_COMMANDS & CFG_CMD_IDE) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_SCSI) || \
|
||||
(CONFIG_COMMANDS & CFG_CMD_USB) ) && defined(CONFIG_DOS_PARTITION)
|
||||
|
||||
/* Convert char[4] in little endian format to the host format integer
|
||||
*/
|
||||
@@ -65,6 +67,17 @@ static void print_one_part (dos_partition_t *p, int ext_part_sector, int part_nu
|
||||
(is_extended (p->sys_ind) ? " Extd" : ""));
|
||||
}
|
||||
|
||||
static int test_block_type(unsigned char *buffer)
|
||||
{
|
||||
if((buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
|
||||
(buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
|
||||
return (-1);
|
||||
} /* no DOS Signature at all */
|
||||
if(strncmp(&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0)
|
||||
return DOS_PBR; /* is PBR */
|
||||
return DOS_MBR; /* Is MBR */
|
||||
}
|
||||
|
||||
|
||||
int test_part_dos (block_dev_desc_t *dev_desc)
|
||||
{
|
||||
@@ -92,14 +105,18 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s
|
||||
dev_desc->dev, ext_part_sector);
|
||||
return;
|
||||
}
|
||||
if (buffer[DOS_PART_MAGIC_OFFSET] != 0x55 ||
|
||||
buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) {
|
||||
i=test_block_type(buffer);
|
||||
if(i==-1) {
|
||||
printf ("bad MBR sector signature 0x%02x%02x\n",
|
||||
buffer[DOS_PART_MAGIC_OFFSET],
|
||||
buffer[DOS_PART_MAGIC_OFFSET + 1]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(i==DOS_PBR) {
|
||||
printf (" 1\t\t 0\t%10ld\t%2x\n",
|
||||
dev_desc->lba, buffer[DOS_PBR_MEDIA_TYPE_OFFSET]);
|
||||
return;
|
||||
}
|
||||
/* Print all primary/logical partitions */
|
||||
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
|
||||
for (i = 0; i < 4; i++, pt++) {
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
#endif
|
||||
#define DOS_PART_TBL_OFFSET 0x1be
|
||||
#define DOS_PART_MAGIC_OFFSET 0x1fe
|
||||
#define DOS_PBR_FSTYPE_OFFSET 0x36
|
||||
#define DOS_PBR_MEDIA_TYPE_OFFSET 0x15
|
||||
#define DOS_MBR 0
|
||||
#define DOS_PBR 1
|
||||
|
||||
typedef struct dos_partition {
|
||||
unsigned char boot_ind; /* 0x80 - active */
|
||||
|
||||
@@ -5,7 +5,7 @@ This project is to support Power-On-Self-Test (POST) in U-Boot.
|
||||
|
||||
1. High-level requirements
|
||||
|
||||
The key rquirements for this project are as follows:
|
||||
The key requirements for this project are as follows:
|
||||
|
||||
1) The project shall develop a flexible framework for implementing
|
||||
and running Power-On-Self-Test in U-Boot. This framework shall
|
||||
@@ -72,7 +72,7 @@ tests. All POST tests will be divided into the following groups:
|
||||
This group will contain those tests that do not take much
|
||||
time and can be run on the regular basis (e.g. CPU test)
|
||||
|
||||
3) Tests running on in special "slow test more" only
|
||||
3) Tests running in special "slow test mode" only
|
||||
|
||||
This group will contain POST tests that consume much time
|
||||
and cannot be run regularly (e.g. strong memory test, I2C test)
|
||||
@@ -92,7 +92,7 @@ Specifically, the following groups will be singled out:
|
||||
|
||||
1) Tests running before relocating to RAM
|
||||
|
||||
These tests will run immediatelly after initializing RAM
|
||||
These tests will run immediately after initializing RAM
|
||||
as to enable modifying it without taking care of its
|
||||
contents. Basically, this group will contain memory tests
|
||||
only.
|
||||
|
||||
@@ -428,7 +428,7 @@ int pci_hose_scan_bus(struct pci_controller *hose, int bus)
|
||||
dev < PCI_BDF(bus,PCI_MAX_PCI_DEVICES-1,PCI_MAX_PCI_FUNCTIONS-1);
|
||||
dev += PCI_BDF(0,0,1))
|
||||
{
|
||||
#ifndef CONFIG_405GP /* don't skip host bridge on ppc405gp */
|
||||
#if ((!defined(CONFIG_405GP)) && (!defined(CONFIG_405EP))) /* don't skip host bridge on ppc405gp and 405ep */
|
||||
/* Skip our host bridge */
|
||||
if ( dev == PCI_BDF(hose->first_busno,0,0) )
|
||||
continue;
|
||||
|
||||
102
drivers/sk98lin/Makefile
Normal file
102
drivers/sk98lin/Makefile
Normal file
@@ -0,0 +1,102 @@
|
||||
#
|
||||
# (C) Copyright 2003
|
||||
# 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
|
||||
#
|
||||
# File: drivers/sk98lin/Makefile
|
||||
#
|
||||
# Makefile for the SysKonnect SK-98xx device driver.
|
||||
#
|
||||
|
||||
LIB := libsk98lin.a
|
||||
|
||||
OBJS := skge.o skaddr.o skgehwt.o skgeinit.o skgepnmi.o skgesirq.o \
|
||||
ski2c.o sklm80.o skqueue.o skrlmt.o sktimer.o skvpd.o \
|
||||
skxmac2.o skcsum.o #skproc.o
|
||||
|
||||
OBJS += uboot_skb.o uboot_drv.o
|
||||
|
||||
# DBGDEF = \
|
||||
# -DDEBUG
|
||||
|
||||
ifdef DEBUG
|
||||
DBGDEF += \
|
||||
-DSK_DEBUG_CHKMOD=0x00000000L \
|
||||
-DSK_DEBUG_CHKCAT=0x00000000L
|
||||
endif
|
||||
|
||||
|
||||
# **** possible debug modules for SK_DEBUG_CHKMOD *****************
|
||||
# SK_DBGMOD_MERR 0x00000001L /* general module error indication */
|
||||
# SK_DBGMOD_HWM 0x00000002L /* Hardware init module */
|
||||
# SK_DBGMOD_RLMT 0x00000004L /* RLMT module */
|
||||
# SK_DBGMOD_VPD 0x00000008L /* VPD module */
|
||||
# SK_DBGMOD_I2C 0x00000010L /* I2C module */
|
||||
# SK_DBGMOD_PNMI 0x00000020L /* PNMI module */
|
||||
# SK_DBGMOD_CSUM 0x00000040L /* CSUM module */
|
||||
# SK_DBGMOD_ADDR 0x00000080L /* ADDR module */
|
||||
# SK_DBGMOD_DRV 0x00010000L /* DRV module */
|
||||
|
||||
# **** possible debug categories for SK_DEBUG_CHKCAT **************
|
||||
# *** common modules ***
|
||||
# SK_DBGCAT_INIT 0x00000001L module/driver initialization
|
||||
# SK_DBGCAT_CTRL 0x00000002L controlling: add/rmv MCA/MAC and other controls (IOCTL)
|
||||
# SK_DBGCAT_ERR 0x00000004L error handling paths
|
||||
# SK_DBGCAT_TX 0x00000008L transmit path
|
||||
# SK_DBGCAT_RX 0x00000010L receive path
|
||||
# SK_DBGCAT_IRQ 0x00000020L general IRQ handling
|
||||
# SK_DBGCAT_QUEUE 0x00000040L any queue management
|
||||
# SK_DBGCAT_DUMP 0x00000080L large data output e.g. hex dump
|
||||
# SK_DBGCAT_FATAL 0x00000100L large data output e.g. hex dump
|
||||
|
||||
# *** driver (file skge.c) ***
|
||||
# SK_DBGCAT_DRV_ENTRY 0x00010000 entry points
|
||||
# SK_DBGCAT_DRV_??? 0x00020000 not used
|
||||
# SK_DBGCAT_DRV_MCA 0x00040000 multicast
|
||||
# SK_DBGCAT_DRV_TX_PROGRESS 0x00080000 tx path
|
||||
# SK_DBGCAT_DRV_RX_PROGRESS 0x00100000 rx path
|
||||
# SK_DBGCAT_DRV_PROGRESS 0x00200000 general runtime
|
||||
# SK_DBGCAT_DRV_??? 0x00400000 not used
|
||||
# SK_DBGCAT_DRV_PROM 0x00800000 promiscuous mode
|
||||
# SK_DBGCAT_DRV_TX_FRAME 0x01000000 display tx frames
|
||||
# SK_DBGCAT_DRV_ERROR 0x02000000 error conditions
|
||||
# SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources
|
||||
# SK_DBGCAT_DRV_EVENT 0x08000000 driver events
|
||||
|
||||
EXTRA_CFLAGS += -I. -DSK_USE_CSUM $(DBGDEF)
|
||||
|
||||
CFLAGS += $(EXTRA_CFLAGS)
|
||||
|
||||
|
||||
all: $(LIB)
|
||||
|
||||
$(LIB): $(OBJS)
|
||||
$(AR) crv $@ $(OBJS)
|
||||
|
||||
#########################################################################
|
||||
|
||||
.depend: Makefile $(OBJS:.o=.c)
|
||||
$(CC) -M $(CFLAGS) $(OBJS:.o=.c) > $@
|
||||
|
||||
sinclude .depend
|
||||
|
||||
#########################################################################
|
||||
|
||||
|
||||
197
drivers/sk98lin/h/lm80.h
Normal file
197
drivers/sk98lin/h/lm80.h
Normal file
@@ -0,0 +1,197 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: lm80.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.4 $
|
||||
* Date: $Date: 2002/04/25 11:04:10 $
|
||||
* Purpose: Contains all defines for the LM80 Chip
|
||||
* (National Semiconductor).
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2002 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
* $Log: lm80.h,v $
|
||||
* Revision 1.4 2002/04/25 11:04:10 rschmidt
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.3 1999/11/22 13:41:19 cgoos
|
||||
* Changed license header to GPL.
|
||||
*
|
||||
* Revision 1.2 1999/03/12 13:26:51 malthoff
|
||||
* remove __STDC__.
|
||||
*
|
||||
* Revision 1.1 1998/06/19 09:28:31 malthoff
|
||||
* created.
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INC_LM80_H
|
||||
#define __INC_LM80_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* defines ********************************************************************/
|
||||
|
||||
/*
|
||||
* LM80 register definition
|
||||
*
|
||||
* All registers are 8 bit wide
|
||||
*/
|
||||
#define LM80_CFG 0x00 /* Configuration Register */
|
||||
#define LM80_ISRC_1 0x01 /* Interrupt Status Register 1 */
|
||||
#define LM80_ISRC_2 0x02 /* Interrupt Status Register 2 */
|
||||
#define LM80_IMSK_1 0x03 /* Interrupt Mask Register 1 */
|
||||
#define LM80_IMSK_2 0x04 /* Interrupt Mask Register 2 */
|
||||
#define LM80_FAN_CTRL 0x05 /* Fan Devisor/RST#/OS# Register */
|
||||
#define LM80_TEMP_CTRL 0x06 /* OS# Config, Temp Res. Reg */
|
||||
/* 0x07 - 0x1f reserved */
|
||||
/* current values */
|
||||
#define LM80_VT0_IN 0x20 /* current Voltage 0 value */
|
||||
#define LM80_VT1_IN 0x21 /* current Voltage 1 value */
|
||||
#define LM80_VT2_IN 0x22 /* current Voltage 2 value */
|
||||
#define LM80_VT3_IN 0x23 /* current Voltage 3 value */
|
||||
#define LM80_VT4_IN 0x24 /* current Voltage 4 value */
|
||||
#define LM80_VT5_IN 0x25 /* current Voltage 5 value */
|
||||
#define LM80_VT6_IN 0x26 /* current Voltage 6 value */
|
||||
#define LM80_TEMP_IN 0x27 /* current Temperature value */
|
||||
#define LM80_FAN1_IN 0x28 /* current Fan 1 count */
|
||||
#define LM80_FAN2_IN 0x29 /* current Fan 2 count */
|
||||
/* limit values */
|
||||
#define LM80_VT0_HIGH_LIM 0x2a /* high limit val for Voltage 0 */
|
||||
#define LM80_VT0_LOW_LIM 0x2b /* low limit val for Voltage 0 */
|
||||
#define LM80_VT1_HIGH_LIM 0x2c /* high limit val for Voltage 1 */
|
||||
#define LM80_VT1_LOW_LIM 0x2d /* low limit val for Voltage 1 */
|
||||
#define LM80_VT2_HIGH_LIM 0x2e /* high limit val for Voltage 2 */
|
||||
#define LM80_VT2_LOW_LIM 0x2f /* low limit val for Voltage 2 */
|
||||
#define LM80_VT3_HIGH_LIM 0x30 /* high limit val for Voltage 3 */
|
||||
#define LM80_VT3_LOW_LIM 0x31 /* low limit val for Voltage 3 */
|
||||
#define LM80_VT4_HIGH_LIM 0x32 /* high limit val for Voltage 4 */
|
||||
#define LM80_VT4_LOW_LIM 0x33 /* low limit val for Voltage 4 */
|
||||
#define LM80_VT5_HIGH_LIM 0x34 /* high limit val for Voltage 5 */
|
||||
#define LM80_VT5_LOW_LIM 0x35 /* low limit val for Voltage 5 */
|
||||
#define LM80_VT6_HIGH_LIM 0x36 /* high limit val for Voltage 6 */
|
||||
#define LM80_VT6_LOW_LIM 0x37 /* low limit val for Voltage 6 */
|
||||
#define LM80_THOT_LIM_UP 0x38 /* hot temperature limit (high) */
|
||||
#define LM80_THOT_LIM_LO 0x39 /* hot temperature limit (low) */
|
||||
#define LM80_TOS_LIM_UP 0x3a /* OS temperature limit (high) */
|
||||
#define LM80_TOS_LIM_LO 0x3b /* OS temperature limit (low) */
|
||||
#define LM80_FAN1_COUNT_LIM 0x3c /* Fan 1 count limit (high) */
|
||||
#define LM80_FAN2_COUNT_LIM 0x3d /* Fan 2 count limit (low) */
|
||||
/* 0x3e - 0x3f reserved */
|
||||
|
||||
/*
|
||||
* LM80 bit definitions
|
||||
*/
|
||||
|
||||
/* LM80_CFG Configuration Register */
|
||||
#define LM80_CFG_START (1<<0) /* start monitoring operation */
|
||||
#define LM80_CFG_INT_ENA (1<<1) /* enables the INT# Interrupt output */
|
||||
#define LM80_CFG_INT_POL (1<<2) /* INT# pol: 0 act low, 1 act high */
|
||||
#define LM80_CFG_INT_CLR (1<<3) /* disables INT#/RST_OUT#/OS# outputs */
|
||||
#define LM80_CFG_RESET (1<<4) /* signals a reset */
|
||||
#define LM80_CFG_CHASS_CLR (1<<5) /* clears Chassis Intrusion (CI) pin */
|
||||
#define LM80_CFG_GPO (1<<6) /* drives the GPO# pin */
|
||||
#define LM80_CFG_INIT (1<<7) /* restore power on defaults */
|
||||
|
||||
/* LM80_ISRC_1 Interrupt Status Register 1 */
|
||||
/* LM80_IMSK_1 Interrupt Mask Register 1 */
|
||||
#define LM80_IS_VT0 (1<<0) /* limit exceeded for Voltage 0 */
|
||||
#define LM80_IS_VT1 (1<<1) /* limit exceeded for Voltage 1 */
|
||||
#define LM80_IS_VT2 (1<<2) /* limit exceeded for Voltage 2 */
|
||||
#define LM80_IS_VT3 (1<<3) /* limit exceeded for Voltage 3 */
|
||||
#define LM80_IS_VT4 (1<<4) /* limit exceeded for Voltage 4 */
|
||||
#define LM80_IS_VT5 (1<<5) /* limit exceeded for Voltage 5 */
|
||||
#define LM80_IS_VT6 (1<<6) /* limit exceeded for Voltage 6 */
|
||||
#define LM80_IS_INT_IN (1<<7) /* state of INT_IN# */
|
||||
|
||||
/* LM80_ISRC_2 Interrupt Status Register 2 */
|
||||
/* LM80_IMSK_2 Interrupt Mask Register 2 */
|
||||
#define LM80_IS_TEMP (1<<0) /* HOT temperature limit exceeded */
|
||||
#define LM80_IS_BTI (1<<1) /* state of BTI# pin */
|
||||
#define LM80_IS_FAN1 (1<<2) /* count limit exceeded for Fan 1 */
|
||||
#define LM80_IS_FAN2 (1<<3) /* count limit exceeded for Fan 2 */
|
||||
#define LM80_IS_CI (1<<4) /* Chassis Intrusion occured */
|
||||
#define LM80_IS_OS (1<<5) /* OS temperature limit exceeded */
|
||||
/* bit 6 and 7 are reserved in LM80_ISRC_2 */
|
||||
#define LM80_IS_HT_IRQ_MD (1<<6) /* Hot temperature interrupt mode */
|
||||
#define LM80_IS_OT_IRQ_MD (1<<7) /* OS temperature interrupt mode */
|
||||
|
||||
/* LM80_FAN_CTRL Fan Devisor/RST#/OS# Register */
|
||||
#define LM80_FAN1_MD_SEL (1<<0) /* Fan 1 mode select */
|
||||
#define LM80_FAN2_MD_SEL (1<<1) /* Fan 2 mode select */
|
||||
#define LM80_FAN1_PRM_CTL (3<<2) /* Fan 1 speed control */
|
||||
#define LM80_FAN2_PRM_CTL (3<<4) /* Fan 2 speed control */
|
||||
#define LM80_FAN_OS_ENA (1<<6) /* enable OS mode on RST_OUT#/OS# pins*/
|
||||
#define LM80_FAN_RST_ENA (1<<7) /* sets RST_OUT#/OS# pins in RST mode */
|
||||
|
||||
/* LM80_TEMP_CTRL OS# Config, Temp Res. Reg */
|
||||
#define LM80_TEMP_OS_STAT (1<<0) /* mirrors the state of RST_OUT#/OS# */
|
||||
#define LM80_TEMP_OS_POL (1<<1) /* select OS# polarity */
|
||||
#define LM80_TEMP_OS_MODE (1<<2) /* selects Interrupt mode */
|
||||
#define LM80_TEMP_RES (1<<3) /* selects 9 or 11 bit temp resulution*/
|
||||
#define LM80_TEMP_LSB (0xf<<4)/* 4 LSBs of 11 bit temp data */
|
||||
#define LM80_TEMP_LSB_9 (1<<7) /* LSB of 9 bit temperature data */
|
||||
|
||||
/* 0x07 - 0x1f reserved */
|
||||
/* LM80_VT0_IN current Voltage 0 value */
|
||||
/* LM80_VT1_IN current Voltage 1 value */
|
||||
/* LM80_VT2_IN current Voltage 2 value */
|
||||
/* LM80_VT3_IN current Voltage 3 value */
|
||||
/* LM80_VT4_IN current Voltage 4 value */
|
||||
/* LM80_VT5_IN current Voltage 5 value */
|
||||
/* LM80_VT6_IN current Voltage 6 value */
|
||||
/* LM80_TEMP_IN current temperature value */
|
||||
/* LM80_FAN1_IN current Fan 1 count */
|
||||
/* LM80_FAN2_IN current Fan 2 count */
|
||||
/* LM80_VT0_HIGH_LIM high limit val for Voltage 0 */
|
||||
/* LM80_VT0_LOW_LIM low limit val for Voltage 0 */
|
||||
/* LM80_VT1_HIGH_LIM high limit val for Voltage 1 */
|
||||
/* LM80_VT1_LOW_LIM low limit val for Voltage 1 */
|
||||
/* LM80_VT2_HIGH_LIM high limit val for Voltage 2 */
|
||||
/* LM80_VT2_LOW_LIM low limit val for Voltage 2 */
|
||||
/* LM80_VT3_HIGH_LIM high limit val for Voltage 3 */
|
||||
/* LM80_VT3_LOW_LIM low limit val for Voltage 3 */
|
||||
/* LM80_VT4_HIGH_LIM high limit val for Voltage 4 */
|
||||
/* LM80_VT4_LOW_LIM low limit val for Voltage 4 */
|
||||
/* LM80_VT5_HIGH_LIM high limit val for Voltage 5 */
|
||||
/* LM80_VT5_LOW_LIM low limit val for Voltage 5 */
|
||||
/* LM80_VT6_HIGH_LIM high limit val for Voltage 6 */
|
||||
/* LM80_VT6_LOW_LIM low limit val for Voltage 6 */
|
||||
/* LM80_THOT_LIM_UP hot temperature limit (high) */
|
||||
/* LM80_THOT_LIM_LO hot temperature limit (low) */
|
||||
/* LM80_TOS_LIM_UP OS temperature limit (high) */
|
||||
/* LM80_TOS_LIM_LO OS temperature limit (low) */
|
||||
/* LM80_FAN1_COUNT_LIM Fan 1 count limit (high) */
|
||||
/* LM80_FAN2_COUNT_LIM Fan 2 count limit (low) */
|
||||
/* 0x3e - 0x3f reserved */
|
||||
|
||||
#define LM80_ADDR 0x28 /* LM80 default addr */
|
||||
|
||||
/* typedefs *******************************************************************/
|
||||
|
||||
|
||||
/* function prototypes ********************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __INC_LM80_H */
|
||||
425
drivers/sk98lin/h/skaddr.h
Normal file
425
drivers/sk98lin/h/skaddr.h
Normal file
@@ -0,0 +1,425 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skaddr.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.26 $
|
||||
* Date: $Date: 2002/11/15 07:24:42 $
|
||||
* Purpose: Header file for Address Management (MC, UC, Prom).
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2001 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* $Log: skaddr.h,v $
|
||||
* Revision 1.26 2002/11/15 07:24:42 tschilli
|
||||
* SK_ADDR_EQUAL macro fixed.
|
||||
*
|
||||
* Revision 1.25 2002/06/10 13:55:18 tschilli
|
||||
* Changes for handling YUKON.
|
||||
* All changes are internally and not visible to the programmer
|
||||
* using this module.
|
||||
*
|
||||
* Revision 1.24 2001/01/22 13:41:34 rassmann
|
||||
* Supporting two nets on dual-port adapters.
|
||||
*
|
||||
* Revision 1.23 2000/08/10 11:27:50 rassmann
|
||||
* Editorial changes.
|
||||
* Preserving 32-bit alignment in structs for the adapter context.
|
||||
*
|
||||
* Revision 1.22 2000/08/07 11:10:40 rassmann
|
||||
* Editorial changes.
|
||||
*
|
||||
* Revision 1.21 2000/05/04 09:39:59 rassmann
|
||||
* Editorial changes.
|
||||
* Corrected multicast address hashing.
|
||||
*
|
||||
* Revision 1.20 1999/11/22 13:46:14 cgoos
|
||||
* Changed license header to GPL.
|
||||
* Allowing overwrite for SK_ADDR_EQUAL.
|
||||
*
|
||||
* Revision 1.19 1999/05/28 10:56:07 rassmann
|
||||
* Editorial changes.
|
||||
*
|
||||
* Revision 1.18 1999/04/06 17:22:04 rassmann
|
||||
* Added private "ActivePort".
|
||||
*
|
||||
* Revision 1.17 1999/01/14 16:18:19 rassmann
|
||||
* Corrected multicast initialization.
|
||||
*
|
||||
* Revision 1.16 1999/01/04 10:30:36 rassmann
|
||||
* SkAddrOverride only possible after SK_INIT_IO phase.
|
||||
*
|
||||
* Revision 1.15 1998/12/29 13:13:11 rassmann
|
||||
* An address override is now preserved in the SK_INIT_IO phase.
|
||||
* All functions return an int now.
|
||||
* Extended parameter checking.
|
||||
*
|
||||
* Revision 1.14 1998/11/24 12:39:45 rassmann
|
||||
* Reserved multicast entry for BPDU address.
|
||||
* 13 multicast entries left for protocol.
|
||||
*
|
||||
* Revision 1.13 1998/11/13 17:24:32 rassmann
|
||||
* Changed return value of SkAddrOverride to int.
|
||||
*
|
||||
* Revision 1.12 1998/11/13 16:56:19 rassmann
|
||||
* Added macro SK_ADDR_COMPARE.
|
||||
* Changed return type of SkAddrOverride to SK_BOOL.
|
||||
*
|
||||
* Revision 1.11 1998/10/28 18:16:35 rassmann
|
||||
* Avoiding I/Os before SK_INIT_RUN level.
|
||||
* Aligning InexactFilter.
|
||||
*
|
||||
* Revision 1.10 1998/10/22 11:39:10 rassmann
|
||||
* Corrected signed/unsigned mismatches.
|
||||
*
|
||||
* Revision 1.9 1998/10/15 15:15:49 rassmann
|
||||
* Changed Flags Parameters from SK_U8 to int.
|
||||
* Checked with lint.
|
||||
*
|
||||
* Revision 1.8 1998/09/24 19:15:12 rassmann
|
||||
* Code cleanup.
|
||||
*
|
||||
* Revision 1.7 1998/09/18 20:22:13 rassmann
|
||||
* Added HW access.
|
||||
*
|
||||
* Revision 1.6 1998/09/04 19:40:20 rassmann
|
||||
* Interface enhancements.
|
||||
*
|
||||
* Revision 1.5 1998/09/04 12:40:57 rassmann
|
||||
* Interface cleanup.
|
||||
*
|
||||
* Revision 1.4 1998/09/04 12:14:13 rassmann
|
||||
* Interface cleanup.
|
||||
*
|
||||
* Revision 1.3 1998/09/02 16:56:40 rassmann
|
||||
* Updated interface.
|
||||
*
|
||||
* Revision 1.2 1998/08/27 14:26:09 rassmann
|
||||
* Updated interface.
|
||||
*
|
||||
* Revision 1.1 1998/08/21 08:31:08 rassmann
|
||||
* First public version.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* This module is intended to manage multicast addresses and promiscuous mode
|
||||
* on GEnesis adapters.
|
||||
*
|
||||
* Include File Hierarchy:
|
||||
*
|
||||
* "skdrv1st.h"
|
||||
* ...
|
||||
* "sktypes.h"
|
||||
* "skqueue.h"
|
||||
* "skaddr.h"
|
||||
* ...
|
||||
* "skdrv2nd.h"
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INC_SKADDR_H
|
||||
#define __INC_SKADDR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#error C++ is not yet supported.
|
||||
extern "C" {
|
||||
#endif /* cplusplus */
|
||||
|
||||
/* defines ********************************************************************/
|
||||
|
||||
#define SK_MAC_ADDR_LEN 6 /* Length of MAC address. */
|
||||
#define SK_MAX_ADDRS 14 /* #Addrs for exact match. */
|
||||
|
||||
/* ----- Common return values ----- */
|
||||
|
||||
#define SK_ADDR_SUCCESS 0 /* Function returned successfully. */
|
||||
#define SK_ADDR_ILLEGAL_PORT 100 /* Port number too high. */
|
||||
#define SK_ADDR_TOO_EARLY 101 /* Function called too early. */
|
||||
|
||||
/* ----- Clear/Add flag bits ----- */
|
||||
|
||||
#define SK_ADDR_PERMANENT 1 /* RLMT Address */
|
||||
|
||||
/* ----- Additional Clear flag bits ----- */
|
||||
|
||||
#define SK_MC_SW_ONLY 2 /* Do not update HW when clearing. */
|
||||
|
||||
/* ----- Override flag bits ----- */
|
||||
|
||||
#define SK_ADDR_LOGICAL_ADDRESS 0
|
||||
#define SK_ADDR_VIRTUAL_ADDRESS (SK_ADDR_LOGICAL_ADDRESS) /* old */
|
||||
#define SK_ADDR_PHYSICAL_ADDRESS 1
|
||||
#define SK_ADDR_CLEAR_LOGICAL 2
|
||||
#define SK_ADDR_SET_LOGICAL 4
|
||||
|
||||
/* ----- Override return values ----- */
|
||||
|
||||
#define SK_ADDR_OVERRIDE_SUCCESS (SK_ADDR_SUCCESS)
|
||||
#define SK_ADDR_DUPLICATE_ADDRESS 1
|
||||
#define SK_ADDR_MULTICAST_ADDRESS 2
|
||||
|
||||
/* ----- Partitioning of excact match table ----- */
|
||||
|
||||
#define SK_ADDR_EXACT_MATCHES 16 /* #Exact match entries. */
|
||||
|
||||
#define SK_ADDR_FIRST_MATCH_RLMT 1
|
||||
#define SK_ADDR_LAST_MATCH_RLMT 2
|
||||
#define SK_ADDR_FIRST_MATCH_DRV 3
|
||||
#define SK_ADDR_LAST_MATCH_DRV (SK_ADDR_EXACT_MATCHES - 1)
|
||||
|
||||
/* ----- SkAddrMcAdd/SkAddrMcUpdate return values ----- */
|
||||
|
||||
#define SK_MC_FILTERING_EXACT 0 /* Exact filtering. */
|
||||
#define SK_MC_FILTERING_INEXACT 1 /* Inexact filtering. */
|
||||
|
||||
/* ----- Additional SkAddrMcAdd return values ----- */
|
||||
|
||||
#define SK_MC_ILLEGAL_ADDRESS 2 /* Illegal address. */
|
||||
#define SK_MC_ILLEGAL_PORT 3 /* Illegal port (not the active one). */
|
||||
#define SK_MC_RLMT_OVERFLOW 4 /* Too many RLMT mc addresses. */
|
||||
|
||||
/* Promiscuous mode bits ----- */
|
||||
|
||||
#define SK_PROM_MODE_NONE 0 /* Normal receive. */
|
||||
#define SK_PROM_MODE_LLC 1 /* Receive all LLC frames. */
|
||||
#define SK_PROM_MODE_ALL_MC 2 /* Receive all multicast frames. */
|
||||
/* #define SK_PROM_MODE_NON_LLC 4 */ /* Receive all non-LLC frames. */
|
||||
|
||||
/* Macros */
|
||||
|
||||
#if 0
|
||||
#ifndef SK_ADDR_EQUAL
|
||||
/*
|
||||
* "&" instead of "&&" allows better optimization on IA-64.
|
||||
* The replacement is safe here, as all bytes exist.
|
||||
*/
|
||||
#ifndef SK_ADDR_DWORD_COMPARE
|
||||
#define SK_ADDR_EQUAL(A1,A2) ( \
|
||||
(((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
|
||||
(((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
|
||||
(((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
|
||||
(((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
|
||||
(((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
|
||||
(((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
|
||||
#else /* SK_ADDR_DWORD_COMPARE */
|
||||
#define SK_ADDR_EQUAL(A1,A2) ( \
|
||||
(*(SK_U32 *)&(((SK_U8 *)(A1))[2]) == *(SK_U32 *)&(((SK_U8 *)(A2))[2])) & \
|
||||
(*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
|
||||
#endif /* SK_ADDR_DWORD_COMPARE */
|
||||
#endif /* SK_ADDR_EQUAL */
|
||||
#endif /* 0 */
|
||||
|
||||
#ifndef SK_ADDR_EQUAL
|
||||
#ifndef SK_ADDR_DWORD_COMPARE
|
||||
#define SK_ADDR_EQUAL(A1,A2) ( \
|
||||
(((SK_U8 *)(A1))[5] == ((SK_U8 *)(A2))[5]) & \
|
||||
(((SK_U8 *)(A1))[4] == ((SK_U8 *)(A2))[4]) & \
|
||||
(((SK_U8 *)(A1))[3] == ((SK_U8 *)(A2))[3]) & \
|
||||
(((SK_U8 *)(A1))[2] == ((SK_U8 *)(A2))[2]) & \
|
||||
(((SK_U8 *)(A1))[1] == ((SK_U8 *)(A2))[1]) & \
|
||||
(((SK_U8 *)(A1))[0] == ((SK_U8 *)(A2))[0]))
|
||||
#else /* SK_ADDR_DWORD_COMPARE */
|
||||
#define SK_ADDR_EQUAL(A1,A2) ( \
|
||||
(*(SK_U16 *)&(((SK_U8 *)(A1))[4]) == *(SK_U16 *)&(((SK_U8 *)(A2))[4])) && \
|
||||
(*(SK_U32 *)&(((SK_U8 *)(A1))[0]) == *(SK_U32 *)&(((SK_U8 *)(A2))[0])))
|
||||
#endif /* SK_ADDR_DWORD_COMPARE */
|
||||
#endif /* SK_ADDR_EQUAL */
|
||||
|
||||
/* typedefs *******************************************************************/
|
||||
|
||||
typedef struct s_MacAddr {
|
||||
SK_U8 a[SK_MAC_ADDR_LEN];
|
||||
} SK_MAC_ADDR;
|
||||
|
||||
|
||||
/* SK_FILTER is used to ensure alignment of the filter. */
|
||||
typedef union s_InexactFilter {
|
||||
SK_U8 Bytes[8];
|
||||
SK_U64 Val; /* Dummy entry for alignment only. */
|
||||
} SK_FILTER64;
|
||||
|
||||
|
||||
typedef struct s_AddrNet SK_ADDR_NET;
|
||||
|
||||
|
||||
typedef struct s_AddrPort {
|
||||
|
||||
/* ----- Public part (read-only) ----- */
|
||||
|
||||
SK_MAC_ADDR CurrentMacAddress; /* Current physical MAC Address. */
|
||||
SK_MAC_ADDR PermanentMacAddress; /* Permanent physical MAC Address. */
|
||||
int PromMode; /* Promiscuous Mode. */
|
||||
|
||||
/* ----- Private part ----- */
|
||||
|
||||
SK_MAC_ADDR PreviousMacAddress; /* Prev. phys. MAC Address. */
|
||||
SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
|
||||
SK_U8 Align01;
|
||||
|
||||
SK_U32 FirstExactMatchRlmt;
|
||||
SK_U32 NextExactMatchRlmt;
|
||||
SK_U32 FirstExactMatchDrv;
|
||||
SK_U32 NextExactMatchDrv;
|
||||
SK_MAC_ADDR Exact[SK_ADDR_EXACT_MATCHES];
|
||||
SK_FILTER64 InexactFilter; /* For 64-bit hash register. */
|
||||
SK_FILTER64 InexactRlmtFilter; /* For 64-bit hash register. */
|
||||
SK_FILTER64 InexactDrvFilter; /* For 64-bit hash register. */
|
||||
} SK_ADDR_PORT;
|
||||
|
||||
|
||||
struct s_AddrNet {
|
||||
/* ----- Public part (read-only) ----- */
|
||||
|
||||
SK_MAC_ADDR CurrentMacAddress; /* Logical MAC Address. */
|
||||
SK_MAC_ADDR PermanentMacAddress; /* Logical MAC Address. */
|
||||
|
||||
/* ----- Private part ----- */
|
||||
|
||||
SK_U32 ActivePort; /* View of module ADDR. */
|
||||
SK_BOOL CurrentMacAddressSet; /* CurrentMacAddress is set. */
|
||||
SK_U8 Align01;
|
||||
SK_U16 Align02;
|
||||
};
|
||||
|
||||
|
||||
typedef struct s_Addr {
|
||||
|
||||
/* ----- Public part (read-only) ----- */
|
||||
|
||||
SK_ADDR_NET Net[SK_MAX_NETS];
|
||||
SK_ADDR_PORT Port[SK_MAX_MACS];
|
||||
|
||||
/* ----- Private part ----- */
|
||||
} SK_ADDR;
|
||||
|
||||
/* function prototypes ********************************************************/
|
||||
|
||||
#ifndef SK_KR_PROTO
|
||||
|
||||
/* Functions provided by SkAddr */
|
||||
|
||||
/* ANSI/C++ compliant function prototypes */
|
||||
|
||||
extern int SkAddrInit(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
int Level);
|
||||
|
||||
extern int SkAddrMcClear(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
int Flags);
|
||||
|
||||
extern int SkAddrXmacMcClear(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
int Flags);
|
||||
|
||||
extern int SkAddrGmacMcClear(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
int Flags);
|
||||
|
||||
extern int SkAddrMcAdd(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
SK_MAC_ADDR *pMc,
|
||||
int Flags);
|
||||
|
||||
extern int SkAddrXmacMcAdd(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
SK_MAC_ADDR *pMc,
|
||||
int Flags);
|
||||
|
||||
extern int SkAddrGmacMcAdd(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
SK_MAC_ADDR *pMc,
|
||||
int Flags);
|
||||
|
||||
extern int SkAddrMcUpdate(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber);
|
||||
|
||||
extern int SkAddrXmacMcUpdate(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber);
|
||||
|
||||
extern int SkAddrGmacMcUpdate(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber);
|
||||
|
||||
extern int SkAddrOverride(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
SK_MAC_ADDR *pNewAddr,
|
||||
int Flags);
|
||||
|
||||
extern int SkAddrPromiscuousChange(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
int NewPromMode);
|
||||
|
||||
extern int SkAddrXmacPromiscuousChange(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
int NewPromMode);
|
||||
|
||||
extern int SkAddrGmacPromiscuousChange(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 PortNumber,
|
||||
int NewPromMode);
|
||||
|
||||
extern int SkAddrSwap(
|
||||
SK_AC *pAC,
|
||||
SK_IOC IoC,
|
||||
SK_U32 FromPortNumber,
|
||||
SK_U32 ToPortNumber);
|
||||
|
||||
#else /* defined(SK_KR_PROTO)) */
|
||||
|
||||
/* Non-ANSI/C++ compliant function prototypes */
|
||||
|
||||
#error KR-style prototypes are not yet provided.
|
||||
|
||||
#endif /* defined(SK_KR_PROTO)) */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __INC_SKADDR_H */
|
||||
261
drivers/sk98lin/h/skcsum.h
Normal file
261
drivers/sk98lin/h/skcsum.h
Normal file
@@ -0,0 +1,261 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skcsum.h
|
||||
* Project: GEnesis - SysKonnect SK-NET Gigabit Ethernet (SK-98xx)
|
||||
* Version: $Revision: 1.9 $
|
||||
* Date: $Date: 2001/02/06 11:21:39 $
|
||||
* Purpose: Store/verify Internet checksum in send/receive packets.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2001 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* $Log: skcsum.h,v $
|
||||
* Revision 1.9 2001/02/06 11:21:39 rassmann
|
||||
* Editorial changes.
|
||||
*
|
||||
* Revision 1.8 2001/02/06 11:15:36 rassmann
|
||||
* Supporting two nets on dual-port adapters.
|
||||
*
|
||||
* Revision 1.7 2000/06/29 13:17:05 rassmann
|
||||
* Corrected reception of a packet with UDP checksum == 0 (which means there
|
||||
* is no UDP checksum).
|
||||
*
|
||||
* Revision 1.6 2000/02/28 12:33:44 cgoos
|
||||
* Changed C++ style comments to C style.
|
||||
*
|
||||
* Revision 1.5 2000/02/21 12:10:05 cgoos
|
||||
* Fixed license comment.
|
||||
*
|
||||
* Revision 1.4 2000/02/21 11:08:37 cgoos
|
||||
* Merged changes back into common source.
|
||||
*
|
||||
* Revision 1.1 1999/07/26 14:47:49 mkarl
|
||||
* changed from common source to windows specific source
|
||||
* added return SKCS_STATUS_IP_CSUM_ERROR_UDP and
|
||||
* SKCS_STATUS_IP_CSUM_ERROR_TCP to pass the NidsTester
|
||||
* changes for Tx csum offload
|
||||
*
|
||||
* Revision 1.2 1998/09/04 12:16:34 mhaveman
|
||||
* Checked in for Stephan to allow compilation.
|
||||
* -Added definition SK_CSUM_EVENT_CLEAR_PROTO_STATS to clear statistic
|
||||
* -Added prototype for SkCsEvent()
|
||||
*
|
||||
* Revision 1.1 1998/09/01 15:36:53 swolf
|
||||
* initial revision
|
||||
*
|
||||
* 01-Sep-1998 sw Created.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* Public header file for the "GEnesis" common module "CSUM".
|
||||
*
|
||||
* "GEnesis" is an abbreviation of "Gigabit Ethernet Network System in Silicon"
|
||||
* and is the code name of this SysKonnect project.
|
||||
*
|
||||
* Compilation Options:
|
||||
*
|
||||
* SK_USE_CSUM - Define if CSUM is to be used. Otherwise, CSUM will be an
|
||||
* empty module.
|
||||
*
|
||||
* SKCS_OVERWRITE_PROTO - Define to overwrite the default protocol id
|
||||
* definitions. In this case, all SKCS_PROTO_xxx definitions must be made
|
||||
* external.
|
||||
*
|
||||
* SKCS_OVERWRITE_STATUS - Define to overwrite the default return status
|
||||
* definitions. In this case, all SKCS_STATUS_xxx definitions must be made
|
||||
* external.
|
||||
*
|
||||
* Include File Hierarchy:
|
||||
*
|
||||
* "h/skcsum.h"
|
||||
* "h/sktypes.h"
|
||||
* "h/skqueue.h"
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INC_SKCSUM_H
|
||||
#define __INC_SKCSUM_H
|
||||
|
||||
#include "h/sktypes.h"
|
||||
#include "h/skqueue.h"
|
||||
|
||||
/* defines ********************************************************************/
|
||||
|
||||
/*
|
||||
* Define the default bit flags for 'SKCS_PACKET_INFO.ProtocolFlags' if no user
|
||||
* overwrite.
|
||||
*/
|
||||
#ifndef SKCS_OVERWRITE_PROTO /* User overwrite? */
|
||||
#define SKCS_PROTO_IP 0x1 /* IP (Internet Protocol version 4) */
|
||||
#define SKCS_PROTO_TCP 0x2 /* TCP (Transmission Control Protocol) */
|
||||
#define SKCS_PROTO_UDP 0x4 /* UDP (User Datagram Protocol) */
|
||||
|
||||
/* Indices for protocol statistics. */
|
||||
#define SKCS_PROTO_STATS_IP 0
|
||||
#define SKCS_PROTO_STATS_UDP 1
|
||||
#define SKCS_PROTO_STATS_TCP 2
|
||||
#define SKCS_NUM_PROTOCOLS 3 /* Number of supported protocols. */
|
||||
#endif /* !SKCS_OVERWRITE_PROTO */
|
||||
|
||||
/*
|
||||
* Define the default SKCS_STATUS type and values if no user overwrite.
|
||||
*
|
||||
* SKCS_STATUS_UNKNOWN_IP_VERSION - Not an IP v4 frame.
|
||||
* SKCS_STATUS_IP_CSUM_ERROR - IP checksum error.
|
||||
* SKCS_STATUS_IP_CSUM_ERROR_TCP - IP checksum error in TCP frame.
|
||||
* SKCS_STATUS_IP_CSUM_ERROR_UDP - IP checksum error in UDP frame
|
||||
* SKCS_STATUS_IP_FRAGMENT - IP fragment (IP checksum ok).
|
||||
* SKCS_STATUS_IP_CSUM_OK - IP checksum ok (not a TCP or UDP frame).
|
||||
* SKCS_STATUS_TCP_CSUM_ERROR - TCP checksum error (IP checksum ok).
|
||||
* SKCS_STATUS_UDP_CSUM_ERROR - UDP checksum error (IP checksum ok).
|
||||
* SKCS_STATUS_TCP_CSUM_OK - IP and TCP checksum ok.
|
||||
* SKCS_STATUS_UDP_CSUM_OK - IP and UDP checksum ok.
|
||||
* SKCS_STATUS_IP_CSUM_OK_NO_UDP - IP checksum OK and no UDP checksum.
|
||||
*/
|
||||
#ifndef SKCS_OVERWRITE_STATUS /* User overwrite? */
|
||||
#define SKCS_STATUS int /* Define status type. */
|
||||
|
||||
#define SKCS_STATUS_UNKNOWN_IP_VERSION 1
|
||||
#define SKCS_STATUS_IP_CSUM_ERROR 2
|
||||
#define SKCS_STATUS_IP_FRAGMENT 3
|
||||
#define SKCS_STATUS_IP_CSUM_OK 4
|
||||
#define SKCS_STATUS_TCP_CSUM_ERROR 5
|
||||
#define SKCS_STATUS_UDP_CSUM_ERROR 6
|
||||
#define SKCS_STATUS_TCP_CSUM_OK 7
|
||||
#define SKCS_STATUS_UDP_CSUM_OK 8
|
||||
/* needed for Microsoft */
|
||||
#define SKCS_STATUS_IP_CSUM_ERROR_UDP 9
|
||||
#define SKCS_STATUS_IP_CSUM_ERROR_TCP 10
|
||||
/* UDP checksum may be omitted */
|
||||
#define SKCS_STATUS_IP_CSUM_OK_NO_UDP 11
|
||||
#endif /* !SKCS_OVERWRITE_STATUS */
|
||||
|
||||
/* Clear protocol statistics event. */
|
||||
#define SK_CSUM_EVENT_CLEAR_PROTO_STATS 1
|
||||
|
||||
/*
|
||||
* Add two values in one's complement.
|
||||
*
|
||||
* Note: One of the two input values may be "longer" than 16-bit, but then the
|
||||
* resulting sum may be 17 bits long. In this case, add zero to the result using
|
||||
* SKCS_OC_ADD() again.
|
||||
*
|
||||
* Result = Value1 + Value2
|
||||
*/
|
||||
#define SKCS_OC_ADD(Result, Value1, Value2) { \
|
||||
unsigned long Sum; \
|
||||
\
|
||||
Sum = (unsigned long) (Value1) + (unsigned long) (Value2); \
|
||||
/* Add-in any carry. */ \
|
||||
(Result) = (Sum & 0xffff) + (Sum >> 16); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Subtract two values in one's complement.
|
||||
*
|
||||
* Result = Value1 - Value2
|
||||
*/
|
||||
#define SKCS_OC_SUB(Result, Value1, Value2) \
|
||||
SKCS_OC_ADD((Result), (Value1), ~(Value2) & 0xffff)
|
||||
|
||||
/* typedefs *******************************************************************/
|
||||
|
||||
/*
|
||||
* SKCS_PROTO_STATS - The CSUM protocol statistics structure.
|
||||
*
|
||||
* There is one instance of this structure for each protocol supported.
|
||||
*/
|
||||
typedef struct s_CsProtocolStatistics {
|
||||
SK_U64 RxOkCts; /* Receive checksum ok. */
|
||||
SK_U64 RxUnableCts; /* Unable to verify receive checksum. */
|
||||
SK_U64 RxErrCts; /* Receive checksum error. */
|
||||
SK_U64 TxOkCts; /* Transmit checksum ok. */
|
||||
SK_U64 TxUnableCts; /* Unable to calculate checksum in hw. */
|
||||
} SKCS_PROTO_STATS;
|
||||
|
||||
/*
|
||||
* s_Csum - The CSUM module context structure.
|
||||
*/
|
||||
typedef struct s_Csum {
|
||||
/* Enabled receive SK_PROTO_XXX bit flags. */
|
||||
unsigned ReceiveFlags[SK_MAX_NETS];
|
||||
#ifdef TX_CSUM
|
||||
unsigned TransmitFlags[SK_MAX_NETS];
|
||||
#endif /* TX_CSUM */
|
||||
|
||||
/* The protocol statistics structure; one per supported protocol. */
|
||||
SKCS_PROTO_STATS ProtoStats[SK_MAX_NETS][SKCS_NUM_PROTOCOLS];
|
||||
} SK_CSUM;
|
||||
|
||||
/*
|
||||
* SKCS_PACKET_INFO - The packet information structure.
|
||||
*/
|
||||
typedef struct s_CsPacketInfo {
|
||||
/* Bit field specifiying the desired/found protocols. */
|
||||
unsigned ProtocolFlags;
|
||||
|
||||
/* Length of complete IP header, including any option fields. */
|
||||
unsigned IpHeaderLength;
|
||||
|
||||
/* IP header checksum. */
|
||||
unsigned IpHeaderChecksum;
|
||||
|
||||
/* TCP/UDP pseudo header checksum. */
|
||||
unsigned PseudoHeaderChecksum;
|
||||
} SKCS_PACKET_INFO;
|
||||
|
||||
/* function prototypes ********************************************************/
|
||||
|
||||
#ifndef SkCsCalculateChecksum
|
||||
extern unsigned SkCsCalculateChecksum(
|
||||
void *pData,
|
||||
unsigned Length);
|
||||
#endif
|
||||
|
||||
extern int SkCsEvent(
|
||||
SK_AC *pAc,
|
||||
SK_IOC Ioc,
|
||||
SK_U32 Event,
|
||||
SK_EVPARA Param);
|
||||
|
||||
extern SKCS_STATUS SkCsGetReceiveInfo(
|
||||
SK_AC *pAc,
|
||||
void *pIpHeader,
|
||||
unsigned Checksum1,
|
||||
unsigned Checksum2,
|
||||
int NetNumber);
|
||||
|
||||
extern void SkCsGetSendInfo(
|
||||
SK_AC *pAc,
|
||||
void *pIpHeader,
|
||||
SKCS_PACKET_INFO *pPacketInfo,
|
||||
int NetNumber);
|
||||
|
||||
extern void SkCsSetReceiveFlags(
|
||||
SK_AC *pAc,
|
||||
unsigned ReceiveFlags,
|
||||
unsigned *pChecksum1Offset,
|
||||
unsigned *pChecksum2Offset,
|
||||
int NetNumber);
|
||||
|
||||
#endif /* __INC_SKCSUM_H */
|
||||
119
drivers/sk98lin/h/skdebug.h
Normal file
119
drivers/sk98lin/h/skdebug.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skdebug.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.12 $
|
||||
* Date: $Date: 2002/07/15 15:37:13 $
|
||||
* Purpose: SK specific DEBUG support
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2002 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
* $Log: skdebug.h,v $
|
||||
* Revision 1.12 2002/07/15 15:37:13 rschmidt
|
||||
* Power Management support
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.11 2002/04/25 11:04:39 rschmidt
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.10 1999/11/22 13:47:40 cgoos
|
||||
* Changed license header to GPL.
|
||||
*
|
||||
* Revision 1.9 1999/09/14 14:02:43 rwahl
|
||||
* Added SK_DBGMOD_PECP.
|
||||
*
|
||||
* Revision 1.8 1998/11/25 08:31:54 gklug
|
||||
* fix: no C++ comments allowed in common sources
|
||||
*
|
||||
* Revision 1.7 1998/11/24 16:47:24 swolf
|
||||
* Driver may now define its own SK_DBG_MSG() (eg. in "h/skdrv1st.h").
|
||||
*
|
||||
* Revision 1.6 1998/10/28 10:23:55 rassmann
|
||||
* ADDED SK_DBGMOD_ADDR.
|
||||
*
|
||||
* Revision 1.5 1998/10/22 09:43:55 gklug
|
||||
* add: CSUM module
|
||||
*
|
||||
* Revision 1.4 1998/10/01 07:54:44 gklug
|
||||
* add: PNMI debug module
|
||||
*
|
||||
* Revision 1.3 1998/09/18 08:32:34 afischer
|
||||
* Macros changed according ssr-spec.:
|
||||
* SK_DBG_MODCHK -> SK_DBG_CHKMOD
|
||||
* SK_DBG_CATCHK -> SK_DBG_CHKCAT
|
||||
*
|
||||
* Revision 1.2 1998/07/03 14:38:25 malthoff
|
||||
* Add category SK_DBGCAT_FATAL.
|
||||
*
|
||||
* Revision 1.1 1998/06/19 13:39:01 malthoff
|
||||
* created.
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INC_SKDEBUG_H
|
||||
#define __INC_SKDEBUG_H
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifndef SK_DBG_MSG
|
||||
#define SK_DBG_MSG(pAC,comp,cat,arg) \
|
||||
if ( ((comp) & SK_DBG_CHKMOD(pAC)) && \
|
||||
((cat) & SK_DBG_CHKCAT(pAC)) ) { \
|
||||
SK_DBG_PRINTF arg ; \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define SK_DBG_MSG(pAC,comp,lev,arg)
|
||||
#endif
|
||||
|
||||
/* PLS NOTE:
|
||||
* =========
|
||||
* Due to any restrictions of kernel printf routines do not use other
|
||||
* format identifiers as: %x %d %c %s .
|
||||
* Never use any combined format identifiers such as: %lx %ld in your
|
||||
* printf - argument (arg) because some OS specific kernel printfs may
|
||||
* only support some basic identifiers.
|
||||
*/
|
||||
|
||||
/* Debug modules */
|
||||
|
||||
#define SK_DBGMOD_MERR 0x00000001L /* general module error indication */
|
||||
#define SK_DBGMOD_HWM 0x00000002L /* Hardware init module */
|
||||
#define SK_DBGMOD_RLMT 0x00000004L /* RLMT module */
|
||||
#define SK_DBGMOD_VPD 0x00000008L /* VPD module */
|
||||
#define SK_DBGMOD_I2C 0x00000010L /* I2C module */
|
||||
#define SK_DBGMOD_PNMI 0x00000020L /* PNMI module */
|
||||
#define SK_DBGMOD_CSUM 0x00000040L /* CSUM module */
|
||||
#define SK_DBGMOD_ADDR 0x00000080L /* ADDR module */
|
||||
#define SK_DBGMOD_PECP 0x00000100L /* PECP module */
|
||||
#define SK_DBGMOD_POWM 0x00000200L /* Power Management module */
|
||||
|
||||
/* Debug events */
|
||||
|
||||
#define SK_DBGCAT_INIT 0x00000001L /* module/driver initialization */
|
||||
#define SK_DBGCAT_CTRL 0x00000002L /* controlling devices */
|
||||
#define SK_DBGCAT_ERR 0x00000004L /* error handling paths */
|
||||
#define SK_DBGCAT_TX 0x00000008L /* transmit path */
|
||||
#define SK_DBGCAT_RX 0x00000010L /* receive path */
|
||||
#define SK_DBGCAT_IRQ 0x00000020L /* general IRQ handling */
|
||||
#define SK_DBGCAT_QUEUE 0x00000040L /* any queue management */
|
||||
#define SK_DBGCAT_DUMP 0x00000080L /* large data output e.g. hex dump */
|
||||
#define SK_DBGCAT_FATAL 0x00000100L /* fatal error */
|
||||
|
||||
#endif /* __INC_SKDEBUG_H */
|
||||
265
drivers/sk98lin/h/skdrv1st.h
Normal file
265
drivers/sk98lin/h/skdrv1st.h
Normal file
@@ -0,0 +1,265 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skdrv1st.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.11 $
|
||||
* Date: $Date: 2003/02/25 14:16:40 $
|
||||
* Purpose: First header file for driver and all other modules
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2003 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* $Log: skdrv1st.h,v $
|
||||
* Revision 1.11 2003/02/25 14:16:40 mlindner
|
||||
* Fix: Copyright statement
|
||||
*
|
||||
* Revision 1.10 2002/10/02 12:46:02 mlindner
|
||||
* Add: Support for Yukon
|
||||
*
|
||||
* Revision 1.9.2.2 2001/12/07 12:06:42 mlindner
|
||||
* Fix: malloc -> slab changes
|
||||
*
|
||||
* Revision 1.9.2.1 2001/03/12 16:50:59 mlindner
|
||||
* chg: kernel 2.4 adaption
|
||||
*
|
||||
* Revision 1.9 2001/01/22 14:16:04 mlindner
|
||||
* added ProcFs functionality
|
||||
* Dual Net functionality integrated
|
||||
* Rlmt networks added
|
||||
*
|
||||
* Revision 1.8 2000/02/21 12:19:18 cgoos
|
||||
* Added default for SK_DEBUG_CHKMOD/_CHKCAT
|
||||
*
|
||||
* Revision 1.7 1999/11/22 13:50:00 cgoos
|
||||
* Changed license header to GPL.
|
||||
* Added overwrite for several functions.
|
||||
* Removed linux 2.0.x definitions.
|
||||
* Removed PCI vendor ID definition (now in kernel).
|
||||
*
|
||||
* Revision 1.6 1999/07/27 08:03:33 cgoos
|
||||
* Changed SK_IN/OUT macros to readX/writeX instead of memory
|
||||
* accesses (necessary for ALPHA).
|
||||
*
|
||||
* Revision 1.5 1999/07/23 12:10:21 cgoos
|
||||
* Removed SK_RLMT_SLOW_LOOKAHEAD define.
|
||||
*
|
||||
* Revision 1.4 1999/07/14 12:31:13 cgoos
|
||||
* Added SK_RLMT_SLOW_LOOKAHEAD define.
|
||||
*
|
||||
* Revision 1.3 1999/04/07 10:12:54 cgoos
|
||||
* Added check for KERNEL and OPTIMIZATION defines.
|
||||
*
|
||||
* Revision 1.2 1999/03/01 08:51:47 cgoos
|
||||
* Fixed pcibios_read/write definitions.
|
||||
*
|
||||
* Revision 1.1 1999/02/16 07:40:49 cgoos
|
||||
* First version.
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* This is the first include file of the driver, which includes all
|
||||
* neccessary system header files and some of the GEnesis header files.
|
||||
* It also defines some basic items.
|
||||
*
|
||||
* Include File Hierarchy:
|
||||
*
|
||||
* see skge.c
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INC_SKDRV1ST_H
|
||||
#define __INC_SKDRV1ST_H
|
||||
|
||||
#if 0
|
||||
/* Check kernel version */
|
||||
#include <linux/version.h>
|
||||
#if (LINUX_VERSION_CODE > 0x020300)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct s_AC SK_AC;
|
||||
|
||||
/* override some default functions with optimized linux functions */
|
||||
|
||||
#define SK_PNMI_STORE_U16(p,v) memcpy((char*)(p),(char*)&(v),2)
|
||||
#define SK_PNMI_STORE_U32(p,v) memcpy((char*)(p),(char*)&(v),4)
|
||||
#define SK_PNMI_STORE_U64(p,v) memcpy((char*)(p),(char*)&(v),8)
|
||||
#define SK_PNMI_READ_U16(p,v) memcpy((char*)&(v),(char*)(p),2)
|
||||
#define SK_PNMI_READ_U32(p,v) memcpy((char*)&(v),(char*)(p),2)
|
||||
#define SK_PNMI_READ_U64(p,v) memcpy((char*)&(v),(char*)(p),2)
|
||||
|
||||
#define SkCsCalculateChecksum(p,l) ((~ip_compute_csum(p, l)) & 0xffff)
|
||||
|
||||
#define SK_ADDR_EQUAL(a1,a2) (!memcmp(a1,a2,6))
|
||||
|
||||
|
||||
#if !defined(__OPTIMIZE__) || !defined(__KERNEL__)
|
||||
#warning You must compile this file with the correct options!
|
||||
#warning See the last lines of the source file.
|
||||
#error You must compile this driver with "-O".
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#include <linux/version.h>
|
||||
#endif
|
||||
#include <linux/types.h>
|
||||
#if 0
|
||||
#include <linux/kernel.h>
|
||||
#endif
|
||||
#include <linux/string.h>
|
||||
#if 0
|
||||
#include <linux/errno.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/pci.h>
|
||||
#endif
|
||||
#include <asm/byteorder.h>
|
||||
#include <asm/bitops.h>
|
||||
#include <asm/io.h>
|
||||
#if 0
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/skbuff.h>
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <net/checksum.h>
|
||||
#endif
|
||||
|
||||
#include "h/sktypes.h"
|
||||
#include "h/skerror.h"
|
||||
#include "h/skdebug.h"
|
||||
#include "h/lm80.h"
|
||||
#include "h/xmac_ii.h"
|
||||
|
||||
#include "u-boot_compat.h"
|
||||
|
||||
#ifdef __LITTLE_ENDIAN
|
||||
#define SK_LITTLE_ENDIAN
|
||||
#else
|
||||
#define SK_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define SK_NET_DEVICE net_device
|
||||
#else
|
||||
#define SK_NET_DEVICE eth_device
|
||||
#endif
|
||||
|
||||
|
||||
/* we use gethrtime(), return unit: nanoseconds */
|
||||
#if 0
|
||||
#define SK_TICKS_PER_SEC HZ
|
||||
#else
|
||||
#define SK_TICKS_PER_SEC CFG_HZ
|
||||
#endif
|
||||
|
||||
#define SK_MEM_MAPPED_IO
|
||||
|
||||
// #define SK_RLMT_SLOW_LOOKAHEAD
|
||||
|
||||
#define SK_MAX_MACS 2
|
||||
#define SK_MAX_NETS 2
|
||||
|
||||
#define SK_IOC char*
|
||||
|
||||
typedef struct s_DrvRlmtMbuf SK_MBUF;
|
||||
|
||||
#define SK_CONST64 INT64_C
|
||||
#define SK_CONSTU64 UINT64_C
|
||||
|
||||
#define SK_MEMCPY(dest,src,size) memcpy(dest,src,size)
|
||||
#define SK_MEMCMP(s1,s2,size) memcmp(s1,s2,size)
|
||||
#define SK_MEMSET(dest,val,size) memset(dest,val,size)
|
||||
#define SK_STRLEN(pStr) strlen((char*)(pStr))
|
||||
#define SK_STRNCPY(pDest,pSrc,size) strncpy((char*)(pDest),(char*)(pSrc),size)
|
||||
#define SK_STRCMP(pStr1,pStr2) strcmp((char*)(pStr1),(char*)(pStr2))
|
||||
|
||||
/* macros to access the adapter */
|
||||
#define SK_OUT8(b,a,v) writeb((v), ((b)+(a)))
|
||||
#define SK_OUT16(b,a,v) writew((v), ((b)+(a)))
|
||||
#define SK_OUT32(b,a,v) writel((v), ((b)+(a)))
|
||||
#define SK_IN8(b,a,pv) (*(pv) = readb((b)+(a)))
|
||||
#define SK_IN16(b,a,pv) (*(pv) = readw((b)+(a)))
|
||||
#define SK_IN32(b,a,pv) (*(pv) = readl((b)+(a)))
|
||||
|
||||
#define int8_t char
|
||||
#define int16_t short
|
||||
#define int32_t long
|
||||
#define int64_t long long
|
||||
#define uint8_t u_char
|
||||
#define uint16_t u_short
|
||||
#define uint32_t u_long
|
||||
#define uint64_t unsigned long long
|
||||
#define t_scalar_t int
|
||||
#define t_uscalar_t unsigned int
|
||||
#define uintptr_t unsigned long
|
||||
|
||||
#define __CONCAT__(A,B) A##B
|
||||
|
||||
#define INT32_C(a) __CONCAT__(a,L)
|
||||
#define INT64_C(a) __CONCAT__(a,LL)
|
||||
#define UINT32_C(a) __CONCAT__(a,UL)
|
||||
#define UINT64_C(a) __CONCAT__(a,ULL)
|
||||
|
||||
#ifdef DEBUG
|
||||
#define SK_DBG_PRINTF printk
|
||||
#ifndef SK_DEBUG_CHKMOD
|
||||
#define SK_DEBUG_CHKMOD 0
|
||||
#endif
|
||||
#ifndef SK_DEBUG_CHKCAT
|
||||
#define SK_DEBUG_CHKCAT 0
|
||||
#endif
|
||||
/* those come from the makefile */
|
||||
#define SK_DBG_CHKMOD(pAC) (SK_DEBUG_CHKMOD)
|
||||
#define SK_DBG_CHKCAT(pAC) (SK_DEBUG_CHKCAT)
|
||||
|
||||
extern void SkDbgPrintf(const char *format,...);
|
||||
|
||||
#define SK_DBGMOD_DRV 0x00010000
|
||||
|
||||
/**** possible driver debug categories ********************************/
|
||||
#define SK_DBGCAT_DRV_ENTRY 0x00010000
|
||||
#define SK_DBGCAT_DRV_SAP 0x00020000
|
||||
#define SK_DBGCAT_DRV_MCA 0x00040000
|
||||
#define SK_DBGCAT_DRV_TX_PROGRESS 0x00080000
|
||||
#define SK_DBGCAT_DRV_RX_PROGRESS 0x00100000
|
||||
#define SK_DBGCAT_DRV_PROGRESS 0x00200000
|
||||
#define SK_DBGCAT_DRV_MSG 0x00400000
|
||||
#define SK_DBGCAT_DRV_PROM 0x00800000
|
||||
#define SK_DBGCAT_DRV_TX_FRAME 0x01000000
|
||||
#define SK_DBGCAT_DRV_ERROR 0x02000000
|
||||
#define SK_DBGCAT_DRV_INT_SRC 0x04000000
|
||||
#define SK_DBGCAT_DRV_EVENT 0x08000000
|
||||
|
||||
#endif
|
||||
|
||||
#define SK_ERR_LOG SkErrorLog
|
||||
|
||||
extern void SkErrorLog(SK_AC*, int, int, char*);
|
||||
|
||||
#endif
|
||||
|
||||
565
drivers/sk98lin/h/skdrv2nd.h
Normal file
565
drivers/sk98lin/h/skdrv2nd.h
Normal file
@@ -0,0 +1,565 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skdrv2nd.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.15 $
|
||||
* Date: $Date: 2003/02/25 14:16:40 $
|
||||
* Purpose: Second header file for driver and all other modules
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2003 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* $Log: skdrv2nd.h,v $
|
||||
* Revision 1.15 2003/02/25 14:16:40 mlindner
|
||||
* Fix: Copyright statement
|
||||
*
|
||||
* Revision 1.14 2003/02/25 13:26:26 mlindner
|
||||
* Add: Support for various vendors
|
||||
*
|
||||
* Revision 1.13 2002/10/02 12:46:02 mlindner
|
||||
* Add: Support for Yukon
|
||||
*
|
||||
* Revision 1.12.2.2 2001/09/05 12:14:50 mlindner
|
||||
* add: New hardware revision int
|
||||
*
|
||||
* Revision 1.12.2.1 2001/03/12 16:50:59 mlindner
|
||||
* chg: kernel 2.4 adaption
|
||||
*
|
||||
* Revision 1.12 2001/03/01 12:52:15 mlindner
|
||||
* Fixed ring size
|
||||
*
|
||||
* Revision 1.11 2001/02/19 13:28:02 mlindner
|
||||
* Changed PNMI parameter values
|
||||
*
|
||||
* Revision 1.10 2001/01/22 14:16:04 mlindner
|
||||
* added ProcFs functionality
|
||||
* Dual Net functionality integrated
|
||||
* Rlmt networks added
|
||||
*
|
||||
* Revision 1.1 2000/10/05 19:46:50 phargrov
|
||||
* Add directory src/vipk_devs_nonlbl/vipk_sk98lin/
|
||||
* This is the SysKonnect SK-98xx Gigabit Ethernet driver,
|
||||
* contributed by SysKonnect.
|
||||
*
|
||||
* Revision 1.9 2000/02/21 10:39:55 cgoos
|
||||
* Added flag for jumbo support usage.
|
||||
*
|
||||
* Revision 1.8 1999/11/22 13:50:44 cgoos
|
||||
* Changed license header to GPL.
|
||||
* Fixed two comments.
|
||||
*
|
||||
* Revision 1.7 1999/09/28 12:38:21 cgoos
|
||||
* Added CheckQueue to SK_AC.
|
||||
*
|
||||
* Revision 1.6 1999/07/27 08:04:05 cgoos
|
||||
* Added checksumming variables to SK_AC.
|
||||
*
|
||||
* Revision 1.5 1999/03/29 12:33:26 cgoos
|
||||
* Rreversed to fine lock granularity.
|
||||
*
|
||||
* Revision 1.4 1999/03/15 12:14:02 cgoos
|
||||
* Added DriverLock to SK_AC.
|
||||
* Removed other locks.
|
||||
*
|
||||
* Revision 1.3 1999/03/01 08:52:27 cgoos
|
||||
* Changed pAC->PciDev declaration.
|
||||
*
|
||||
* Revision 1.2 1999/02/18 10:57:14 cgoos
|
||||
* Removed SkDrvTimeStamp prototype.
|
||||
* Fixed SkGeOsGetTime prototype.
|
||||
*
|
||||
* Revision 1.1 1999/02/16 07:41:01 cgoos
|
||||
* First version.
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
* This is the second include file of the driver, which includes all other
|
||||
* neccessary files and defines all structures and constants used by the
|
||||
* driver and the common modules.
|
||||
*
|
||||
* Include File Hierarchy:
|
||||
*
|
||||
* see skge.c
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INC_SKDRV2ND_H
|
||||
#define __INC_SKDRV2ND_H
|
||||
|
||||
#include "h/skqueue.h"
|
||||
#include "h/skgehwt.h"
|
||||
#include "h/sktimer.h"
|
||||
#include "h/ski2c.h"
|
||||
#include "h/skgepnmi.h"
|
||||
#include "h/skvpd.h"
|
||||
#include "h/skgehw.h"
|
||||
#include "h/skgeinit.h"
|
||||
#include "h/skaddr.h"
|
||||
#include "h/skgesirq.h"
|
||||
#include "h/skcsum.h"
|
||||
#include "h/skrlmt.h"
|
||||
#include "h/skgedrv.h"
|
||||
|
||||
#define SK_PCI_ISCOMPLIANT(result, pdev) { \
|
||||
result = SK_FALSE; /* default */ \
|
||||
/* 3Com (0x10b7) */ \
|
||||
if (pdev->vendor == 0x10b7) { \
|
||||
/* Gigabit Ethernet Adapter (0x1700) */ \
|
||||
if ((pdev->device == 0x1700)) { \
|
||||
result = SK_TRUE; \
|
||||
} \
|
||||
/* SysKonnect (0x1148) */ \
|
||||
} else if (pdev->vendor == 0x1148) { \
|
||||
/* SK-98xx Gigabit Ethernet Server Adapter (0x4300) */ \
|
||||
/* SK-98xx V2 Gigabit Ethernet Adapter (0x4320) */ \
|
||||
if ((pdev->device == 0x4300) || \
|
||||
(pdev->device == 0x4320)) { \
|
||||
result = SK_TRUE; \
|
||||
} \
|
||||
/* D-Link (0x1186) */ \
|
||||
} else if (pdev->vendor == 0x1186) { \
|
||||
/* Gigabit Ethernet Adapter (0x4c00) */ \
|
||||
if ((pdev->device == 0x4c00)) { \
|
||||
result = SK_TRUE; \
|
||||
} \
|
||||
/* CNet (0x1371) */ \
|
||||
} else if (pdev->vendor == 0x1371) { \
|
||||
/* GigaCard Network Adapter (0x434e) */ \
|
||||
if ((pdev->device == 0x434e)) { \
|
||||
result = SK_TRUE; \
|
||||
} \
|
||||
/* Linksys (0x1737) */ \
|
||||
} else if (pdev->vendor == 0x1737) { \
|
||||
/* Gigabit Network Adapter (0x1032) */ \
|
||||
/* Gigabit Network Adapter (0x1064) */ \
|
||||
if ((pdev->device == 0x1032) || \
|
||||
(pdev->device == 0x1064)) { \
|
||||
result = SK_TRUE; \
|
||||
} \
|
||||
} else { \
|
||||
result = SK_FALSE; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
extern SK_MBUF *SkDrvAllocRlmtMbuf(SK_AC*, SK_IOC, unsigned);
|
||||
extern void SkDrvFreeRlmtMbuf(SK_AC*, SK_IOC, SK_MBUF*);
|
||||
extern SK_U64 SkOsGetTime(SK_AC*);
|
||||
extern int SkPciReadCfgDWord(SK_AC*, int, SK_U32*);
|
||||
extern int SkPciReadCfgWord(SK_AC*, int, SK_U16*);
|
||||
extern int SkPciReadCfgByte(SK_AC*, int, SK_U8*);
|
||||
extern int SkPciWriteCfgDWord(SK_AC*, int, SK_U32);
|
||||
extern int SkPciWriteCfgWord(SK_AC*, int, SK_U16);
|
||||
extern int SkPciWriteCfgByte(SK_AC*, int, SK_U8);
|
||||
extern int SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA);
|
||||
|
||||
struct s_DrvRlmtMbuf {
|
||||
SK_MBUF *pNext; /* Pointer to next RLMT Mbuf. */
|
||||
SK_U8 *pData; /* Data buffer (virtually contig.). */
|
||||
unsigned Size; /* Data buffer size. */
|
||||
unsigned Length; /* Length of packet (<= Size). */
|
||||
SK_U32 PortIdx; /* Receiving/transmitting port. */
|
||||
#ifdef SK_RLMT_MBUF_PRIVATE
|
||||
SK_RLMT_MBUF Rlmt; /* Private part for RLMT. */
|
||||
#endif /* SK_RLMT_MBUF_PRIVATE */
|
||||
struct sk_buff *pOs; /* Pointer to message block */
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* ioctl definitions
|
||||
*/
|
||||
#define SK_IOCTL_BASE (SIOCDEVPRIVATE)
|
||||
#define SK_IOCTL_GETMIB (SK_IOCTL_BASE + 0)
|
||||
#define SK_IOCTL_SETMIB (SK_IOCTL_BASE + 1)
|
||||
#define SK_IOCTL_PRESETMIB (SK_IOCTL_BASE + 2)
|
||||
|
||||
typedef struct s_IOCTL SK_GE_IOCTL;
|
||||
|
||||
struct s_IOCTL {
|
||||
char* pData;
|
||||
unsigned int Len;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* define sizes of descriptor rings in bytes
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#define TX_RING_SIZE (8*1024)
|
||||
#define RX_RING_SIZE (24*1024)
|
||||
#else
|
||||
#define TX_RING_SIZE (10 * 40)
|
||||
#define RX_RING_SIZE (10 * 40)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Buffer size for ethernet packets
|
||||
*/
|
||||
#define ETH_BUF_SIZE 1540
|
||||
#define ETH_MAX_MTU 1514
|
||||
#define ETH_MIN_MTU 60
|
||||
#define ETH_MULTICAST_BIT 0x01
|
||||
#define SK_JUMBO_MTU 9000
|
||||
|
||||
/*
|
||||
* transmit priority selects the queue: LOW=asynchron, HIGH=synchron
|
||||
*/
|
||||
#define TX_PRIO_LOW 0
|
||||
#define TX_PRIO_HIGH 1
|
||||
|
||||
/*
|
||||
* alignment of rx/tx descriptors
|
||||
*/
|
||||
#define DESCR_ALIGN 8
|
||||
|
||||
/*
|
||||
* definitions for pnmi. TODO
|
||||
*/
|
||||
#define SK_DRIVER_RESET(pAC, IoC) 0
|
||||
#define SK_DRIVER_SENDEVENT(pAC, IoC) 0
|
||||
#define SK_DRIVER_SELFTEST(pAC, IoC) 0
|
||||
/* For get mtu you must add an own function */
|
||||
#define SK_DRIVER_GET_MTU(pAc,IoC,i) 0
|
||||
#define SK_DRIVER_SET_MTU(pAc,IoC,i,v) 0
|
||||
#define SK_DRIVER_PRESET_MTU(pAc,IoC,i,v) 0
|
||||
|
||||
|
||||
/* TX and RX descriptors *****************************************************/
|
||||
|
||||
typedef struct s_RxD RXD; /* the receive descriptor */
|
||||
|
||||
struct s_RxD {
|
||||
volatile SK_U32 RBControl; /* Receive Buffer Control */
|
||||
SK_U32 VNextRxd; /* Next receive descriptor,low dword */
|
||||
SK_U32 VDataLow; /* Receive buffer Addr, low dword */
|
||||
SK_U32 VDataHigh; /* Receive buffer Addr, high dword */
|
||||
SK_U32 FrameStat; /* Receive Frame Status word */
|
||||
SK_U32 TimeStamp; /* Time stamp from XMAC */
|
||||
SK_U32 TcpSums; /* TCP Sum 2 / TCP Sum 1 */
|
||||
SK_U32 TcpSumStarts; /* TCP Sum Start 2 / TCP Sum Start 1 */
|
||||
RXD *pNextRxd; /* Pointer to next Rxd */
|
||||
struct sk_buff *pMBuf; /* Pointer to Linux' socket buffer */
|
||||
};
|
||||
|
||||
typedef struct s_TxD TXD; /* the transmit descriptor */
|
||||
|
||||
struct s_TxD {
|
||||
volatile SK_U32 TBControl; /* Transmit Buffer Control */
|
||||
SK_U32 VNextTxd; /* Next transmit descriptor,low dword */
|
||||
SK_U32 VDataLow; /* Transmit Buffer Addr, low dword */
|
||||
SK_U32 VDataHigh; /* Transmit Buffer Addr, high dword */
|
||||
SK_U32 FrameStat; /* Transmit Frame Status Word */
|
||||
SK_U32 TcpSumOfs; /* Reserved / TCP Sum Offset */
|
||||
SK_U16 TcpSumSt; /* TCP Sum Start */
|
||||
SK_U16 TcpSumWr; /* TCP Sum Write */
|
||||
SK_U32 TcpReserved; /* not used */
|
||||
TXD *pNextTxd; /* Pointer to next Txd */
|
||||
struct sk_buff *pMBuf; /* Pointer to Linux' socket buffer */
|
||||
};
|
||||
|
||||
|
||||
/* definition of flags in descriptor control field */
|
||||
#define RX_CTRL_OWN_BMU UINT32_C(0x80000000)
|
||||
#define RX_CTRL_STF UINT32_C(0x40000000)
|
||||
#define RX_CTRL_EOF UINT32_C(0x20000000)
|
||||
#define RX_CTRL_EOB_IRQ UINT32_C(0x10000000)
|
||||
#define RX_CTRL_EOF_IRQ UINT32_C(0x08000000)
|
||||
#define RX_CTRL_DEV_NULL UINT32_C(0x04000000)
|
||||
#define RX_CTRL_STAT_VALID UINT32_C(0x02000000)
|
||||
#define RX_CTRL_TIME_VALID UINT32_C(0x01000000)
|
||||
#define RX_CTRL_CHECK_DEFAULT UINT32_C(0x00550000)
|
||||
#define RX_CTRL_CHECK_CSUM UINT32_C(0x00560000)
|
||||
#define RX_CTRL_LEN_MASK UINT32_C(0x0000FFFF)
|
||||
|
||||
#define TX_CTRL_OWN_BMU UINT32_C(0x80000000)
|
||||
#define TX_CTRL_STF UINT32_C(0x40000000)
|
||||
#define TX_CTRL_EOF UINT32_C(0x20000000)
|
||||
#define TX_CTRL_EOB_IRQ UINT32_C(0x10000000)
|
||||
#define TX_CTRL_EOF_IRQ UINT32_C(0x08000000)
|
||||
#define TX_CTRL_ST_FWD UINT32_C(0x04000000)
|
||||
#define TX_CTRL_DISAB_CRC UINT32_C(0x02000000)
|
||||
#define TX_CTRL_SOFTWARE UINT32_C(0x01000000)
|
||||
#define TX_CTRL_CHECK_DEFAULT UINT32_C(0x00550000)
|
||||
#define TX_CTRL_CHECK_CSUM UINT32_C(0x00560000)
|
||||
#define TX_CTRL_LEN_MASK UINT32_C(0x0000FFFF)
|
||||
|
||||
|
||||
|
||||
/* The offsets of registers in the TX and RX queue control io area ***********/
|
||||
|
||||
#define RX_Q_BUF_CTRL_CNT 0x00
|
||||
#define RX_Q_NEXT_DESCR_LOW 0x04
|
||||
#define RX_Q_BUF_ADDR_LOW 0x08
|
||||
#define RX_Q_BUF_ADDR_HIGH 0x0c
|
||||
#define RX_Q_FRAME_STAT 0x10
|
||||
#define RX_Q_TIME_STAMP 0x14
|
||||
#define RX_Q_CSUM_1_2 0x18
|
||||
#define RX_Q_CSUM_START_1_2 0x1c
|
||||
#define RX_Q_CUR_DESCR_LOW 0x20
|
||||
#define RX_Q_DESCR_HIGH 0x24
|
||||
#define RX_Q_CUR_ADDR_LOW 0x28
|
||||
#define RX_Q_CUR_ADDR_HIGH 0x2c
|
||||
#define RX_Q_CUR_BYTE_CNT 0x30
|
||||
#define RX_Q_CTRL 0x34
|
||||
#define RX_Q_FLAG 0x38
|
||||
#define RX_Q_TEST1 0x3c
|
||||
#define RX_Q_TEST2 0x40
|
||||
#define RX_Q_TEST3 0x44
|
||||
|
||||
#define TX_Q_BUF_CTRL_CNT 0x00
|
||||
#define TX_Q_NEXT_DESCR_LOW 0x04
|
||||
#define TX_Q_BUF_ADDR_LOW 0x08
|
||||
#define TX_Q_BUF_ADDR_HIGH 0x0c
|
||||
#define TX_Q_FRAME_STAT 0x10
|
||||
#define TX_Q_CSUM_START 0x14
|
||||
#define TX_Q_CSUM_START_POS 0x18
|
||||
#define TX_Q_RESERVED 0x1c
|
||||
#define TX_Q_CUR_DESCR_LOW 0x20
|
||||
#define TX_Q_DESCR_HIGH 0x24
|
||||
#define TX_Q_CUR_ADDR_LOW 0x28
|
||||
#define TX_Q_CUR_ADDR_HIGH 0x2c
|
||||
#define TX_Q_CUR_BYTE_CNT 0x30
|
||||
#define TX_Q_CTRL 0x34
|
||||
#define TX_Q_FLAG 0x38
|
||||
#define TX_Q_TEST1 0x3c
|
||||
#define TX_Q_TEST2 0x40
|
||||
#define TX_Q_TEST3 0x44
|
||||
|
||||
/* definition of flags in the queue control field */
|
||||
#define RX_Q_CTRL_POLL_ON 0x00000080
|
||||
#define RX_Q_CTRL_POLL_OFF 0x00000040
|
||||
#define RX_Q_CTRL_STOP 0x00000020
|
||||
#define RX_Q_CTRL_START 0x00000010
|
||||
#define RX_Q_CTRL_CLR_I_PAR 0x00000008
|
||||
#define RX_Q_CTRL_CLR_I_EOB 0x00000004
|
||||
#define RX_Q_CTRL_CLR_I_EOF 0x00000002
|
||||
#define RX_Q_CTRL_CLR_I_ERR 0x00000001
|
||||
|
||||
#define TX_Q_CTRL_POLL_ON 0x00000080
|
||||
#define TX_Q_CTRL_POLL_OFF 0x00000040
|
||||
#define TX_Q_CTRL_STOP 0x00000020
|
||||
#define TX_Q_CTRL_START 0x00000010
|
||||
#define TX_Q_CTRL_CLR_I_EOB 0x00000004
|
||||
#define TX_Q_CTRL_CLR_I_EOF 0x00000002
|
||||
#define TX_Q_CTRL_CLR_I_ERR 0x00000001
|
||||
|
||||
|
||||
/* Interrupt bits in the interrupts source register **************************/
|
||||
#define IRQ_HW_ERROR 0x80000000
|
||||
#define IRQ_RESERVED 0x40000000
|
||||
#define IRQ_PKT_TOUT_RX1 0x20000000
|
||||
#define IRQ_PKT_TOUT_RX2 0x10000000
|
||||
#define IRQ_PKT_TOUT_TX1 0x08000000
|
||||
#define IRQ_PKT_TOUT_TX2 0x04000000
|
||||
#define IRQ_I2C_READY 0x02000000
|
||||
#define IRQ_SW 0x01000000
|
||||
#define IRQ_EXTERNAL_REG 0x00800000
|
||||
#define IRQ_TIMER 0x00400000
|
||||
#define IRQ_MAC1 0x00200000
|
||||
#define IRQ_LINK_SYNC_C_M1 0x00100000
|
||||
#define IRQ_MAC2 0x00080000
|
||||
#define IRQ_LINK_SYNC_C_M2 0x00040000
|
||||
#define IRQ_EOB_RX1 0x00020000
|
||||
#define IRQ_EOF_RX1 0x00010000
|
||||
#define IRQ_CHK_RX1 0x00008000
|
||||
#define IRQ_EOB_RX2 0x00004000
|
||||
#define IRQ_EOF_RX2 0x00002000
|
||||
#define IRQ_CHK_RX2 0x00001000
|
||||
#define IRQ_EOB_SY_TX1 0x00000800
|
||||
#define IRQ_EOF_SY_TX1 0x00000400
|
||||
#define IRQ_CHK_SY_TX1 0x00000200
|
||||
#define IRQ_EOB_AS_TX1 0x00000100
|
||||
#define IRQ_EOF_AS_TX1 0x00000080
|
||||
#define IRQ_CHK_AS_TX1 0x00000040
|
||||
#define IRQ_EOB_SY_TX2 0x00000020
|
||||
#define IRQ_EOF_SY_TX2 0x00000010
|
||||
#define IRQ_CHK_SY_TX2 0x00000008
|
||||
#define IRQ_EOB_AS_TX2 0x00000004
|
||||
#define IRQ_EOF_AS_TX2 0x00000002
|
||||
#define IRQ_CHK_AS_TX2 0x00000001
|
||||
|
||||
#define DRIVER_IRQS (IRQ_SW | IRQ_EOF_RX1 | IRQ_EOF_RX2 | \
|
||||
IRQ_EOF_SY_TX1 | IRQ_EOF_AS_TX1 | \
|
||||
IRQ_EOF_SY_TX2 | IRQ_EOF_AS_TX2)
|
||||
|
||||
#define SPECIAL_IRQS (IRQ_HW_ERROR | IRQ_PKT_TOUT_RX1 | IRQ_PKT_TOUT_RX2 | \
|
||||
IRQ_PKT_TOUT_TX1 | IRQ_PKT_TOUT_TX2 | \
|
||||
IRQ_I2C_READY | IRQ_EXTERNAL_REG | IRQ_TIMER | \
|
||||
IRQ_MAC1 | IRQ_LINK_SYNC_C_M1 | \
|
||||
IRQ_MAC2 | IRQ_LINK_SYNC_C_M2 | \
|
||||
IRQ_CHK_RX1 | IRQ_CHK_RX2 | \
|
||||
IRQ_CHK_SY_TX1 | IRQ_CHK_AS_TX1 | \
|
||||
IRQ_CHK_SY_TX2 | IRQ_CHK_AS_TX2)
|
||||
|
||||
#define IRQ_MASK (IRQ_SW | IRQ_EOB_RX1 | IRQ_EOF_RX1 | \
|
||||
IRQ_EOB_RX2 | IRQ_EOF_RX2 | \
|
||||
IRQ_EOB_SY_TX1 | IRQ_EOF_SY_TX1 | \
|
||||
IRQ_EOB_AS_TX1 | IRQ_EOF_AS_TX1 | \
|
||||
IRQ_EOB_SY_TX2 | IRQ_EOF_SY_TX2 | \
|
||||
IRQ_EOB_AS_TX2 | IRQ_EOF_AS_TX2 | \
|
||||
IRQ_HW_ERROR | IRQ_PKT_TOUT_RX1 | IRQ_PKT_TOUT_RX2 | \
|
||||
IRQ_PKT_TOUT_TX1 | IRQ_PKT_TOUT_TX2 | \
|
||||
IRQ_I2C_READY | IRQ_EXTERNAL_REG | IRQ_TIMER | \
|
||||
IRQ_MAC1 | \
|
||||
IRQ_MAC2 | \
|
||||
IRQ_CHK_RX1 | IRQ_CHK_RX2 | \
|
||||
IRQ_CHK_SY_TX1 | IRQ_CHK_AS_TX1 | \
|
||||
IRQ_CHK_SY_TX2 | IRQ_CHK_AS_TX2)
|
||||
|
||||
#define IRQ_HWE_MASK 0x00000FFF /* enable all HW irqs */
|
||||
|
||||
typedef struct s_DevNet DEV_NET;
|
||||
|
||||
struct s_DevNet {
|
||||
int PortNr;
|
||||
int NetNr;
|
||||
int Mtu;
|
||||
int Up;
|
||||
SK_AC *pAC;
|
||||
};
|
||||
|
||||
typedef struct s_TxPort TX_PORT;
|
||||
|
||||
struct s_TxPort {
|
||||
/* the transmit descriptor rings */
|
||||
caddr_t pTxDescrRing; /* descriptor area memory */
|
||||
SK_U64 VTxDescrRing; /* descr. area bus virt. addr. */
|
||||
TXD *pTxdRingHead; /* Head of Tx rings */
|
||||
TXD *pTxdRingTail; /* Tail of Tx rings */
|
||||
TXD *pTxdRingPrev; /* descriptor sent previously */
|
||||
int TxdRingFree; /* # of free entrys */
|
||||
#if 0
|
||||
spinlock_t TxDesRingLock; /* serialize descriptor accesses */
|
||||
#endif
|
||||
caddr_t HwAddr; /* bmu registers address */
|
||||
int PortIndex; /* index number of port (0 or 1) */
|
||||
};
|
||||
|
||||
typedef struct s_RxPort RX_PORT;
|
||||
|
||||
struct s_RxPort {
|
||||
/* the receive descriptor rings */
|
||||
caddr_t pRxDescrRing; /* descriptor area memory */
|
||||
SK_U64 VRxDescrRing; /* descr. area bus virt. addr. */
|
||||
RXD *pRxdRingHead; /* Head of Rx rings */
|
||||
RXD *pRxdRingTail; /* Tail of Rx rings */
|
||||
RXD *pRxdRingPrev; /* descriptor given to BMU previously */
|
||||
int RxdRingFree; /* # of free entrys */
|
||||
#if 0
|
||||
spinlock_t RxDesRingLock; /* serialize descriptor accesses */
|
||||
#endif
|
||||
int RxFillLimit; /* limit for buffers in ring */
|
||||
caddr_t HwAddr; /* bmu registers address */
|
||||
int PortIndex; /* index number of port (0 or 1) */
|
||||
};
|
||||
|
||||
typedef struct s_PerStrm PER_STRM;
|
||||
|
||||
#define SK_ALLOC_IRQ 0x00000001
|
||||
|
||||
/****************************************************************************
|
||||
* Per board structure / Adapter Context structure:
|
||||
* Allocated within attach(9e) and freed within detach(9e).
|
||||
* Contains all 'per device' necessary handles, flags, locks etc.:
|
||||
*/
|
||||
struct s_AC {
|
||||
SK_GEINIT GIni; /* GE init struct */
|
||||
SK_PNMI Pnmi; /* PNMI data struct */
|
||||
SK_VPD vpd; /* vpd data struct */
|
||||
SK_QUEUE Event; /* Event queue */
|
||||
SK_HWT Hwt; /* Hardware Timer control struct */
|
||||
SK_TIMCTRL Tim; /* Software Timer control struct */
|
||||
SK_I2C I2c; /* I2C relevant data structure */
|
||||
SK_ADDR Addr; /* for Address module */
|
||||
SK_CSUM Csum; /* for checksum module */
|
||||
SK_RLMT Rlmt; /* for rlmt module */
|
||||
#if 0
|
||||
spinlock_t SlowPathLock; /* Normal IRQ lock */
|
||||
#endif
|
||||
SK_PNMI_STRUCT_DATA PnmiStruct; /* structure to get all Pnmi-Data */
|
||||
int RlmtMode; /* link check mode to set */
|
||||
int RlmtNets; /* Number of nets */
|
||||
|
||||
SK_IOC IoBase; /* register set of adapter */
|
||||
int BoardLevel; /* level of active hw init (0-2) */
|
||||
char DeviceStr[80]; /* adapter string from vpd */
|
||||
SK_U32 AllocFlag; /* flag allocation of resources */
|
||||
#if 0
|
||||
struct pci_dev *PciDev; /* for access to pci config space */
|
||||
SK_U32 PciDevId; /* pci device id */
|
||||
#else
|
||||
int PciDev;
|
||||
#endif
|
||||
struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */
|
||||
char Name[30]; /* driver name */
|
||||
struct SK_NET_DEVICE *Next; /* link all devices (for clearing) */
|
||||
int RxBufSize; /* length of receive buffers */
|
||||
#if 0
|
||||
struct net_device_stats stats; /* linux 'netstat -i' statistics */
|
||||
#endif
|
||||
int Index; /* internal board index number */
|
||||
|
||||
/* adapter RAM sizes for queues of active port */
|
||||
int RxQueueSize; /* memory used for receive queue */
|
||||
int TxSQueueSize; /* memory used for sync. tx queue */
|
||||
int TxAQueueSize; /* memory used for async. tx queue */
|
||||
|
||||
int PromiscCount; /* promiscuous mode counter */
|
||||
int AllMultiCount; /* allmulticast mode counter */
|
||||
int MulticCount; /* number of different MC */
|
||||
/* addresses for this board */
|
||||
/* (may be more than HW can)*/
|
||||
|
||||
int HWRevision; /* Hardware revision */
|
||||
int ActivePort; /* the active XMAC port */
|
||||
int MaxPorts; /* number of activated ports */
|
||||
int TxDescrPerRing; /* # of descriptors per tx ring */
|
||||
int RxDescrPerRing; /* # of descriptors per rx ring */
|
||||
|
||||
caddr_t pDescrMem; /* Pointer to the descriptor area */
|
||||
dma_addr_t pDescrMemDMA; /* PCI DMA address of area */
|
||||
|
||||
/* the port structures with descriptor rings */
|
||||
TX_PORT TxPort[SK_MAX_MACS][2];
|
||||
RX_PORT RxPort[SK_MAX_MACS];
|
||||
|
||||
unsigned int CsOfs1; /* for checksum calculation */
|
||||
unsigned int CsOfs2; /* for checksum calculation */
|
||||
SK_U32 CsOfs; /* for checksum calculation */
|
||||
|
||||
SK_BOOL CheckQueue; /* check event queue soon */
|
||||
|
||||
/* Only for tests */
|
||||
int PortUp;
|
||||
int PortDown;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* __INC_SKDRV2ND_H */
|
||||
|
||||
80
drivers/sk98lin/h/skerror.h
Normal file
80
drivers/sk98lin/h/skerror.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skerror.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.5 $
|
||||
* Date: $Date: 2002/04/25 11:05:10 $
|
||||
* Purpose: SK specific Error log support
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2002 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
* $Log: skerror.h,v $
|
||||
* Revision 1.5 2002/04/25 11:05:10 rschmidt
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.4 1999/11/22 13:51:59 cgoos
|
||||
* Changed license header to GPL.
|
||||
*
|
||||
* Revision 1.3 1999/09/14 14:04:42 rwahl
|
||||
* Added error base SK_ERRBASE_PECP.
|
||||
* Changed error base for driver.
|
||||
*
|
||||
* Revision 1.2 1998/08/11 11:15:41 gklug
|
||||
* chg: comments
|
||||
*
|
||||
* Revision 1.1 1998/08/11 11:09:38 gklug
|
||||
* add: error bases
|
||||
* add: error Classes
|
||||
* first version
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _INC_SKERROR_H_
|
||||
#define _INC_SKERROR_H_
|
||||
|
||||
/*
|
||||
* Define Error Classes
|
||||
*/
|
||||
#define SK_ERRCL_OTHER (0) /* Other error */
|
||||
#define SK_ERRCL_CONFIG (1L<<0) /* Configuration error */
|
||||
#define SK_ERRCL_INIT (1L<<1) /* Initialization error */
|
||||
#define SK_ERRCL_NORES (1L<<2) /* Out of Resources error */
|
||||
#define SK_ERRCL_SW (1L<<3) /* Internal Software error */
|
||||
#define SK_ERRCL_HW (1L<<4) /* Hardware Failure */
|
||||
#define SK_ERRCL_COMM (1L<<5) /* Communication error */
|
||||
|
||||
|
||||
/*
|
||||
* Define Error Code Bases
|
||||
*/
|
||||
#define SK_ERRBASE_RLMT 100 /* Base Error number for RLMT */
|
||||
#define SK_ERRBASE_HWINIT 200 /* Base Error number for HWInit */
|
||||
#define SK_ERRBASE_VPD 300 /* Base Error number for VPD */
|
||||
#define SK_ERRBASE_PNMI 400 /* Base Error number for PNMI */
|
||||
#define SK_ERRBASE_CSUM 500 /* Base Error number for Checksum */
|
||||
#define SK_ERRBASE_SIRQ 600 /* Base Error number for Special IRQ */
|
||||
#define SK_ERRBASE_I2C 700 /* Base Error number for I2C module */
|
||||
#define SK_ERRBASE_QUEUE 800 /* Base Error number for Scheduler */
|
||||
#define SK_ERRBASE_ADDR 900 /* Base Error number for Address module */
|
||||
#define SK_ERRBASE_PECP 1000 /* Base Error number for PECP */
|
||||
#define SK_ERRBASE_DRV 1100 /* Base Error number for Driver */
|
||||
|
||||
#endif /* _INC_SKERROR_H_ */
|
||||
72
drivers/sk98lin/h/skgedrv.h
Normal file
72
drivers/sk98lin/h/skgedrv.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skgedrv.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.6 $
|
||||
* Date: $Date: 2002/07/15 15:38:01 $
|
||||
* Purpose: Interface with the driver
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2002 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* $Log: skgedrv.h,v $
|
||||
* Revision 1.6 2002/07/15 15:38:01 rschmidt
|
||||
* Power Management support
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.5 2002/04/25 11:05:47 rschmidt
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.4 1999/11/22 13:52:46 cgoos
|
||||
* Changed license header to GPL.
|
||||
*
|
||||
* Revision 1.3 1998/12/01 13:31:39 cgoos
|
||||
* SWITCH INTERN Event added.
|
||||
*
|
||||
* Revision 1.2 1998/11/25 08:28:38 gklug
|
||||
* rmv: PORT SWITCH Event
|
||||
*
|
||||
* Revision 1.1 1998/09/29 06:14:07 gklug
|
||||
* add: driver events (initial version)
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INC_SKGEDRV_H_
|
||||
#define __INC_SKGEDRV_H_
|
||||
|
||||
/* defines ********************************************************************/
|
||||
|
||||
/*
|
||||
* Define the driver events.
|
||||
* Usually the events are defined by the destination module.
|
||||
* In case of the driver we put the definition of the events here.
|
||||
*/
|
||||
#define SK_DRV_PORT_RESET 1 /* The port needs to be reset */
|
||||
#define SK_DRV_NET_UP 2 /* The net is operational */
|
||||
#define SK_DRV_NET_DOWN 3 /* The net is down */
|
||||
#define SK_DRV_SWITCH_SOFT 4 /* Ports switch with both links connected */
|
||||
#define SK_DRV_SWITCH_HARD 5 /* Port switch due to link failure */
|
||||
#define SK_DRV_RLMT_SEND 6 /* Send a RLMT packet */
|
||||
#define SK_DRV_ADAP_FAIL 7 /* The whole adapter fails */
|
||||
#define SK_DRV_PORT_FAIL 8 /* One port fails */
|
||||
#define SK_DRV_SWITCH_INTERN 9 /* Port switch by the driver itself */
|
||||
#define SK_DRV_POWER_DOWN 10 /* Power down mode */
|
||||
|
||||
#endif /* __INC_SKGEDRV_H_ */
|
||||
2336
drivers/sk98lin/h/skgehw.h
Normal file
2336
drivers/sk98lin/h/skgehw.h
Normal file
File diff suppressed because it is too large
Load Diff
74
drivers/sk98lin/h/skgehwt.h
Normal file
74
drivers/sk98lin/h/skgehwt.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skhwt.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.5 $
|
||||
* Date: $Date: 1999/11/22 13:54:24 $
|
||||
* Purpose: Defines for the hardware timer functions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998,1999 SysKonnect,
|
||||
* a business unit of Schneider & Koch & Co. Datensysteme GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* $Log: skgehwt.h,v $
|
||||
* Revision 1.5 1999/11/22 13:54:24 cgoos
|
||||
* Changed license header to GPL.
|
||||
*
|
||||
* Revision 1.4 1998/08/19 09:50:58 gklug
|
||||
* fix: remove struct keyword from c-code (see CCC) add typedefs
|
||||
*
|
||||
* Revision 1.3 1998/08/14 07:09:29 gklug
|
||||
* fix: chg pAc -> pAC
|
||||
*
|
||||
* Revision 1.2 1998/08/07 12:54:21 gklug
|
||||
* fix: first compiled version
|
||||
*
|
||||
* Revision 1.1 1998/08/07 09:32:58 gklug
|
||||
* first version
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* SKGEHWT.H contains all defines and types for the timer functions
|
||||
*/
|
||||
|
||||
#ifndef _SKGEHWT_H_
|
||||
#define _SKGEHWT_H_
|
||||
|
||||
/*
|
||||
* SK Hardware Timer
|
||||
* - needed wherever the HWT module is used
|
||||
* - use in Adapters context name pAC->Hwt
|
||||
*/
|
||||
typedef struct s_Hwt {
|
||||
SK_U32 TStart ; /* HWT start */
|
||||
SK_U32 TStop ; /* HWT stop */
|
||||
int TActive ; /* HWT: flag : active/inactive */
|
||||
} SK_HWT;
|
||||
|
||||
extern void SkHwtInit(SK_AC *pAC, SK_IOC Ioc);
|
||||
extern void SkHwtStart(SK_AC *pAC, SK_IOC Ioc, SK_U32 Time);
|
||||
extern void SkHwtStop(SK_AC *pAC, SK_IOC Ioc);
|
||||
extern SK_U32 SkHwtRead(SK_AC *pAC,SK_IOC Ioc);
|
||||
extern void SkHwtIsr(SK_AC *pAC, SK_IOC Ioc);
|
||||
#endif /* _SKGEHWT_H_ */
|
||||
299
drivers/sk98lin/h/skgei2c.h
Normal file
299
drivers/sk98lin/h/skgei2c.h
Normal file
@@ -0,0 +1,299 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skgei2c.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.23 $
|
||||
* Date: $Date: 2002/12/19 14:34:27 $
|
||||
* Purpose: Special GEnesis defines for TWSI
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2002 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* $Log: skgei2c.h,v $
|
||||
* Revision 1.23 2002/12/19 14:34:27 rschmidt
|
||||
* Added cast in macros SK_I2C_SET_BIT() and SK_I2C_CLR_BIT()
|
||||
* Editorial changes (TWSI)
|
||||
*
|
||||
* Revision 1.22 2002/10/14 16:45:56 rschmidt
|
||||
* Editorial changes (TWSI)
|
||||
*
|
||||
* Revision 1.21 2002/08/13 08:42:24 rschmidt
|
||||
* Changed define for SK_MIN_SENSORS back to 5
|
||||
* Merged defines for PHY PLL 3V3 voltage (A and B)
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.20 2002/08/06 09:43:56 jschmalz
|
||||
* Extensions and changes for Yukon
|
||||
*
|
||||
* Revision 1.19 2002/08/02 12:00:08 rschmidt
|
||||
* Added defines for YUKON sensors
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.18 2001/08/16 12:44:33 afischer
|
||||
* LM80 sensor init values corrected
|
||||
*
|
||||
* Revision 1.17 1999/11/22 13:55:25 cgoos
|
||||
* Changed license header to GPL.
|
||||
*
|
||||
* Revision 1.16 1999/11/12 08:24:10 malthoff
|
||||
* Change voltage warning and error limits
|
||||
* (warning +-5%, error +-10%).
|
||||
*
|
||||
* Revision 1.15 1999/09/14 14:14:43 malthoff
|
||||
* The 1000BT Dual Link adapter has got only one Fan.
|
||||
* The second Fan has been removed.
|
||||
*
|
||||
* Revision 1.14 1999/05/27 13:40:50 malthoff
|
||||
* Fan Divisor = 1. Assuming fan with 6500 rpm.
|
||||
*
|
||||
* Revision 1.13 1999/05/20 14:56:55 malthoff
|
||||
* Bug Fix: Missing brace in SK_LM80_FAN_FAKTOR.
|
||||
*
|
||||
* Revision 1.12 1999/05/20 09:22:00 cgoos
|
||||
* Changes for 1000Base-T (Fan sensors).
|
||||
*
|
||||
* Revision 1.11 1998/10/14 05:57:22 cgoos
|
||||
* Fixed compilation warnings.
|
||||
*
|
||||
* Revision 1.10 1998/09/04 08:37:00 malthoff
|
||||
* bugfix: correct the SK_I2C_GET_CTL() macro.
|
||||
*
|
||||
* Revision 1.9 1998/08/25 06:10:03 gklug
|
||||
* add: thresholds for all sensors
|
||||
*
|
||||
* Revision 1.8 1998/08/20 11:37:42 gklug
|
||||
* chg: change Ioc to IoC
|
||||
*
|
||||
* Revision 1.7 1998/08/20 08:53:11 gklug
|
||||
* fix: compiler errors
|
||||
* add: Threshold values
|
||||
*
|
||||
* Revision 1.6 1998/08/17 11:37:09 malthoff
|
||||
* Bugfix in SK_I2C_CTL macro. The parameter 'dev'
|
||||
* has to be shifted 9 bits.
|
||||
*
|
||||
* Revision 1.5 1998/08/17 06:52:21 malthoff
|
||||
* Remove unrequired macros.
|
||||
* Add macros for accessing TWSI SW register.
|
||||
*
|
||||
* Revision 1.4 1998/08/13 08:30:18 gklug
|
||||
* add: conversion factors for read values
|
||||
* add: new state SEN_VALEXT to read extension value of temperature sensor
|
||||
*
|
||||
* Revision 1.3 1998/08/12 13:37:56 gklug
|
||||
* rmv: error numbers and messages
|
||||
*
|
||||
* Revision 1.2 1998/08/11 07:54:38 gklug
|
||||
* add: sensor states for GE sensors
|
||||
* add: Macro to access TWSI hardware register
|
||||
* chg: Error messages for TWSI errors
|
||||
*
|
||||
* Revision 1.1 1998/07/17 11:27:56 gklug
|
||||
* Created.
|
||||
*
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* SKGEI2C.H contains all SK-98xx specific defines for the TWSI handling
|
||||
*/
|
||||
|
||||
#ifndef _INC_SKGEI2C_H_
|
||||
#define _INC_SKGEI2C_H_
|
||||
|
||||
/*
|
||||
* Macros to access the B2_I2C_CTRL
|
||||
*/
|
||||
#define SK_I2C_CTL(IoC, flag, dev, reg, burst) \
|
||||
SK_OUT32(IoC, B2_I2C_CTRL,\
|
||||
(flag ? 0x80000000UL : 0x0L) | \
|
||||
(((SK_U32) reg << 16) & I2C_ADDR) | \
|
||||
(((SK_U32) dev << 9) & I2C_DEV_SEL) | \
|
||||
(( burst << 4) & I2C_BURST_LEN))
|
||||
|
||||
#define SK_I2C_STOP(IoC) { \
|
||||
SK_U32 I2cCtrl; \
|
||||
SK_IN32(IoC, B2_I2C_CTRL, &I2cCtrl); \
|
||||
SK_OUT32(IoC, B2_I2C_CTRL, I2cCtrl | I2C_STOP); \
|
||||
}
|
||||
|
||||
#define SK_I2C_GET_CTL(IoC, pI2cCtrl) SK_IN32(IoC, B2_I2C_CTRL, pI2cCtrl)
|
||||
|
||||
/*
|
||||
* Macros to access the TWSI SW Registers
|
||||
*/
|
||||
#define SK_I2C_SET_BIT(IoC, SetBits) { \
|
||||
SK_U8 OrgBits; \
|
||||
SK_IN8(IoC, B2_I2C_SW, &OrgBits); \
|
||||
SK_OUT8(IoC, B2_I2C_SW, OrgBits | (SK_U8)(SetBits)); \
|
||||
}
|
||||
|
||||
#define SK_I2C_CLR_BIT(IoC, ClrBits) { \
|
||||
SK_U8 OrgBits; \
|
||||
SK_IN8(IoC, B2_I2C_SW, &OrgBits); \
|
||||
SK_OUT8(IoC, B2_I2C_SW, OrgBits & ~((SK_U8)(ClrBits))); \
|
||||
}
|
||||
|
||||
#define SK_I2C_GET_SW(IoC, pI2cSw) SK_IN8(IoC, B2_I2C_SW, pI2cSw)
|
||||
|
||||
/*
|
||||
* define the possible sensor states
|
||||
*/
|
||||
#define SK_SEN_IDLE 0 /* Idle: sensor not read */
|
||||
#define SK_SEN_VALUE 1 /* Value Read cycle */
|
||||
#define SK_SEN_VALEXT 2 /* Extended Value Read cycle */
|
||||
|
||||
/*
|
||||
* Conversion factor to convert read Voltage sensor to milli Volt
|
||||
* Conversion factor to convert read Temperature sensor to 10th degree Celsius
|
||||
*/
|
||||
#define SK_LM80_VT_LSB 22 /* 22mV LSB resolution */
|
||||
#define SK_LM80_TEMP_LSB 10 /* 1 degree LSB resolution */
|
||||
#define SK_LM80_TEMPEXT_LSB 5 /* 0.5 degree LSB resolution for the
|
||||
* extension value
|
||||
*/
|
||||
#define SK_LM80_FAN_FAKTOR ((22500L*60)/(1*2))
|
||||
/* formula: counter = (22500*60)/(rpm * divisor * pulses/2)
|
||||
* assuming: 6500rpm, 4 pulses, divisor 1
|
||||
*/
|
||||
|
||||
/*
|
||||
* Define sensor management data
|
||||
* Maximum is reached on copperfield with dual Broadcom.
|
||||
* Board specific maximum is in pAC->I2c.MaxSens
|
||||
*/
|
||||
#define SK_MAX_SENSORS 8 /* maximal no. of installed sensors */
|
||||
#define SK_MIN_SENSORS 5 /* minimal no. of installed sensors */
|
||||
|
||||
/*
|
||||
* To watch the statemachine (JS) use the timer in two ways instead of one as hitherto
|
||||
*/
|
||||
#define SK_TIMER_WATCH_STATEMACHINE 0 /* Watch the statemachine to finish in a specific time */
|
||||
#define SK_TIMER_NEW_GAUGING 1 /* Start a new gauging when timer expires */
|
||||
|
||||
|
||||
/*
|
||||
* Defines for the individual Thresholds
|
||||
*/
|
||||
|
||||
/* Temperature sensor */
|
||||
#define SK_SEN_TEMP_HIGH_ERR 800 /* Temperature High Err Threshold */
|
||||
#define SK_SEN_TEMP_HIGH_WARN 700 /* Temperature High Warn Threshold */
|
||||
#define SK_SEN_TEMP_LOW_WARN 100 /* Temperature Low Warn Threshold */
|
||||
#define SK_SEN_TEMP_LOW_ERR 0 /* Temperature Low Err Threshold */
|
||||
|
||||
/* VCC which should be 5 V */
|
||||
#define SK_SEN_PCI_5V_HIGH_ERR 5588 /* Voltage PCI High Err Threshold */
|
||||
#define SK_SEN_PCI_5V_HIGH_WARN 5346 /* Voltage PCI High Warn Threshold */
|
||||
#define SK_SEN_PCI_5V_LOW_WARN 4664 /* Voltage PCI Low Warn Threshold */
|
||||
#define SK_SEN_PCI_5V_LOW_ERR 4422 /* Voltage PCI Low Err Threshold */
|
||||
|
||||
/*
|
||||
* VIO may be 5 V or 3.3 V. Initialization takes two parts:
|
||||
* 1. Initialize lowest lower limit and highest higher limit.
|
||||
* 2. After the first value is read correct the upper or the lower limit to
|
||||
* the appropriate C constant.
|
||||
*
|
||||
* Warning limits are +-5% of the exepected voltage.
|
||||
* Error limits are +-10% of the expected voltage.
|
||||
*/
|
||||
|
||||
/* Bug fix AF: 16.Aug.2001: Correct the init base of LM80 sensor */
|
||||
|
||||
#define SK_SEN_PCI_IO_5V_HIGH_ERR 5566 /* + 10% V PCI-IO High Err Threshold */
|
||||
#define SK_SEN_PCI_IO_5V_HIGH_WARN 5324 /* + 5% V PCI-IO High Warn Threshold */
|
||||
/* 5000 mVolt */
|
||||
#define SK_SEN_PCI_IO_5V_LOW_WARN 4686 /* - 5% V PCI-IO Low Warn Threshold */
|
||||
#define SK_SEN_PCI_IO_5V_LOW_ERR 4444 /* - 10% V PCI-IO Low Err Threshold */
|
||||
|
||||
#define SK_SEN_PCI_IO_RANGE_LIMITER 4000 /* 4000 mV range delimiter */
|
||||
|
||||
/* correction values for the second pass */
|
||||
#define SK_SEN_PCI_IO_3V3_HIGH_ERR 3850 /* + 15% V PCI-IO High Err Threshold */
|
||||
#define SK_SEN_PCI_IO_3V3_HIGH_WARN 3674 /* + 10% V PCI-IO High Warn Threshold */
|
||||
/* 3300 mVolt */
|
||||
#define SK_SEN_PCI_IO_3V3_LOW_WARN 2926 /* - 10% V PCI-IO Low Warn Threshold */
|
||||
#define SK_SEN_PCI_IO_3V3_LOW_ERR 2772 /* - 15% V PCI-IO Low Err Threshold */
|
||||
|
||||
|
||||
/*
|
||||
* VDD voltage
|
||||
*/
|
||||
#define SK_SEN_VDD_HIGH_ERR 3630 /* Voltage ASIC High Err Threshold */
|
||||
#define SK_SEN_VDD_HIGH_WARN 3476 /* Voltage ASIC High Warn Threshold */
|
||||
#define SK_SEN_VDD_LOW_WARN 3146 /* Voltage ASIC Low Warn Threshold */
|
||||
#define SK_SEN_VDD_LOW_ERR 2970 /* Voltage ASIC Low Err Threshold */
|
||||
|
||||
/*
|
||||
* PHY PLL 3V3 voltage
|
||||
*/
|
||||
#define SK_SEN_PLL_3V3_HIGH_ERR 3630 /* Voltage PMA High Err Threshold */
|
||||
#define SK_SEN_PLL_3V3_HIGH_WARN 3476 /* Voltage PMA High Warn Threshold */
|
||||
#define SK_SEN_PLL_3V3_LOW_WARN 3146 /* Voltage PMA Low Warn Threshold */
|
||||
#define SK_SEN_PLL_3V3_LOW_ERR 2970 /* Voltage PMA Low Err Threshold */
|
||||
|
||||
/*
|
||||
* VAUX (YUKON only)
|
||||
*/
|
||||
#define SK_SEN_VAUX_3V3_HIGH_ERR 3630 /* Voltage VAUX High Err Threshold */
|
||||
#define SK_SEN_VAUX_3V3_HIGH_WARN 3476 /* Voltage VAUX High Warn Threshold */
|
||||
#define SK_SEN_VAUX_3V3_LOW_WARN 3146 /* Voltage VAUX Low Warn Threshold */
|
||||
#define SK_SEN_VAUX_3V3_LOW_ERR 2970 /* Voltage VAUX Low Err Threshold */
|
||||
#define SK_SEN_VAUX_0V_WARN_ERR 0 /* if VAUX not present */
|
||||
#define SK_SEN_VAUX_RANGE_LIMITER 1000 /* 1000 mV range delimiter */
|
||||
|
||||
/*
|
||||
* PHY 2V5 voltage
|
||||
*/
|
||||
#define SK_SEN_PHY_2V5_HIGH_ERR 2750 /* Voltage PHY High Err Threshold */
|
||||
#define SK_SEN_PHY_2V5_HIGH_WARN 2640 /* Voltage PHY High Warn Threshold */
|
||||
#define SK_SEN_PHY_2V5_LOW_WARN 2376 /* Voltage PHY Low Warn Threshold */
|
||||
#define SK_SEN_PHY_2V5_LOW_ERR 2222 /* Voltage PHY Low Err Threshold */
|
||||
|
||||
/*
|
||||
* ASIC Core 1V5 voltage (YUKON only)
|
||||
*/
|
||||
#define SK_SEN_CORE_1V5_HIGH_ERR 1650 /* Voltage ASIC Core High Err Threshold */
|
||||
#define SK_SEN_CORE_1V5_HIGH_WARN 1575 /* Voltage ASIC Core High Warn Threshold */
|
||||
#define SK_SEN_CORE_1V5_LOW_WARN 1425 /* Voltage ASIC Core Low Warn Threshold */
|
||||
#define SK_SEN_CORE_1V5_LOW_ERR 1350 /* Voltage ASIC Core Low Err Threshold */
|
||||
|
||||
/*
|
||||
* FAN 1 speed
|
||||
*/
|
||||
/* assuming: 6500rpm +-15%, 4 pulses,
|
||||
* warning at: 80 %
|
||||
* error at: 70 %
|
||||
* no upper limit
|
||||
*/
|
||||
#define SK_SEN_FAN_HIGH_ERR 20000 /* FAN Speed High Err Threshold */
|
||||
#define SK_SEN_FAN_HIGH_WARN 20000 /* FAN Speed High Warn Threshold */
|
||||
#define SK_SEN_FAN_LOW_WARN 5200 /* FAN Speed Low Warn Threshold */
|
||||
#define SK_SEN_FAN_LOW_ERR 4550 /* FAN Speed Low Err Threshold */
|
||||
|
||||
/*
|
||||
* Some Voltages need dynamic thresholds
|
||||
*/
|
||||
#define SK_SEN_DYN_INIT_NONE 0 /* No dynamic init of thresholds */
|
||||
#define SK_SEN_DYN_INIT_PCI_IO 10 /* Init PCI-IO with new thresholds */
|
||||
#define SK_SEN_DYN_INIT_VAUX 11 /* Init VAUX with new thresholds */
|
||||
|
||||
extern int SkLm80ReadSensor(SK_AC *pAC, SK_IOC IoC, SK_SENSOR *pSen);
|
||||
#endif /* n_INC_SKGEI2C_H */
|
||||
1113
drivers/sk98lin/h/skgeinit.h
Normal file
1113
drivers/sk98lin/h/skgeinit.h
Normal file
File diff suppressed because it is too large
Load Diff
462
drivers/sk98lin/h/skgepnm2.h
Normal file
462
drivers/sk98lin/h/skgepnm2.h
Normal file
@@ -0,0 +1,462 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* Name: skgepnm2.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.34 $
|
||||
* Date: $Date: 2002/12/16 09:05:18 $
|
||||
* Purpose: Defines for Private Network Management Interface
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2001 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* $Log: skgepnm2.h,v $
|
||||
* Revision 1.34 2002/12/16 09:05:18 tschilli
|
||||
* Code for VCT handling added.
|
||||
*
|
||||
* Revision 1.33 2002/09/10 09:00:03 rwahl
|
||||
* Adapted boolean definitions according sktypes.
|
||||
*
|
||||
* Revision 1.32 2002/08/09 09:47:01 rwahl
|
||||
* Added write-only flag to oid access defines.
|
||||
* Editorial changes.
|
||||
*
|
||||
* Revision 1.31 2002/07/17 19:23:18 rwahl
|
||||
* - Replaced MAC counter definitions by enumeration.
|
||||
* - Added definition SK_PNMI_MAC_TYPES.
|
||||
* - Added chipset defnition for Yukon.
|
||||
*
|
||||
* Revision 1.30 2001/02/06 10:03:41 mkunz
|
||||
* - Pnmi V4 dual net support added. Interface functions and macros extended
|
||||
* - Vpd bug fixed
|
||||
* - OID_SKGE_MTU added
|
||||
*
|
||||
* Revision 1.29 2001/01/22 13:41:37 rassmann
|
||||
* Supporting two nets on dual-port adapters.
|
||||
*
|
||||
* Revision 1.28 2000/08/03 15:12:48 rwahl
|
||||
* - Additional comment for MAC statistic data structure.
|
||||
*
|
||||
* Revision 1.27 2000/08/01 16:10:18 rwahl
|
||||
* - Added mac statistic data structure for StatRxLongFrame counter.
|
||||
*
|
||||
* Revision 1.26 2000/03/31 13:51:34 rwahl
|
||||
* Added SK_UPTR cast to offset calculation for PNMI struct fields;
|
||||
* missing cast caused compiler warnings by Win64 compiler.
|
||||
*
|
||||
* Revision 1.25 1999/11/22 13:57:41 cgoos
|
||||
* Changed license header to GPL.
|
||||
* Allowing overwrite for SK_PNMI_STORE/_READ defines.
|
||||
*
|
||||
* Revision 1.24 1999/04/13 15:11:11 mhaveman
|
||||
* Changed copyright.
|
||||
*
|
||||
* Revision 1.23 1999/01/28 15:07:12 mhaveman
|
||||
* Changed default threshold for port switches per hour from 10
|
||||
* to 240 which means 4 switches per minute. This fits better
|
||||
* the granularity of 32 for the port switch estimate
|
||||
* counter.
|
||||
*
|
||||
* Revision 1.22 1999/01/05 12:52:30 mhaveman
|
||||
* Removed macro SK_PNMI_MICRO_SEC.
|
||||
*
|
||||
* Revision 1.21 1999/01/05 12:50:34 mhaveman
|
||||
* Enlarged macro definition SK_PNMI_HUNDREDS_SEC() so that no 64-bit
|
||||
* arithmetic is necessary if SK_TICKS_PER_SEC is 100.
|
||||
*
|
||||
* Revision 1.20 1998/12/09 14:02:53 mhaveman
|
||||
* Defined macro SK_PNMI_DEF_RLMT_CHG_THRES for default port switch
|
||||
* threshold.
|
||||
*
|
||||
* Revision 1.19 1998/12/03 11:28:41 mhaveman
|
||||
* Removed SK_PNMI_CHECKPTR macro.
|
||||
*
|
||||
* Revision 1.18 1998/12/03 11:21:00 mhaveman
|
||||
* -Added pointer check macro SK_PNMI_CHECKPTR
|
||||
* -Added macros SK_PNMI_VPD_ARR_SIZE and SK_PNMI_VPD_STR_SIZE for
|
||||
* VPD key evaluation.
|
||||
*
|
||||
* Revision 1.17 1998/11/20 13:20:33 mhaveman
|
||||
* Fixed bug in SK_PNMI_SET_STAT macro. ErrorStatus was not correctly set.
|
||||
*
|
||||
* Revision 1.16 1998/11/20 08:08:49 mhaveman
|
||||
* Macro SK_PNMI_CHECKFLAGS has got a if clause.
|
||||
*
|
||||
* Revision 1.15 1998/11/03 13:53:40 mhaveman
|
||||
* Fixed alignment problem in macor SK_PNMI_SET_STAT macro.
|
||||
*
|
||||
* Revision 1.14 1998/10/30 15:50:13 mhaveman
|
||||
* Added macro SK_PNMI_MICRO_SEC()
|
||||
*
|
||||
* Revision 1.13 1998/10/30 12:32:20 mhaveman
|
||||
* Added forgotten cast in SK_PNMI_READ_U32 macro.
|
||||
*
|
||||
* Revision 1.12 1998/10/29 15:40:26 mhaveman
|
||||
* -Changed SK_PNMI_TRAP_SENSOR_LEN because SensorDescr has now
|
||||
* variable string length.
|
||||
* -Defined SK_PNMI_CHECKFLAGS macro
|
||||
*
|
||||
* Revision 1.11 1998/10/29 08:53:34 mhaveman
|
||||
* Removed SK_PNMI_RLM_XXX table indexed because these counters need
|
||||
* not been saved over XMAC resets.
|
||||
*
|
||||
* Revision 1.10 1998/10/28 08:48:20 mhaveman
|
||||
* -Added macros for storage according to alignment
|
||||
* -Changed type of Instance to SK_U32 because of VPD
|
||||
* -Removed trap structures. Not needed because of alignment problem
|
||||
* -Changed type of Action form SK_U8 to int
|
||||
*
|
||||
* Revision 1.9 1998/10/21 13:34:45 mhaveman
|
||||
* Shit, mismatched calculation of SK_PNMI_HUNDREDS_SEC. Corrected.
|
||||
*
|
||||
* Revision 1.8 1998/10/21 13:24:58 mhaveman
|
||||
* Changed calculation of hundreds of seconds.
|
||||
*
|
||||
* Revision 1.7 1998/10/20 07:31:41 mhaveman
|
||||
* Made type changes to unsigned int where possible.
|
||||
*
|
||||
* Revision 1.6 1998/09/04 17:04:05 mhaveman
|
||||
* Added Sync counters to offset storage to provided settled values on
|
||||
* port switch.
|
||||
*
|
||||
* Revision 1.5 1998/09/04 12:45:35 mhaveman
|
||||
* Removed dummies for SK_DRIVER_ macros. They should be added by driver
|
||||
* writer in skdrv2nd.h.
|
||||
*
|
||||
* Revision 1.4 1998/09/04 11:59:50 mhaveman
|
||||
* Everything compiles now. Driver Macros for counting still missing.
|
||||
*
|
||||
* Revision 1.3 1998/08/24 12:01:35 mhaveman
|
||||
* Intermediate state.
|
||||
*
|
||||
* Revision 1.2 1998/08/17 07:51:40 mhaveman
|
||||
* Intermediate state.
|
||||
*
|
||||
* Revision 1.1 1998/08/11 09:08:40 mhaveman
|
||||
* Intermediate state.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _SKGEPNM2_H_
|
||||
#define _SKGEPNM2_H_
|
||||
|
||||
/*
|
||||
* General definitions
|
||||
*/
|
||||
#define SK_PNMI_CHIPSET_XMAC 1 /* XMAC11800FP */
|
||||
#define SK_PNMI_CHIPSET_YUKON 2 /* YUKON */
|
||||
|
||||
#define SK_PNMI_BUS_PCI 1 /* PCI bus*/
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
#define SK_PNMI_ACT_IDLE 1
|
||||
#define SK_PNMI_ACT_RESET 2
|
||||
#define SK_PNMI_ACT_SELFTEST 3
|
||||
#define SK_PNMI_ACT_RESETCNT 4
|
||||
|
||||
/*
|
||||
* VPD releated defines
|
||||
*/
|
||||
|
||||
#define SK_PNMI_VPD_RW 1
|
||||
#define SK_PNMI_VPD_RO 2
|
||||
|
||||
#define SK_PNMI_VPD_OK 0
|
||||
#define SK_PNMI_VPD_NOTFOUND 1
|
||||
#define SK_PNMI_VPD_CUT 2
|
||||
#define SK_PNMI_VPD_TIMEOUT 3
|
||||
#define SK_PNMI_VPD_FULL 4
|
||||
#define SK_PNMI_VPD_NOWRITE 5
|
||||
#define SK_PNMI_VPD_FATAL 6
|
||||
|
||||
#define SK_PNMI_VPD_IGNORE 0
|
||||
#define SK_PNMI_VPD_CREATE 1
|
||||
#define SK_PNMI_VPD_DELETE 2
|
||||
|
||||
|
||||
/*
|
||||
* RLMT related defines
|
||||
*/
|
||||
#define SK_PNMI_DEF_RLMT_CHG_THRES 240 /* 4 changes per minute */
|
||||
|
||||
|
||||
/*
|
||||
* VCT internal status values
|
||||
*/
|
||||
#define SK_PNMI_VCT_PENDING 32
|
||||
#define SK_PNMI_VCT_TEST_DONE 64
|
||||
#define SK_PNMI_VCT_LINK 128
|
||||
|
||||
/*
|
||||
* Internal table definitions
|
||||
*/
|
||||
#define SK_PNMI_GET 0
|
||||
#define SK_PNMI_PRESET 1
|
||||
#define SK_PNMI_SET 2
|
||||
|
||||
#define SK_PNMI_RO 0
|
||||
#define SK_PNMI_RW 1
|
||||
#define SK_PNMI_WO 2
|
||||
|
||||
typedef struct s_OidTabEntry {
|
||||
SK_U32 Id;
|
||||
SK_U32 InstanceNo;
|
||||
unsigned int StructSize;
|
||||
unsigned int Offset;
|
||||
int Access;
|
||||
int (* Func)(SK_AC *pAc, SK_IOC pIo, int action,
|
||||
SK_U32 Id, char* pBuf, unsigned int* pLen,
|
||||
SK_U32 Instance, unsigned int TableIndex,
|
||||
SK_U32 NetNumber);
|
||||
SK_U16 Param;
|
||||
} SK_PNMI_TAB_ENTRY;
|
||||
|
||||
|
||||
/*
|
||||
* Trap lengths
|
||||
*/
|
||||
#define SK_PNMI_TRAP_SIMPLE_LEN 17
|
||||
#define SK_PNMI_TRAP_SENSOR_LEN_BASE 46
|
||||
#define SK_PNMI_TRAP_RLMT_CHANGE_LEN 23
|
||||
#define SK_PNMI_TRAP_RLMT_PORT_LEN 23
|
||||
|
||||
/*
|
||||
* Number of MAC types supported
|
||||
*/
|
||||
#define SK_PNMI_MAC_TYPES (SK_MAC_GMAC + 1)
|
||||
|
||||
/*
|
||||
* MAC statistic data list (overall set for MAC types used)
|
||||
*/
|
||||
enum SK_MACSTATS {
|
||||
SK_PNMI_HTX = 0,
|
||||
SK_PNMI_HTX_OCTET,
|
||||
SK_PNMI_HTX_OCTETHIGH = SK_PNMI_HTX_OCTET,
|
||||
SK_PNMI_HTX_OCTETLOW,
|
||||
SK_PNMI_HTX_BROADCAST,
|
||||
SK_PNMI_HTX_MULTICAST,
|
||||
SK_PNMI_HTX_UNICAST,
|
||||
SK_PNMI_HTX_BURST,
|
||||
SK_PNMI_HTX_PMACC,
|
||||
SK_PNMI_HTX_MACC,
|
||||
SK_PNMI_HTX_COL,
|
||||
SK_PNMI_HTX_SINGLE_COL,
|
||||
SK_PNMI_HTX_MULTI_COL,
|
||||
SK_PNMI_HTX_EXCESS_COL,
|
||||
SK_PNMI_HTX_LATE_COL,
|
||||
SK_PNMI_HTX_DEFFERAL,
|
||||
SK_PNMI_HTX_EXCESS_DEF,
|
||||
SK_PNMI_HTX_UNDERRUN,
|
||||
SK_PNMI_HTX_CARRIER,
|
||||
SK_PNMI_HTX_UTILUNDER,
|
||||
SK_PNMI_HTX_UTILOVER,
|
||||
SK_PNMI_HTX_64,
|
||||
SK_PNMI_HTX_127,
|
||||
SK_PNMI_HTX_255,
|
||||
SK_PNMI_HTX_511,
|
||||
SK_PNMI_HTX_1023,
|
||||
SK_PNMI_HTX_MAX,
|
||||
SK_PNMI_HTX_LONGFRAMES,
|
||||
SK_PNMI_HTX_SYNC,
|
||||
SK_PNMI_HTX_SYNC_OCTET,
|
||||
SK_PNMI_HTX_RESERVED,
|
||||
|
||||
SK_PNMI_HRX,
|
||||
SK_PNMI_HRX_OCTET,
|
||||
SK_PNMI_HRX_OCTETHIGH = SK_PNMI_HRX_OCTET,
|
||||
SK_PNMI_HRX_OCTETLOW,
|
||||
SK_PNMI_HRX_BADOCTET,
|
||||
SK_PNMI_HRX_BADOCTETHIGH = SK_PNMI_HRX_BADOCTET,
|
||||
SK_PNMI_HRX_BADOCTETLOW,
|
||||
SK_PNMI_HRX_BROADCAST,
|
||||
SK_PNMI_HRX_MULTICAST,
|
||||
SK_PNMI_HRX_UNICAST,
|
||||
SK_PNMI_HRX_PMACC,
|
||||
SK_PNMI_HRX_MACC,
|
||||
SK_PNMI_HRX_PMACC_ERR,
|
||||
SK_PNMI_HRX_MACC_UNKWN,
|
||||
SK_PNMI_HRX_BURST,
|
||||
SK_PNMI_HRX_MISSED,
|
||||
SK_PNMI_HRX_FRAMING,
|
||||
SK_PNMI_HRX_UNDERSIZE,
|
||||
SK_PNMI_HRX_OVERFLOW,
|
||||
SK_PNMI_HRX_JABBER,
|
||||
SK_PNMI_HRX_CARRIER,
|
||||
SK_PNMI_HRX_IRLENGTH,
|
||||
SK_PNMI_HRX_SYMBOL,
|
||||
SK_PNMI_HRX_SHORTS,
|
||||
SK_PNMI_HRX_RUNT,
|
||||
SK_PNMI_HRX_TOO_LONG,
|
||||
SK_PNMI_HRX_FCS,
|
||||
SK_PNMI_HRX_CEXT,
|
||||
SK_PNMI_HRX_UTILUNDER,
|
||||
SK_PNMI_HRX_UTILOVER,
|
||||
SK_PNMI_HRX_64,
|
||||
SK_PNMI_HRX_127,
|
||||
SK_PNMI_HRX_255,
|
||||
SK_PNMI_HRX_511,
|
||||
SK_PNMI_HRX_1023,
|
||||
SK_PNMI_HRX_MAX,
|
||||
SK_PNMI_HRX_LONGFRAMES,
|
||||
|
||||
SK_PNMI_HRX_RESERVED,
|
||||
|
||||
SK_PNMI_MAX_IDX /* NOTE: Ensure SK_PNMI_CNT_NO is set to this value */
|
||||
};
|
||||
|
||||
/*
|
||||
* MAC specific data
|
||||
*/
|
||||
typedef struct s_PnmiStatAddr {
|
||||
SK_U16 Reg; /* MAC register containing the value */
|
||||
SK_BOOL GetOffset; /* TRUE: Offset managed by PNMI (call GetStatVal())*/
|
||||
} SK_PNMI_STATADDR;
|
||||
|
||||
|
||||
/*
|
||||
* SK_PNMI_STRUCT_DATA copy offset evaluation macros
|
||||
*/
|
||||
#define SK_PNMI_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_STRUCT_DATA *)0)->e))
|
||||
#define SK_PNMI_MAI_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_STRUCT_DATA *)0)->e))
|
||||
#define SK_PNMI_VPD_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_VPD *)0)->e))
|
||||
#define SK_PNMI_SEN_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_SENSOR *)0)->e))
|
||||
#define SK_PNMI_CHK_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_CHECKSUM *)0)->e))
|
||||
#define SK_PNMI_STA_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_STAT *)0)->e))
|
||||
#define SK_PNMI_CNF_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_CONF *)0)->e))
|
||||
#define SK_PNMI_RLM_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_RLMT *)0)->e))
|
||||
#define SK_PNMI_MON_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_RLMT_MONITOR *)0)->e))
|
||||
#define SK_PNMI_TRP_OFF(e) ((SK_U32)(SK_UPTR)&(((SK_PNMI_TRAP *)0)->e))
|
||||
|
||||
#define SK_PNMI_SET_STAT(b,s,o) {SK_U32 Val32; char *pVal; \
|
||||
Val32 = (s); \
|
||||
pVal = (char *)(b) + ((SK_U32)(SK_UPTR) \
|
||||
&(((SK_PNMI_STRUCT_DATA *)0)-> \
|
||||
ReturnStatus.ErrorStatus)); \
|
||||
SK_PNMI_STORE_U32(pVal, Val32); \
|
||||
Val32 = (o); \
|
||||
pVal = (char *)(b) + ((SK_U32)(SK_UPTR) \
|
||||
&(((SK_PNMI_STRUCT_DATA *)0)-> \
|
||||
ReturnStatus.ErrorOffset)); \
|
||||
SK_PNMI_STORE_U32(pVal, Val32);}
|
||||
|
||||
/*
|
||||
* Time macros
|
||||
*/
|
||||
#if SK_TICKS_PER_SEC == 100
|
||||
#define SK_PNMI_HUNDREDS_SEC(t) (t)
|
||||
#else
|
||||
#define SK_PNMI_HUNDREDS_SEC(t) (((t) * 100) / (SK_TICKS_PER_SEC))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros to work around alignment problems
|
||||
*/
|
||||
#ifndef SK_PNMI_STORE_U16
|
||||
#define SK_PNMI_STORE_U16(p,v) {*(char *)(p) = *((char *)&(v)); \
|
||||
*((char *)(p) + 1) = \
|
||||
*(((char *)&(v)) + 1);}
|
||||
#endif
|
||||
|
||||
#ifndef SK_PNMI_STORE_U32
|
||||
#define SK_PNMI_STORE_U32(p,v) {*(char *)(p) = *((char *)&(v)); \
|
||||
*((char *)(p) + 1) = \
|
||||
*(((char *)&(v)) + 1); \
|
||||
*((char *)(p) + 2) = \
|
||||
*(((char *)&(v)) + 2); \
|
||||
*((char *)(p) + 3) = \
|
||||
*(((char *)&(v)) + 3);}
|
||||
#endif
|
||||
|
||||
#ifndef SK_PNMI_STORE_U64
|
||||
#define SK_PNMI_STORE_U64(p,v) {*(char *)(p) = *((char *)&(v)); \
|
||||
*((char *)(p) + 1) = \
|
||||
*(((char *)&(v)) + 1); \
|
||||
*((char *)(p) + 2) = \
|
||||
*(((char *)&(v)) + 2); \
|
||||
*((char *)(p) + 3) = \
|
||||
*(((char *)&(v)) + 3); \
|
||||
*((char *)(p) + 4) = \
|
||||
*(((char *)&(v)) + 4); \
|
||||
*((char *)(p) + 5) = \
|
||||
*(((char *)&(v)) + 5); \
|
||||
*((char *)(p) + 6) = \
|
||||
*(((char *)&(v)) + 6); \
|
||||
*((char *)(p) + 7) = \
|
||||
*(((char *)&(v)) + 7);}
|
||||
#endif
|
||||
|
||||
#ifndef SK_PNMI_READ_U16
|
||||
#define SK_PNMI_READ_U16(p,v) {*((char *)&(v)) = *(char *)(p); \
|
||||
*(((char *)&(v)) + 1) = \
|
||||
*((char *)(p) + 1);}
|
||||
#endif
|
||||
|
||||
#ifndef SK_PNMI_READ_U32
|
||||
#define SK_PNMI_READ_U32(p,v) {*((char *)&(v)) = *(char *)(p); \
|
||||
*(((char *)&(v)) + 1) = \
|
||||
*((char *)(p) + 1); \
|
||||
*(((char *)&(v)) + 2) = \
|
||||
*((char *)(p) + 2); \
|
||||
*(((char *)&(v)) + 3) = \
|
||||
*((char *)(p) + 3);}
|
||||
#endif
|
||||
|
||||
#ifndef SK_PNMI_READ_U64
|
||||
#define SK_PNMI_READ_U64(p,v) {*((char *)&(v)) = *(char *)(p); \
|
||||
*(((char *)&(v)) + 1) = \
|
||||
*((char *)(p) + 1); \
|
||||
*(((char *)&(v)) + 2) = \
|
||||
*((char *)(p) + 2); \
|
||||
*(((char *)&(v)) + 3) = \
|
||||
*((char *)(p) + 3); \
|
||||
*(((char *)&(v)) + 4) = \
|
||||
*((char *)(p) + 4); \
|
||||
*(((char *)&(v)) + 5) = \
|
||||
*((char *)(p) + 5); \
|
||||
*(((char *)&(v)) + 6) = \
|
||||
*((char *)(p) + 6); \
|
||||
*(((char *)&(v)) + 7) = \
|
||||
*((char *)(p) + 7);}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for Debug
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
|
||||
#define SK_PNMI_CHECKFLAGS(vSt) {if (pAC->Pnmi.MacUpdatedFlag > 0 || \
|
||||
pAC->Pnmi.RlmtUpdatedFlag > 0 || \
|
||||
pAC->Pnmi.SirqUpdatedFlag > 0) { \
|
||||
SK_DBG_MSG(pAC, \
|
||||
SK_DBGMOD_PNMI, \
|
||||
SK_DBGCAT_CTRL, \
|
||||
("PNMI: ERR: %s MacUFlag=%d, RlmtUFlag=%d, SirqUFlag=%d\n", \
|
||||
vSt, \
|
||||
pAC->Pnmi.MacUpdatedFlag, \
|
||||
pAC->Pnmi.RlmtUpdatedFlag, \
|
||||
pAC->Pnmi.SirqUpdatedFlag))}}
|
||||
|
||||
#else /* !DEBUG */
|
||||
|
||||
#define SK_PNMI_CHECKFLAGS(vSt) /* Nothing */
|
||||
|
||||
#endif /* !DEBUG */
|
||||
|
||||
#endif /* _SKGEPNM2_H_ */
|
||||
1114
drivers/sk98lin/h/skgepnmi.h
Normal file
1114
drivers/sk98lin/h/skgepnmi.h
Normal file
File diff suppressed because it is too large
Load Diff
194
drivers/sk98lin/h/skgesirq.h
Normal file
194
drivers/sk98lin/h/skgesirq.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Name: skgesirq.h
|
||||
* Project: GEnesis, PCI Gigabit Ethernet Adapter
|
||||
* Version: $Revision: 1.26 $
|
||||
* Date: $Date: 2002/10/14 09:52:36 $
|
||||
* Purpose: SK specific Gigabit Ethernet special IRQ functions
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* (C)Copyright 1998-2002 SysKonnect GmbH.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The information in this file is provided "AS IS" without warranty.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* History:
|
||||
* $Log: skgesirq.h,v $
|
||||
* Revision 1.26 2002/10/14 09:52:36 rschmidt
|
||||
* Added SKERR_SIRQ_E023 and SKERR_SIRQ_E023 for GPHY (Yukon)
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.25 2002/07/15 18:15:52 rwahl
|
||||
* Editorial changes.
|
||||
*
|
||||
* Revision 1.24 2002/07/15 15:39:21 rschmidt
|
||||
* Corrected define for SKERR_SIRQ_E022
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.23 2002/04/25 11:09:45 rschmidt
|
||||
* Removed declarations for SkXmInitPhy(), SkXmRxTxEnable()
|
||||
* Editorial changes
|
||||
*
|
||||
* Revision 1.22 2000/11/09 11:30:10 rassmann
|
||||
* WA: Waiting after releasing reset until BCom chip is accessible.
|
||||
*
|
||||
* Revision 1.21 2000/10/18 12:22:40 cgoos
|
||||
* Added workaround for half duplex hangup.
|
||||
*
|
||||
* Revision 1.20 1999/12/06 10:00:44 cgoos
|
||||
* Added SET event for role.
|
||||
*
|
||||
* Revision 1.19 1999/11/22 13:58:26 cgoos
|
||||
* Changed license header to GPL.
|
||||
*
|
||||
* Revision 1.18 1999/05/19 07:32:59 cgoos
|
||||
* Changes for 1000Base-T.
|
||||
*
|
||||
* Revision 1.17 1999/03/12 13:29:31 malthoff
|
||||
* Move Autonegotiation Error Codes to skgeinit.h.
|
||||
*
|
||||
* Revision 1.16 1999/03/08 10:11:28 gklug
|
||||
* add: AutoNegDone return codes
|
||||
*
|
||||
* Revision 1.15 1998/11/18 13:20:53 gklug
|
||||
* add: different timeouts for active and non-active links
|
||||
*
|
||||
* Revision 1.14 1998/11/04 07:18:14 cgoos
|
||||
* Added prototype for SkXmRxTxEnable.
|
||||
*
|
||||
* Revision 1.13 1998/10/21 05:52:23 gklug
|
||||
* add: parameter DoLoop to InitPhy function
|
||||
*
|
||||
* Revision 1.12 1998/10/19 06:45:03 cgoos
|
||||
* Added prototype for SkXmInitPhy.
|
||||
*
|
||||
* Revision 1.11 1998/10/15 14:34:10 gklug
|
||||
* add: WA_TIME is 500 msec
|
||||
*
|
||||
* Revision 1.10 1998/10/14 14:49:41 malthoff
|
||||
* Remove err log defines E021 and E022. They are
|
||||
* defined in skgeinit.h now.
|
||||
*
|
||||
* Revision 1.9 1998/10/14 14:00:39 gklug
|
||||
* add: error logs for init phys
|
||||
*
|
||||
* Revision 1.8 1998/10/14 05:44:05 gklug
|
||||
* add: E020
|
||||
*
|
||||
* Revision 1.7 1998/10/02 06:24:58 gklug
|
||||
* add: error messages
|
||||
*
|
||||
* Revision 1.6 1998/10/01 07:54:45 gklug
|
||||
* add: PNMI debug module
|
||||
*
|
||||
* Revision 1.5 1998/09/28 13:36:31 malthoff
|
||||
* Move the bit definitions for Autonegotiation
|
||||
* and Flow Control to skgeinit.h.
|
||||
*
|
||||
* Revision 1.4 1998/09/15 12:29:34 gklug
|
||||
* add: error logs
|
||||
*
|
||||
* Revision 1.3 1998/09/03 13:54:02 gklug
|
||||
* add: function prototypes
|
||||
*
|
||||
* Revision 1.2 1998/09/03 10:24:36 gklug
|
||||
* add: Events send by PNMI
|
||||
* add: parameter definition for Flow Control etc.
|
||||
*
|
||||
* Revision 1.1 1998/08/27 11:50:27 gklug
|
||||
* initial revision
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef _INC_SKGESIRQ_H_
|
||||
#define _INC_SKGESIRQ_H_
|
||||
|
||||
/*
|
||||
* Define the Event the special IRQ/INI module can handle
|
||||
*/
|
||||
#define SK_HWEV_WATIM 1 /* Timeout for WA errata #2 XMAC */
|
||||
#define SK_HWEV_PORT_START 2 /* Port Start Event by RLMT */
|
||||
#define SK_HWEV_PORT_STOP 3 /* Port Stop Event by RLMT */
|
||||
#define SK_HWEV_CLEAR_STAT 4 /* Clear Statistics by PNMI */
|
||||
#define SK_HWEV_UPDATE_STAT 5 /* Update Statistics by PNMI */
|
||||
#define SK_HWEV_SET_LMODE 6 /* Set Link Mode by PNMI */
|
||||
#define SK_HWEV_SET_FLOWMODE 7 /* Set Flow Control Mode by PNMI */
|
||||
#define SK_HWEV_SET_ROLE 8 /* Set Master/Slave (Role) by PNMI */
|
||||
#define SK_HWEV_SET_SPEED 9 /* Set Link Speed by PNMI */
|
||||
#define SK_HWEV_HALFDUP_CHK 10 /* Half Duplex Hangup Workaround */
|
||||
|
||||
#define SK_WA_ACT_TIME (5000000L) /* 5 sec */
|
||||
#define SK_WA_INA_TIME (100000L) /* 100 msec */
|
||||
|
||||
#define SK_HALFDUP_CHK_TIME (10000L) /* 10 msec */
|
||||
|
||||
/*
|
||||
* Define the error numbers and messages
|
||||
*/
|
||||
#define SKERR_SIRQ_E001 (SK_ERRBASE_SIRQ+0)
|
||||
#define SKERR_SIRQ_E001MSG "Unknown event"
|
||||
#define SKERR_SIRQ_E002 (SKERR_SIRQ_E001+1)
|
||||
#define SKERR_SIRQ_E002MSG "Packet timeout RX1"
|
||||
#define SKERR_SIRQ_E003 (SKERR_SIRQ_E002+1)
|
||||
#define SKERR_SIRQ_E003MSG "Packet timeout RX2"
|
||||
#define SKERR_SIRQ_E004 (SKERR_SIRQ_E003+1)
|
||||
#define SKERR_SIRQ_E004MSG "MAC 1 not correctly initialized"
|
||||
#define SKERR_SIRQ_E005 (SKERR_SIRQ_E004+1)
|
||||
#define SKERR_SIRQ_E005MSG "MAC 2 not correctly initialized"
|
||||
#define SKERR_SIRQ_E006 (SKERR_SIRQ_E005+1)
|
||||
#define SKERR_SIRQ_E006MSG "CHECK failure R1"
|
||||
#define SKERR_SIRQ_E007 (SKERR_SIRQ_E006+1)
|
||||
#define SKERR_SIRQ_E007MSG "CHECK failure R2"
|
||||
#define SKERR_SIRQ_E008 (SKERR_SIRQ_E007+1)
|
||||
#define SKERR_SIRQ_E008MSG "CHECK failure XS1"
|
||||
#define SKERR_SIRQ_E009 (SKERR_SIRQ_E008+1)
|
||||
#define SKERR_SIRQ_E009MSG "CHECK failure XA1"
|
||||
#define SKERR_SIRQ_E010 (SKERR_SIRQ_E009+1)
|
||||
#define SKERR_SIRQ_E010MSG "CHECK failure XS2"
|
||||
#define SKERR_SIRQ_E011 (SKERR_SIRQ_E010+1)
|
||||
#define SKERR_SIRQ_E011MSG "CHECK failure XA2"
|
||||
#define SKERR_SIRQ_E012 (SKERR_SIRQ_E011+1)
|
||||
#define SKERR_SIRQ_E012MSG "unexpected IRQ Master error"
|
||||
#define SKERR_SIRQ_E013 (SKERR_SIRQ_E012+1)
|
||||
#define SKERR_SIRQ_E013MSG "unexpected IRQ Status error"
|
||||
#define SKERR_SIRQ_E014 (SKERR_SIRQ_E013+1)
|
||||
#define SKERR_SIRQ_E014MSG "Parity error on RAM (read)"
|
||||
#define SKERR_SIRQ_E015 (SKERR_SIRQ_E014+1)
|
||||
#define SKERR_SIRQ_E015MSG "Parity error on RAM (write)"
|
||||
#define SKERR_SIRQ_E016 (SKERR_SIRQ_E015+1)
|
||||
#define SKERR_SIRQ_E016MSG "Parity error MAC 1"
|
||||
#define SKERR_SIRQ_E017 (SKERR_SIRQ_E016+1)
|
||||
#define SKERR_SIRQ_E017MSG "Parity error MAC 2"
|
||||
#define SKERR_SIRQ_E018 (SKERR_SIRQ_E017+1)
|
||||
#define SKERR_SIRQ_E018MSG "Parity error RX 1"
|
||||
#define SKERR_SIRQ_E019 (SKERR_SIRQ_E018+1)
|
||||
#define SKERR_SIRQ_E019MSG "Parity error RX 2"
|
||||
#define SKERR_SIRQ_E020 (SKERR_SIRQ_E019+1)
|
||||
#define SKERR_SIRQ_E020MSG "MAC transmit FIFO underrun"
|
||||
#define SKERR_SIRQ_E021 (SKERR_SIRQ_E020+1)
|
||||
#define SKERR_SIRQ_E021MSG "Spurious TWSI interrupt"
|
||||
#define SKERR_SIRQ_E022 (SKERR_SIRQ_E021+1)
|
||||
#define SKERR_SIRQ_E022MSG "Cable pair swap error"
|
||||
#define SKERR_SIRQ_E023 (SKERR_SIRQ_E022+1)
|
||||
#define SKERR_SIRQ_E023MSG "Auto-negotiation error"
|
||||
#define SKERR_SIRQ_E024 (SKERR_SIRQ_E023+1)
|
||||
#define SKERR_SIRQ_E024MSG "FIFO overflow error"
|
||||
|
||||
extern void SkGeSirqIsr(SK_AC *pAC, SK_IOC IoC, SK_U32 Istatus);
|
||||
extern int SkGeSirqEvent(SK_AC *pAC, SK_IOC IoC, SK_U32 Event, SK_EVPARA Para);
|
||||
extern void SkHWLinkUp(SK_AC *pAC, SK_IOC IoC, int Port);
|
||||
extern void SkHWLinkDown(SK_AC *pAC, SK_IOC IoC, int Port);
|
||||
|
||||
#endif /* _INC_SKGESIRQ_H_ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user