Compare commits

..
Author SHA1 Message Date
wdenk 232c150a25 Add support for Siemens SX1 mobile phone;
add support for USB-based console
(enable with "setenv stdout usbtty; setenv stdin usbtty")
2004-03-12 00:14:09 +00:00
wdenk 79d696fc55 Fix LOWBOOT configuration for MPC5200 with DDR memory 2004-03-11 22:46:36 +00:00
wdenk f8d813e34f * Fix SDRAM timings for LITE5200 / IceCube board
* Handle Auti-MDIX / connection status for INCA-IP

* Fix USB problems when attempting to read 0 bytes
2004-03-02 14:05:39 +00:00
wdenk e7c85689bb * Patch by Travis Sawyer, 26 Feb 2004:
Fix broken compile for XPEDITE1K target.

* Patch by Stephan Linz, 26 Feb 2004:
  Bug fix for NFS code on NIOS targets

* Patch by Stephen Williams, 26 Feb 2004:
  Break up SystemACE reads of large block counts
2004-02-27 08:21:54 +00:00
wdenk 132ba5fdc5 * Patch by Pierre Aubert, 26 Feb 2004
add IDE support for MPC5200

* Patch by Masami Komiya, 26 Feb 2004:
  add autoload via NFS

* Patch by Stephen Williams
  Use of CONFIG_SERIAL_SOFTWARE_FIFO in board.c consistent with uses
  elsewhere in the source.
2004-02-27 08:20:54 +00:00
wdenk 11dadd547c * Patch by Steven Scholz, 25 Feb 2004:
- Timeouts in FPGA code should be based on CFG_HZ
  - Minor cleanup in code for Altera FPGA ACEX1K

* Patch by Steven Scholz, 25 Feb 2004:
  Changed "Directory Hierarchy" section in README

* Patch by Masami Komiya, 25 Feb 2004:
  Reduce copy count in nfs_read_reply() of NFS code
2004-02-27 00:07:27 +00:00
wdenk 80885a9d52 * Patch by Markus Pietrek, 24 Feb 2004:
NS9750 DevBoard added

* Patch by Pierre AUBERT, 24 Feb 2004
  add USB support for MPC5200

* Patch by Steven Scholz, 24 Feb 2004:
  - fix MII commands to use values from last command

* Patch by Torsten Demke, 24 Feb 2004:
  Add support for the eXalion platform (SPSW-8240, F-30, F-300)
2004-02-26 23:46:20 +00:00
wdenk 0c852a2886 * Patch by Rahul Shanbhag, 19 Feb 2004:
Fixes for for OMAP1610 board:
  - shift some IRQ specific code to platform.S file
  - remove duplicatewatchdog reset code from start.S

* Make Auto-MDIX Support configurable on INCA-IP board

* Fix license for mkimage tool
2004-02-26 23:01:04 +00:00
wdenk a084f7da88 * Patch by Masami Komiya, 24 Feb 2004:
Update NetBootFileXferSize in NFS code

* Patch by Scott McNutt, 24 Feb 2004:
  fix packet length in NFS code
2004-02-24 22:33:21 +00:00
87 changed files with 14576 additions and 708 deletions

No files matched your search

+67
View File
@@ -2,6 +2,73 @@
Changes for U-Boot 1.0.2:
======================================================================
* Add support for SX1 mobile phone; add support for USB-based console
(enable with "setenv stdout usbtty; setenv stdin usbtty")
* Fix LOWBOOT configuration for MPC5200 with DDR memory
* Fix SDRAM timings for LITE5200 / IceCube board
* Handle Auti-MDIX / connection status for INCA-IP
* Fix USB problems when attempting to read 0 bytes
* Patch by Travis Sawyer, 26 Feb 2004:
Fix broken compile for XPEDITE1K target.
* Patch by Stephan Linz, 26 Feb 2004:
Bug fix for NFS code on NIOS targets
* Patch by Stephen Williams, 26 Feb 2004:
Break up SystemACE reads of large block counts
* Patch by Pierre Aubert, 26 Feb 2004
add IDE support for MPC5200
* Patch by Masami Komiya, 26 Feb 2004:
add autoload via NFS
* Patch by Stephen Williams
Use of CONFIG_SERIAL_SOFTWARE_FIFO in board.c consistent with uses
elsewhere in the source.
* Patch by Steven Scholz, 25 Feb 2004:
- Timeouts in FPGA code should be based on CFG_HZ
- Minor cleanup in code for Altera FPGA ACEX1K
* Patch by Steven Scholz, 25 Feb 2004:
Changed "Directory Hierarchy" section in README
* Patch by Masami Komiya, 25 Feb 2004:
Reduce copy count in nfs_read_reply() of NFS code
* Patch by Markus Pietrek, 24 Feb 2004:
NS9750 DevBoard added
* Patch by Pierre Aubert, 24 Feb 2004
add USB support for MPC5200
* Patch by Steven Scholz, 24 Feb 2004:
- fix MII commands to use values from last command
* Patch by Torsten Demke, 24 Feb 2004:
Add support for the eXalion platform (SPSW-8240, F-30, F-300)
* Patch by Rahul Shanbhag, 19 Feb 2004:
Fixes for for OMAP1610 board:
- shift some IRQ specific code to platform.S file
- remove duplicatewatchdog reset code from start.S
* Make Auto-MDIX Support configurable on INCA-IP board
* Fix license for mkimage tool
* Patch by Masami Komiya, 24 Feb 2004:
Update NetBootFileXferSize in NFS code
* Patch by Scott McNutt, 24 Feb 2004:
fix packet length in NFS code
* Patch by Masami Komiy, 22 Feb 2004:
Add support for NFS for file download
+5
View File
@@ -103,6 +103,11 @@ N: Dave Ellis
E: DGE@sixnetio.com
D: EEPROM Speedup, SXNI855T port
N: Thomas Elste
E: info@elste.org
D: Port for the ModNET50 Board, NET+50 CPU Port
W: http://www.imms.de
N: Daniel Engström
E: daniel@omicron.se
D: x86 port, Support for sc520_cdp board
+8
View File
@@ -49,6 +49,10 @@ K
FLAGADM MPC823
Torsten Demke <torsten.demke@fci.com>
eXalion MPC824x
Wolfgang Denk <wd@denx.de>
AMX860 MPC860
@@ -289,6 +293,10 @@ Unknown / orphaned boards:
# Board CPU #
#########################################################################
Thomas Elste <info@elste.org>
modnet50 ARM720T (NET+50)
Peter Figuli <peposh@etc.sk>
wepep250 xscale
+3 -3
View File
@@ -73,9 +73,9 @@ LIST_4xx=" \
LIST_824x=" \
A3000 BMW CPC45 CU824 \
debris MOUSSE MUSENKI MVBLUE \
OXC PN62 Sandpoint8240 Sandpoint8245 \
SL8245 utx8245 \
debris eXalion MOUSSE MUSENKI \
MVBLUE OXC PN62 Sandpoint8240 \
Sandpoint8245 SL8245 utx8245 \
"
#########################################################################
+8 -1
View File
@@ -207,9 +207,10 @@ PATI_config:unconfig
MPC5200LITE_config \
MPC5200LITE_LOWBOOT_config \
MPC5200LITE_LOWBOOT08_config \
icecube_5200_DDR_LOWBOOT_config \
icecube_5200_DDR_config \
IceCube_5200_DDR_config \
icecube_5200_DDR_LOWBOOT_config \
icecube_5200_DDR_LOWBOOT08_config \
icecube_5200_config \
IceCube_5200_config \
IceCube_5100_config: unconfig
@@ -671,6 +672,9 @@ CPC45_ROMBOOT_config: unconfig
CU824_config: unconfig
@./mkconfig $(@:_config=) ppc mpc824x cu824
eXalion_config: unconfig
@./mkconfig $(@:_config=) ppc mpc824x eXalion
MOUSSE_config: unconfig
@./mkconfig $(@:_config=) ppc mpc824x mousse
@@ -917,6 +921,9 @@ xtract_trab = $(subst _bigram,,$(subst _bigflash,,$(subst _old,,$(subst _config,
xtract_omap1610xxx = $(subst _cs0boot,,$(subst _cs3boot,, $(subst _config,,$1)))
SX1_config : unconfig
@./mkconfig $(@:_config=) arm arm925t sx1
omap1510inn_config : unconfig
@./mkconfig $(@:_config=) arm arm925t omap1510inn
+31 -121
View File
@@ -122,135 +122,45 @@ Directory Hierarchy:
- board Board dependent files
- common Misc architecture independent functions
- cpu CPU specific files
- 74xx_7xx Files specific to Motorola MPC74xx and 7xx CPUs
- arm720t Files specific to ARM 720 CPUs
- arm920t Files specific to ARM 920 CPUs
- arm925t Files specific to ARM 925 CPUs
- arm926ejs Files specific to ARM 926 CPUs
- at91rm9200 Files specific to Atmel AT91RM9200 CPUs
- i386 Files specific to i386 CPUs
- ixp Files specific to Intel XScale IXP CPUs
- mcf52x2 Files specific to Motorola ColdFire MCF52x2 CPUs
- mips Files specific to MIPS CPUs
- mpc5xx Files specific to Motorola MPC5xx CPUs
- mpc5xxx Files specific to Motorola MPC5xxx CPUs
- mpc8xx Files specific to Motorola MPC8xx CPUs
- mpc824x Files specific to Motorola MPC824x CPUs
- mpc8260 Files specific to Motorola MPC8260 CPUs
- mpc85xx Files specific to Motorola MPC85xx CPUs
- nios Files specific to Altera NIOS CPUs
- ppc4xx Files specific to IBM PowerPC 4xx CPUs
- pxa Files specific to Intel XScale PXA CPUs
- s3c44b0 Files specific to Samsung S3C44B0 CPUs
- sa1100 Files specific to Intel StrongARM SA1100 CPUs
- disk Code for disk drive partition handling
- doc Documentation (don't expect too much)
- drivers Commonly used device drivers
- dtt Digital Thermometer and Thermostat drivers
- examples Example code for standalone applications, etc.
- include Header Files
- disk Harddisk interface code
- lib_arm Files generic to ARM architecture
- lib_generic Files generic to all architectures
- lib_i386 Files generic to i386 architecture
- lib_m68k Files generic to m68k architecture
- lib_mips Files generic to MIPS architecture
- lib_nios Files generic to NIOS architecture
- lib_ppc Files generic to PowerPC architecture
- net Networking code
- ppc Files generic to PowerPC architecture
- post Power On Self Test
- post/arch Symlink to architecture specific Power On Self Test
- post/arch-ppc PowerPC architecture specific Power On Self Test
- post/cpu/mpc8260 MPC8260 CPU specific Power On Self Test
- post/cpu/mpc8xx MPC8xx CPU specific Power On Self Test
- rtc Real Time Clock drivers
- tools Tools to build S-Record or U-Boot images, etc.
- cpu/74xx_7xx Files specific to Motorola MPC74xx and 7xx CPUs
- cpu/arm925t Files specific to ARM 925 CPUs
- cpu/arm926ejs Files specific to ARM 926 CPUs
- cpu/mpc5xx Files specific to Motorola MPC5xx CPUs
- cpu/mpc8xx Files specific to Motorola MPC8xx CPUs
- cpu/mpc824x Files specific to Motorola MPC824x CPUs
- cpu/mpc8260 Files specific to Motorola MPC8260 CPU
- cpu/mpc85xx Files specific to Motorola MPC85xx CPUs
- cpu/ppc4xx Files specific to IBM 4xx CPUs
- board/LEOX/ Files specific to boards manufactured by The LEOX team
- board/LEOX/elpt860 Files specific to ELPT860 boards
- board/RPXClassic
Files specific to RPXClassic boards
- board/RPXlite Files specific to RPXlite boards
- board/at91rm9200dk Files specific to AT91RM9200DK boards
- board/c2mon Files specific to c2mon boards
- board/cmi Files specific to cmi boards
- board/cogent Files specific to Cogent boards
(need further configuration)
Files specific to CPCIISER4 boards
- board/cpu86 Files specific to CPU86 boards
- board/cray/ Files specific to boards manufactured by Cray
- board/cray/L1 Files specific to L1 boards
- board/cu824 Files specific to CU824 boards
- board/ebony Files specific to IBM Ebony board
- board/eric Files specific to ERIC boards
- board/esd/ Files specific to boards manufactured by ESD
- board/esd/adciop Files specific to ADCIOP boards
- board/esd/ar405 Files specific to AR405 boards
- board/esd/canbt Files specific to CANBT boards
- board/esd/cpci405 Files specific to CPCI405 boards
- board/esd/cpciiser4 Files specific to CPCIISER4 boards
- board/esd/common Common files for ESD boards
- board/esd/dasa_sim Files specific to DASA_SIM boards
- board/esd/du405 Files specific to DU405 boards
- board/esd/ocrtc Files specific to OCRTC boards
- board/esd/pci405 Files specific to PCI405 boards
- board/esteem192e
Files specific to ESTEEM192E boards
- board/etx094 Files specific to ETX_094 boards
- board/evb64260
Files specific to EVB64260 boards
- board/fads Files specific to FADS boards
- board/flagadm Files specific to FLAGADM boards
- board/gen860t Files specific to GEN860T and GEN860T_SC boards
- board/genietv Files specific to GENIETV boards
- board/gth Files specific to GTH boards
- board/hermes Files specific to HERMES boards
- board/hymod Files specific to HYMOD boards
- board/icu862 Files specific to ICU862 boards
- board/ip860 Files specific to IP860 boards
- board/iphase4539
Files specific to Interphase4539 boards
- board/ivm Files specific to IVMS8/IVML24 boards
- board/lantec Files specific to LANTEC boards
- board/lwmon Files specific to LWMON boards
- board/Marvell Files specific to Marvell development boards
- board/Marvell/db64360 Files specific to db64360 board
- board/Marvell/db64460 Files specific to db64460 board
- board/mbx8xx Files specific to MBX boards
- board/mpc8260ads
Files specific to MPC826xADS and PQ2FADS-ZU/VR boards
- board/mpc8540ads
Files specific to MPC8540ADS boards
- board/mpc8560ads
Files specific to MPC8560ADS boards
- board/mpl/ Files specific to boards manufactured by MPL
- board/mpl/common Common files for MPL boards
- board/mpl/pip405 Files specific to PIP405 boards
- board/mpl/mip405 Files specific to MIP405 boards
- board/mpl/vcma9 Files specific to VCMA9 boards
- board/musenki Files specific to MUSEKNI boards
- board/mvs1 Files specific to MVS1 boards
- board/nx823 Files specific to NX823 boards
- board/oxc Files specific to OXC boards
- board/omap1510inn
Files specific to OMAP 1510 Innovator boards
- board/omap1610inn
Files specific to OMAP 1610 Innovator and H2 boards
- board/pcippc2 Files specific to PCIPPC2/PCIPPC6 boards
- board/pm826 Files specific to PM826 boards
- board/ppmc8260
Files specific to PPMC8260 boards
- board/snmc/qs850 Files specific to QS850/823 boards
- board/snmc/qs860t Files specific to QS860T boards
- board/rpxsuper
Files specific to RPXsuper boards
- board/rsdproto
Files specific to RSDproto boards
- board/sandpoint
Files specific to Sandpoint boards
- board/sbc8260 Files specific to SBC8260 boards
- board/sacsng Files specific to SACSng boards
- board/siemens Files specific to boards manufactured by Siemens AG
- board/siemens/CCM Files specific to CCM boards
- board/siemens/IAD210 Files specific to IAD210 boards
- board/siemens/SCM Files specific to SCM boards
- board/siemens/pcu_e Files specific to PCU_E boards
- board/sixnet Files specific to SIXNET boards
- board/spd8xx Files specific to SPD8xxTS boards
- board/tqm8260 Files specific to TQM8260 boards
- board/tqm8xx Files specific to TQM8xxL boards
- board/w7o Files specific to W7O boards
- board/walnut405
Files specific to Walnut405 boards
- board/westel/ Files specific to boards manufactured by Westel Wireless
- board/westel/amx860 Files specific to AMX860 boards
- board/utx8245 Files specific to UTX8245 boards
- board/zpc1900 Files specific to Zephyr Engineering ZPC.1900 board
Software Configuration:
=======================
@@ -1412,9 +1322,9 @@ The following options need to be configured:
14 common/cmd_bootm.c No initial ramdisk, no multifile, continue.
15 common/cmd_bootm.c All preparation done, transferring control to OS
-30 lib_ppc/board.c Fatal error, hang the system
-31 post/post.c POST test failed, detected by post_output_backlog()
-32 post/post.c POST test failed, detected by post_run_single()
-30 lib_ppc/board.c Fatal error, hang the system
-31 post/post.c POST test failed, detected by post_output_backlog()
-32 post/post.c POST test failed, detected by post_run_single()
-1 common/cmd_doc.c Bad usage of "doc" command
-1 common/cmd_doc.c No boot device
+41
View File
@@ -0,0 +1,41 @@
#
# (C) Copyright 2001
# 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
SOBJS =
$(LIB): .depend $(OBJS) $(SOBJS)
$(AR) crv $@ $^
#########################################################################
.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
$(CC) -M $(CFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
sinclude .depend
#########################################################################
+31
View File
@@ -0,0 +1,31 @@
#
# (C) Copyright 2000, 2001
# 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
#
#
# Sandpoint boards
#
#TEXT_BASE = 0x00090000
TEXT_BASE = 0xFFF00000
PLATFORM_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
+292
View File
@@ -0,0 +1,292 @@
/*
* (C) Copyright 2000-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* (C) Copyright 2002
* Torsten Demke, FORCE Computers GmbH. torsten.demke@fci.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 <mpc824x.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <pci.h>
#include <ide.h>
#include "piix_pci.h"
#include "eXalion.h"
int checkboard (void)
{
ulong busfreq = get_bus_freq (0);
char buf[32];
printf ("Board: eXalion MPC824x - CHRP (MAP B)\n");
printf ("Built: %s at %s\n", __DATE__, __TIME__);
printf ("Local Bus: %s MHz\n", strmhz (buf, busfreq));
return 0;
}
int checkflash (void)
{
printf ("checkflash\n");
flash_init ();
return (0);
}
long int initdram (int board_type)
{
int i, cnt;
volatile uchar *base = CFG_SDRAM_BASE;
volatile ulong *addr;
ulong save[32];
ulong val, ret = 0;
for (i = 0, cnt = (CFG_MAX_RAM_SIZE / sizeof (long)) >> 1; cnt > 0;
cnt >>= 1) {
addr = (volatile ulong *) base + cnt;
save[i++] = *addr;
*addr = ~cnt;
}
addr = (volatile ulong *) base;
save[i] = *addr;
*addr = 0;
if (*addr != 0) {
*addr = save[i];
goto Done;
}
for (cnt = 1; cnt <= CFG_MAX_RAM_SIZE / sizeof (long); cnt <<= 1) {
addr = (volatile ulong *) base + cnt;
val = *addr;
*addr = save[--i];
if (val != ~cnt) {
ulong new_bank0_end = cnt * sizeof (long) - 1;
ulong mear1 = mpc824x_mpc107_getreg (MEAR1);
ulong emear1 = mpc824x_mpc107_getreg (EMEAR1);
mear1 = (mear1 & 0xFFFFFF00) |
((new_bank0_end & MICR_ADDR_MASK) >>
MICR_ADDR_SHIFT);
emear1 = (emear1 & 0xFFFFFF00) |
((new_bank0_end & MICR_ADDR_MASK) >>
MICR_EADDR_SHIFT);
mpc824x_mpc107_setreg (MEAR1, mear1);
mpc824x_mpc107_setreg (EMEAR1, emear1);
ret = cnt * sizeof (long);
goto Done;
}
}
ret = CFG_MAX_RAM_SIZE;
Done:
return ret;
}
int misc_init_r (void)
{
pci_dev_t bdf;
u32 val32;
u8 val8;
puts ("ISA: ");
bdf = pci_find_device (PIIX4_VENDOR_ID, PIIX4_ISA_DEV_ID, 0);
if (bdf == -1) {
puts ("Unable to find PIIX4 ISA bridge !\n");
hang ();
}
/* set device for normal ISA instead EIO */
pci_read_config_dword (bdf, PCI_CFG_PIIX4_GENCFG, &val32);
val32 |= 0x00000001;
pci_write_config_dword (bdf, PCI_CFG_PIIX4_GENCFG, val32);
printf ("PIIX4 ISA bridge (%d,%d,%d)\n", PCI_BUS (bdf),
PCI_DEV (bdf), PCI_FUNC (bdf));
puts ("ISA: ");
bdf = pci_find_device (PIIX4_VENDOR_ID, PIIX4_IDE_DEV_ID, 0);
if (bdf == -1) {
puts ("Unable to find PIIX4 IDE controller !\n");
hang ();
}
/* Init BMIBA register */
/* pci_read_config_dword(bdf, PCI_CFG_PIIX4_BMIBA, &val32); */
/* val32 |= 0x1000; */
/* pci_write_config_dword(bdf, PCI_CFG_PIIX4_BMIBA, val32); */
/* Enable BUS master and IO access */
val32 = PCI_COMMAND_MASTER | PCI_COMMAND_IO;
pci_write_config_dword (bdf, PCI_COMMAND, val32);
/* Set latency */
pci_read_config_byte (bdf, PCI_LATENCY_TIMER, &val8);
val8 = 0x40;
pci_write_config_byte (bdf, PCI_LATENCY_TIMER, val8);
/* Enable Primary ATA/IDE */
pci_read_config_dword (bdf, PCI_CFG_PIIX4_IDETIM, &val32);
/* val32 = 0xa307a307; */
val32 = 0x00008000;
pci_write_config_dword (bdf, PCI_CFG_PIIX4_IDETIM, val32);
printf ("PIIX4 IDE controller (%d,%d,%d)\n", PCI_BUS (bdf),
PCI_DEV (bdf), PCI_FUNC (bdf));
/* Try to get FAT working... */
/* fat_register_read(ide_read); */
return (0);
}
/*
* Show/Init PCI devices on the specified bus number.
*/
void pci_eXalion_fixup_irq (struct pci_controller *hose, pci_dev_t dev)
{
unsigned char line;
switch (PCI_DEV (dev)) {
case 16:
line = PCI_INT_A;
break;
case 17:
line = PCI_INT_B;
break;
case 18:
line = PCI_INT_C;
break;
case 19:
line = PCI_INT_D;
break;
#if defined (CONFIG_MPC8245)
case 20:
line = PCI_INT_A;
break;
case 21:
line = PCI_INT_B;
break;
case 22:
line = PCI_INT_NA;
break;
#endif
default:
line = PCI_INT_A;
break;
}
pci_hose_write_config_byte (hose, dev, PCI_INTERRUPT_LINE, line);
}
/*
* Initialize PCI Devices, report devices found.
*/
#ifndef CONFIG_PCI_PNP
#if defined (CONFIG_MPC8240)
static struct pci_config_table pci_eXalion_config_table[] = {
{
/* Intel 82559ER ethernet controller */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 18, 0x00,
pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
PCI_ENET0_MEMADDR,
PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER}},
{
/* Intel 82371AB PIIX4 PCI to ISA bridge */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x00,
pci_cfgfunc_config_device, {0,
0,
PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
{
/* Intel 82371AB PIIX4 IDE controller */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x01,
pci_cfgfunc_config_device, {0,
0,
PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
{}
};
#elif defined (CONFIG_MPC8245)
static struct pci_config_table pci_eXalion_config_table[] = {
{
/* Intel 82559ER ethernet controller */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 17, 0x00,
pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
PCI_ENET0_MEMADDR,
PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER}},
{
/* Intel 82559ER ethernet controller */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 18, 0x00,
pci_cfgfunc_config_device, {PCI_ENET1_IOADDR,
PCI_ENET1_MEMADDR,
PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER}},
{
/* Broadcom BCM5690 Gigabit switch */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 20, 0x00,
pci_cfgfunc_config_device, {PCI_ENET2_IOADDR,
PCI_ENET2_MEMADDR,
PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER}},
{
/* Broadcom BCM5690 Gigabit switch */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 21, 0x00,
pci_cfgfunc_config_device, {PCI_ENET3_IOADDR,
PCI_ENET3_MEMADDR,
PCI_COMMAND_MEMORY |
PCI_COMMAND_MASTER}},
{
/* Intel 82371AB PIIX4 PCI to ISA bridge */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 22, 0x00,
pci_cfgfunc_config_device, {0,
0,
PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
{
/* Intel 82371AB PIIX4 IDE controller */
PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x00, 22, 0x01,
pci_cfgfunc_config_device, {0,
0,
PCI_COMMAND_IO | PCI_COMMAND_MASTER}},
{}
};
#else
#error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240)
#endif
#endif /* #ifndef CONFIG_PCI_PNP */
struct pci_controller hose = {
#ifndef CONFIG_PCI_PNP
config_table:pci_eXalion_config_table,
fixup_irq:pci_eXalion_fixup_irq,
#endif
};
void pci_init_board (void)
{
pci_mpc824x_init (&hose);
}
+52
View File
@@ -0,0 +1,52 @@
/*
* (C) Copyright 2002
* Torsten Demke, FORCE Computers GmbH. torsten.demke@fci.com
*
* (C) Copyright 2000
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* (C) Copyright 2002
* James Dougherty (jfd@broadcom.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
*/
#ifndef __EXALION_H
#define __EXALION_H
/* IRQ settings */
#define PCI_INT_NA (0xff) /* PCI Intr. not used */
#define PCI_INT_A (0x09) /* PCI Intr. A Interrupt Request Line Nr. */
#define PCI_INT_B (0x0a) /* PCI Intr. B Interrupt Request Line Nr. */
#define PCI_INT_C (0x0b) /* PCI Intr. C Interrupt Request Line Nr. */
#define PCI_INT_D (0x0c) /* PCI Intr. D Interrupt Request Line Nr. */
#if defined (CPU_MPC8245)
#define LN_1_INT PCI_INT_B /* ethernet interrupt level */
#define LN_2_INT PCI_INT_C /* ethernet interrupt level */
#define BCM_1_INT PCI_INT_A /* BCM5690 interrupt level */
#define BCM_2_INT PCI_INT_B /* BCM5690 interrupt level */
#elif defined (CPU_MPC8240)
#define BCM_INT PCI_INT_B /* BCM5600 interrupt level */
#define LN_INT PCI_INT_C /* ethernet interrupt level */
#endif
#ifndef __ASSEMBLY__
#endif /* !__ASSEMBLY__ */
#endif /* __EXALION_H */
+172
View File
@@ -0,0 +1,172 @@
/*
* (C) Copyright 2000
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* (C) Copyright 2002
* Torsten Demke, FORCE Computers GmbH. torsten.demke@fci.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
*/
#ifndef _PIIX4_PCI_H
#define _PIIX4_PCI_H
#include <common.h>
#include <mpc824x.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <pci.h>
#define PIIX4_VENDOR_ID 0x8086
#define PIIX4_ISA_DEV_ID 0x7110
#define PIIX4_IDE_DEV_ID 0x7111
/* Function 0 ISA Bridge */
#define PCI_CFG_PIIX4_IORT 0x4C /* 8 bit ISA Recovery Timer Reg (default 0x4D) */
#define PCI_CFG_PIIX4_XBCS 0x4E /* 16 bit XBus Chip select reg (default 0x0003) */
#define PCI_CFG_PIIX4_PIRQC 0x60 /* PCI IRQ Route Register 4 x 8bit (default )*/
#define PCI_CFG_PIIX4_SERIRQ 0x64
#define PCI_CFG_PIIX4_TOM 0x69
#define PCI_CFG_PIIX4_MSTAT 0x6A
#define PCI_CFG_PIIX4_MBDMA 0x76
#define PCI_CFG_PIIX4_APICBS 0x80
#define PCI_CFG_PIIX4_DLC 0x82
#define PCI_CFG_PIIX4_PDMACFG 0x90
#define PCI_CFG_PIIX4_DDMABS 0x92
#define PCI_CFG_PIIX4_GENCFG 0xB0
#define PCI_CFG_PIIX4_RTCCFG 0xCB
/* IO Addresses */
#define PIIX4_ISA_DMA1_CH0BA 0x00
#define PIIX4_ISA_DMA1_CH0CA 0x01
#define PIIX4_ISA_DMA1_CH1BA 0x02
#define PIIX4_ISA_DMA1_CH1CA 0x03
#define PIIX4_ISA_DMA1_CH2BA 0x04
#define PIIX4_ISA_DMA1_CH2CA 0x05
#define PIIX4_ISA_DMA1_CH3BA 0x06
#define PIIX4_ISA_DMA1_CH3CA 0x07
#define PIIX4_ISA_DMA1_CMDST 0x08
#define PIIX4_ISA_DMA1_REQ 0x09
#define PIIX4_ISA_DMA1_WSBM 0x0A
#define PIIX4_ISA_DMA1_CH_MOD 0x0B
#define PIIX4_ISA_DMA1_CLR_PT 0x0C
#define PIIX4_ISA_DMA1_M_CLR 0x0D
#define PIIX4_ISA_DMA1_CLR_M 0x0E
#define PIIX4_ISA_DMA1_RWAMB 0x0F
#define PIIX4_ISA_DMA2_CH0BA 0xC0
#define PIIX4_ISA_DMA2_CH0CA 0xC1
#define PIIX4_ISA_DMA2_CH1BA 0xC2
#define PIIX4_ISA_DMA2_CH1CA 0xC3
#define PIIX4_ISA_DMA2_CH2BA 0xC4
#define PIIX4_ISA_DMA2_CH2CA 0xC5
#define PIIX4_ISA_DMA2_CH3BA 0xC6
#define PIIX4_ISA_DMA2_CH3CA 0xC7
#define PIIX4_ISA_DMA2_CMDST 0xD0
#define PIIX4_ISA_DMA2_REQ 0xD2
#define PIIX4_ISA_DMA2_WSBM 0xD4
#define PIIX4_ISA_DMA2_CH_MOD 0xD6
#define PIIX4_ISA_DMA2_CLR_PT 0xD8
#define PIIX4_ISA_DMA2_M_CLR 0xDA
#define PIIX4_ISA_DMA2_CLR_M 0xDC
#define PIIX4_ISA_DMA2_RWAMB 0xDE
#define PIIX4_ISA_INT1_ICW1 0x20
#define PIIX4_ISA_INT1_OCW2 0x20
#define PIIX4_ISA_INT1_OCW3 0x20
#define PIIX4_ISA_INT1_ICW2 0x21
#define PIIX4_ISA_INT1_ICW3 0x21
#define PIIX4_ISA_INT1_ICW4 0x21
#define PIIX4_ISA_INT1_OCW1 0x21
#define PIIX4_ISA_INT1_ELCR 0x4D0
#define PIIX4_ISA_INT2_ICW1 0xA0
#define PIIX4_ISA_INT2_OCW2 0xA0
#define PIIX4_ISA_INT2_OCW3 0xA0
#define PIIX4_ISA_INT2_ICW2 0xA1
#define PIIX4_ISA_INT2_ICW3 0xA1
#define PIIX4_ISA_INT2_ICW4 0xA1
#define PIIX4_ISA_INT2_OCW1 0xA1
#define PIIX4_ISA_INT2_IMR 0xA1 /* read only */
#define PIIX4_ISA_INT2_ELCR 0x4D1
#define PIIX4_ISA_TMR0_CNT_ST 0x40
#define PIIX4_ISA_TMR1_CNT_ST 0x41
#define PIIX4_ISA_TMR2_CNT_ST 0x42
#define PIIX4_ISA_TMR_TCW 0x43
#define PIIX4_ISA_RST_XBUS 0x60
#define PIIX4_ISA_NMI_CNT_ST 0x61
#define PIIX4_ISA_NMI_ENABLE 0x70
#define PIIX4_ISA_RTC_INDEX 0x70
#define PIIX4_ISA_RTC_DATA 0x71
#define PIIX4_ISA_RTCEXT_IND 0x70
#define PIIX4_ISA_RTCEXT_DATA 0x71
#define PIIX4_ISA_DMA1_CH2LPG 0x81
#define PIIX4_ISA_DMA1_CH3LPG 0x82
#define PIIX4_ISA_DMA1_CH1LPG 0x83
#define PIIX4_ISA_DMA1_CH0LPG 0x87
#define PIIX4_ISA_DMA2_CH2LPG 0x89
#define PIIX4_ISA_DMA2_CH3LPG 0x8A
#define PIIX4_ISA_DMA2_CH1LPG 0x8B
#define PIIX4_ISA_DMA2_LPGRFR 0x8F
#define PIIX4_ISA_PORT_92 0x92
#define PIIX4_ISA_APM_CONTRL 0xB2
#define PIIX4_ISA_APM_STATUS 0xB3
#define PIIX4_ISA_COCPU_ERROR 0xF0
/* Function 1 IDE Controller */
#define PCI_CFG_PIIX4_BMIBA 0x20
#define PCI_CFG_PIIX4_IDETIM 0x40
#define PCI_CFG_PIIX4_SIDETIM 0x44
#define PCI_CFG_PIIX4_UDMACTL 0x48
#define PCI_CFG_PIIX4_UDMATIM 0x4A
/* Function 2 USB Controller */
#define PCI_CFG_PIIX4_SBRNUM 0x60
#define PCI_CFG_PIIX4_LEGSUP 0xC0
/* Function 3 Power Management */
#define PCI_CFG_PIIX4_PMAB 0x40
#define PCI_CFG_PIIX4_CNTA 0x44
#define PCI_CFG_PIIX4_CNTB 0x48
#define PCI_CFG_PIIX4_GPICTL 0x4C
#define PCI_CFG_PIIX4_DEVRESD 0x50
#define PCI_CFG_PIIX4_DEVACTA 0x54
#define PCI_CFG_PIIX4_DEVACTB 0x58
#define PCI_CFG_PIIX4_DEVRESA 0x5C
#define PCI_CFG_PIIX4_DEVRESB 0x60
#define PCI_CFG_PIIX4_DEVRESC 0x64
#define PCI_CFG_PIIX4_DEVRESE 0x68
#define PCI_CFG_PIIX4_DEVRESF 0x6C
#define PCI_CFG_PIIX4_DEVRESG 0x70
#define PCI_CFG_PIIX4_DEVRESH 0x74
#define PCI_CFG_PIIX4_DEVRESI 0x78
#define PCI_CFG_PIIX4_PMMISC 0x80
#define PCI_CFG_PIIX4_SMBBA 0x90
#endif /* _PIIX4_PCI_H */
+133
View File
@@ -0,0 +1,133 @@
/*
* (C) Copyright 2001
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
OUTPUT_ARCH(powerpc)
SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = + SIZEOF_HEADERS;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.text : { *(.rel.text) }
.rela.text : { *(.rela.text) }
.rel.data : { *(.rel.data) }
.rela.data : { *(.rela.data) }
.rel.rodata : { *(.rel.rodata) }
.rela.rodata : { *(.rela.rodata) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) }
.plt : { *(.plt) }
.text :
{
cpu/mpc824x/start.o (.text)
lib_ppc/board.o (.text)
lib_ppc/ppcstring.o (.text)
lib_generic/vsprintf.o (.text)
lib_generic/crc32.o (.text)
lib_generic/zlib.o (.text)
. = DEFINED(env_offset) ? env_offset : .;
common/environment.o (.text)
*(.text)
*(.fixup)
*(.got1)
. = ALIGN(16);
*(.rodata)
*(.rodata1)
*(.rodata.str1.4)
}
.fini : { *(.fini) } =0
.ctors : { *(.ctors) }
.dtors : { *(.dtors) }
/* Read-write section, merged into data segment: */
. = (. + 0x0FFF) & 0xFFFFF000;
_erotext = .;
PROVIDE (erotext = .);
.reloc :
{
*(.got)
_GOT2_TABLE_ = .;
*(.got2)
_FIXUP_TABLE_ = .;
*(.fixup)
}
__got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
__fixup_entries = (. - _FIXUP_TABLE_) >> 2;
.data :
{
*(.data)
*(.data1)
*(.sdata)
*(.sdata2)
*(.dynamic)
CONSTRUCTORS
}
_edata = .;
PROVIDE (edata = .);
__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(4096);
__init_begin = .;
.text.init : { *(.text.init) }
.data.init : { *(.data.init) }
. = ALIGN(4096);
__init_end = .;
__bss_start = .;
.bss :
{
*(.sbss) *(.scommon)
*(.dynbss)
*(.bss)
*(COMMON)
}
_end = . ;
PROVIDE (end = .);
}
+6 -6
View File
@@ -54,16 +54,16 @@ static void sdram_start (int hi_addr)
*(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0002 | hi_addr_bit;
/* set mode register */
#if defined(CONFIG_MPC5200)
*(vu_long *)MPC5XXX_SDRAM_MODE = 0x408d0000;
*(vu_long *)MPC5XXX_SDRAM_MODE = 0x00cd0000;
#elif defined(CONFIG_MGT5100)
*(vu_long *)MPC5XXX_SDRAM_MODE = 0x008d0000;
#endif
/* precharge all banks */
*(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0002 | hi_addr_bit;
/* auto refresh */
*(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0004 | hi_addr_bit;
/* auto refresh */
*(vu_long *)MPC5XXX_SDRAM_CTRL = 0xd04f0004 | hi_addr_bit;
/* set mode register */
*(vu_long *)MPC5XXX_SDRAM_MODE = 0x008d0000;
*(vu_long *)MPC5XXX_SDRAM_MODE = 0x00cd0000;
/* normal operation */
*(vu_long *)MPC5XXX_SDRAM_CTRL = 0x504f0000 | hi_addr_bit;
#endif
@@ -93,8 +93,8 @@ long int initdram (int board_type)
*(vu_long *)MPC5XXX_CDM_PORCFG = 0x10000000;
#else
/* setup config registers */
*(vu_long *)MPC5XXX_SDRAM_CONFIG1 = 0xc2233a00;
*(vu_long *)MPC5XXX_SDRAM_CONFIG2 = 0x88b70004;
*(vu_long *)MPC5XXX_SDRAM_CONFIG1 = 0xd2322800;
*(vu_long *)MPC5XXX_SDRAM_CONFIG2 = 0x8ad70000;
#endif
#elif defined(CONFIG_MGT5100)
+47
View File
@@ -0,0 +1,47 @@
#
# (C) Copyright 2000, 2001, 2002
# 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 := ns9750dev.o flash.o led.o
SOBJS := platform.o
$(LIB): $(OBJS) $(SOBJS)
$(AR) crv $@ $(OBJS) $(SOBJS)
clean:
rm -f $(SOBJS) $(OBJS)
distclean: clean
rm -f $(LIB) core *.bak .depend
#########################################################################
.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
-include .depend
#########################################################################
+16
View File
@@ -0,0 +1,16 @@
#######################################################################
#
# Copyright (C) 2004 by FS Forth-Systeme GmbH.
# Markus Pietrek <mpietrek@fsforth.de>
#
# @TODO
# Linux-Kernel is expected to be at 0000'8000, entry 0000'8000
# optionally with a ramdisk at 0080'0000
#
# we load ourself to 0078'0000
#
# download area is 0060'0000
#
TEXT_BASE = 0x00780000
+477
View File
@@ -0,0 +1,477 @@
/*
* (C) Copyright 2001
* Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
*
* (C) Copyright 2001
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* (C) Copyright 2003
* Texas Instruments, <www.ti.com>
* Kshitij Gupta <Kshitij@ti.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 <linux/byteorder/swab.h>
#define PHYS_FLASH_SECT_SIZE 0x00020000 /* 256 KB sectors (x2) */
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
/* Board support for 1 or 2 flash devices */
#undef FLASH_PORT_WIDTH32
#define FLASH_PORT_WIDTH16
#ifdef FLASH_PORT_WIDTH16
#define FLASH_PORT_WIDTH ushort
#define FLASH_PORT_WIDTHV vu_short
#define SWAP(x) __swab16(x)
#else
#define FLASH_PORT_WIDTH ulong
#define FLASH_PORT_WIDTHV vu_long
#define SWAP(x) __swab32(x)
#endif
#define FPW FLASH_PORT_WIDTH
#define FPWV FLASH_PORT_WIDTHV
#define mb() __asm__ __volatile__ ("" : : : "memory")
/* Flash Organization Structure */
typedef struct OrgDef {
unsigned int sector_number;
unsigned int sector_size;
} OrgDef;
/* Flash Organizations */
OrgDef OrgIntel_28F256L18T[] = {
{4, 32 * 1024}, /* 4 * 32kBytes sectors */
{255, 128 * 1024}, /* 255 * 128kBytes sectors */
};
/*-----------------------------------------------------------------------
* Functions
*/
unsigned long flash_init (void);
static ulong flash_get_size (FPW * addr, flash_info_t * info);
static int write_data (flash_info_t * info, ulong dest, FPW data);
static void flash_get_offsets (ulong base, flash_info_t * info);
void inline spin_wheel (void);
void flash_print_info (flash_info_t * info);
void flash_unprotect_sectors (FPWV * addr);
int flash_erase (flash_info_t * info, int s_first, int s_last);
int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt);
/*-----------------------------------------------------------------------
*/
unsigned long flash_init (void)
{
int i;
ulong size = 0;
for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
switch (i) {
case 0:
flash_get_size ((FPW *) PHYS_FLASH_1, &flash_info[i]);
flash_get_offsets (PHYS_FLASH_1, &flash_info[i]);
break;
default:
panic ("configured too many flash banks!\n");
break;
}
size += flash_info[i].size;
}
/* Protect monitor and environment sectors
*/
flash_protect (FLAG_PROTECT_SET,
CFG_FLASH_BASE,
CFG_FLASH_BASE + monitor_flash_len - 1, &flash_info[0]);
flash_protect (FLAG_PROTECT_SET,
CFG_ENV_ADDR,
CFG_ENV_ADDR + CFG_ENV_SIZE - 1, &flash_info[0]);
return size;
}
/*-----------------------------------------------------------------------
*/
static void flash_get_offsets (ulong base, flash_info_t * info)
{
int i;
OrgDef *pOrgDef;
pOrgDef = OrgIntel_28F256L18T;
if (info->flash_id == FLASH_UNKNOWN) {
return;
}
if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL) {
for (i = 0; i < info->sector_count; i++) {
if (i > 255) {
info->start[i] = base + (i * 0x8000);
info->protect[i] = 0;
} else {
info->start[i] = base +
(i * PHYS_FLASH_SECT_SIZE);
info->protect[i] = 0;
}
}
}
}
/*-----------------------------------------------------------------------
*/
void flash_print_info (flash_info_t * info)
{
int i;
if (info->flash_id == FLASH_UNKNOWN) {
printf ("missing or unknown FLASH type\n");
return;
}
switch (info->flash_id & FLASH_VENDMASK) {
case FLASH_MAN_INTEL:
printf ("INTEL ");
break;
default:
printf ("Unknown Vendor ");
break;
}
switch (info->flash_id & FLASH_TYPEMASK) {
case FLASH_28F256L18T:
printf ("FLASH 28F256L18T\n");
break;
default:
printf ("Unknown Chip Type\n");
break;
}
printf (" Size: %ld MB in %d Sectors\n",
info->size >> 20, info->sector_count);
printf (" Sector Start Addresses:");
for (i = 0; i < info->sector_count; ++i) {
if ((i % 5) == 0)
printf ("\n ");
printf (" %08lX%s",
info->start[i], info->protect[i] ? " (RO)" : " ");
}
printf ("\n");
return;
}
/*
* The following code cannot be run from FLASH!
*/
static ulong flash_get_size (FPW * addr, flash_info_t * info)
{
volatile FPW value;
/* Write auto select command: read Manufacturer ID */
addr[0x5555] = (FPW) 0x00AA00AA;
addr[0x2AAA] = (FPW) 0x00550055;
addr[0x5555] = (FPW) 0x00900090;
mb ();
value = addr[0];
switch (value) {
case (FPW) INTEL_MANUFACT:
info->flash_id = FLASH_MAN_INTEL;
break;
default:
info->flash_id = FLASH_UNKNOWN;
info->sector_count = 0;
info->size = 0;
addr[0] = (FPW) 0x00FF00FF; /* restore read mode */
return (0); /* no or unknown flash */
}
mb ();
value = addr[1]; /* device ID */
switch (value) {
case (FPW) (INTEL_ID_28F256L18T):
info->flash_id += FLASH_28F256L18T;
info->sector_count = 259;
info->size = 0x02000000;
break; /* => 32 MB */
default:
info->flash_id = FLASH_UNKNOWN;
break;
}
if (info->sector_count > CFG_MAX_FLASH_SECT) {
printf ("** ERROR: sector count %d > max (%d) **\n",
info->sector_count, CFG_MAX_FLASH_SECT);
info->sector_count = CFG_MAX_FLASH_SECT;
}
addr[0] = (FPW) 0x00FF00FF; /* restore read mode */
return (info->size);
}
/* unprotects a sector for write and erase
* on some intel parts, this unprotects the entire chip, but it
* wont hurt to call this additional times per sector...
*/
void flash_unprotect_sectors (FPWV * addr)
{
#define PD_FINTEL_WSMS_READY_MASK 0x0080
*addr = (FPW) 0x00500050; /* clear status register */
/* this sends the clear lock bit command */
*addr = (FPW) 0x00600060;
*addr = (FPW) 0x00D000D0;
}
/*-----------------------------------------------------------------------
*/
int flash_erase (flash_info_t * info, int s_first, int s_last)
{
int flag, prot, sect;
ulong type, start, last;
int rcode = 0;
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;
}
type = (info->flash_id & FLASH_VENDMASK);
if ((type != FLASH_MAN_INTEL)) {
printf ("Can't erase unknown flash type %08lx - aborted\n",
info->flash_id);
return 1;
}
prot = 0;
for (sect = s_first; sect <= s_last; ++sect) {
if (info->protect[sect]) {
prot++;
}
}
if (prot) {
printf ("- Warning: %d protected sectors will not be erased!\n",
prot);
} else {
printf ("\n");
}
start = get_timer (0);
last = start;
/* 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 */
FPWV *addr = (FPWV *) (info->start[sect]);
FPW status;
printf ("Erasing sector %2d ... ", sect);
flash_unprotect_sectors (addr);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
*addr = (FPW) 0x00500050;/* clear status register */
*addr = (FPW) 0x00200020;/* erase setup */
*addr = (FPW) 0x00D000D0;/* erase confirm */
while (((status =
*addr) & (FPW) 0x00800080) !=
(FPW) 0x00800080) {
if (get_timer_masked () >
CFG_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
/* suspend erase */
*addr = (FPW) 0x00B000B0;
/* reset to read mode */
*addr = (FPW) 0x00FF00FF;
rcode = 1;
break;
}
}
/* clear status register cmd. */
*addr = (FPW) 0x00500050;
*addr = (FPW) 0x00FF00FF;/* resest to read mode */
printf (" done\n");
}
}
return rcode;
}
/*-----------------------------------------------------------------------
* Copy memory to flash, returns:
* 0 - OK
* 1 - write timeout
* 2 - Flash not erased
* 4 - Flash not identified
*/
int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
{
ulong cp, wp;
FPW data;
int count, i, l, rc, port_width;
if (info->flash_id == FLASH_UNKNOWN) {
return 4;
}
/* get lower word aligned address */
#ifdef FLASH_PORT_WIDTH16
wp = (addr & ~1);
port_width = 2;
#else
wp = (addr & ~3);
port_width = 4;
#endif
/*
* 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 < port_width && cnt > 0; ++i) {
data = (data << 8) | *src++;
--cnt;
++cp;
}
for (; cnt == 0 && i < port_width; ++i, ++cp) {
data = (data << 8) | (*(uchar *) cp);
}
if ((rc = write_data (info, wp, SWAP (data))) != 0) {
return (rc);
}
wp += port_width;
}
/*
* handle word aligned part
*/
count = 0;
while (cnt >= port_width) {
data = 0;
for (i = 0; i < port_width; ++i) {
data = (data << 8) | *src++;
}
if ((rc = write_data (info, wp, SWAP (data))) != 0) {
return (rc);
}
wp += port_width;
cnt -= port_width;
if (count++ > 0x800) {
spin_wheel ();
count = 0;
}
}
if (cnt == 0) {
return (0);
}
/*
* handle unaligned tail bytes
*/
data = 0;
for (i = 0, cp = wp; i < port_width && cnt > 0; ++i, ++cp) {
data = (data << 8) | *src++;
--cnt;
}
for (; i < port_width; ++i, ++cp) {
data = (data << 8) | (*(uchar *) cp);
}
return (write_data (info, wp, SWAP (data)));
}
/*-----------------------------------------------------------------------
* Write a word or halfword to Flash, returns:
* 0 - OK
* 1 - write timeout
* 2 - Flash not erased
*/
static int write_data (flash_info_t * info, ulong dest, FPW data)
{
FPWV *addr = (FPWV *) dest;
ulong status;
int flag;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
printf ("not erased at %08lx (%x)\n", (ulong) addr, *addr);
return (2);
}
flash_unprotect_sectors (addr);
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts ();
*addr = (FPW) 0x00400040; /* write setup */
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
/* wait while polling the status register */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
if (get_timer_masked () > CFG_FLASH_WRITE_TOUT) {
*addr = (FPW) 0x00FF00FF; /* restore read mode */
return (1);
}
}
*addr = (FPW) 0x00FF00FF; /* restore read mode */
return (0);
}
void inline spin_wheel (void)
{
static int p = 0;
static char w[] = "\\/-";
printf ("\010%c", w[p]);
(++p == 3) ? (p = 0) : 0;
}
+46
View File
@@ -0,0 +1,46 @@
/***********************************************************************
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
*
* $Id: led.c,v 1.1 2004/02/16 10:37:20 mpietrek Exp $
* @Author: Markus Pietrek
* @Descr: Defines helper functions for toggeling LEDs
* @Usage:
* @References: [1]
*
* 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
*
***********************************************************************/
#ifdef CONFIG_STATUS_LED
#include <ns9750_bbus.h>
static inline void __led_init( led_id_t mask, int state )
{
XXXX;
}
static inline void __led_toggle( led_id_t mask )
{
}
static inline void __led_set( led_id_t mask, int state )
{
}
#endif /* CONFIG_STATUS_LED */
+127
View File
@@ -0,0 +1,127 @@
/*
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
*
* (C) Copyright 2002
* David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
*
* (C) Copyright 2003
* Texas Instruments, <www.ti.com>
* Kshitij Gupta <Kshitij@ti.com>
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
* Markus Pietrek <mpietrek@fsforth.de>
* derived from omap1610innovator.c
* @References: [1] NS9750 Hardware Reference/December 2003
*
* 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>
#if defined(CONFIG_NS9750DEV)
# include <./configs/ns9750dev.h>
# include <./ns9750_bbus.h>
#endif
void flash__init( void );
void ether__init( void );
static inline void delay( unsigned long loops )
{
__asm__ volatile ("1:\n"
"subs %0, %1, #1\n"
"bne 1b":"=r" (loops):"0" (loops));
}
/***********************************************************************
* @Function: board_init
* @Return: 0
* @Descr: Enables BBUS modules and other devices
***********************************************************************/
int board_init( void )
{
DECLARE_GLOBAL_DATA_PTR;
/* Active BBUS modules */
*get_bbus_reg_addr( NS9750_BBUS_MASTER_RESET ) = 0;
#warning TODO check numbers
/* arch number of OMAP 1510-Board */
/* to be changed for OMAP 1610 Board */
gd->bd->bi_arch_number = 234;
/* adress of boot parameters */
gd->bd->bi_boot_params = 0x10000100;
/* this speeds up your boot a quite a bit. However to make it
* work, you need make sure your kernel startup flush bug is fixed.
* ... rkw ...
*/
icache_enable();
flash__init();
ether__init();
return 0;
}
int misc_init_r (void)
{
/* currently empty */
return (0);
}
/******************************
Routine:
Description:
******************************/
void flash__init (void)
{
}
/*************************************************************
Routine:ether__init
Description: take the Ethernet controller out of reset and wait
for the EEPROM load to complete.
*************************************************************/
void ether__init (void)
{
}
/******************************
Routine:
Description:
******************************/
int dram_init (void)
{
DECLARE_GLOBAL_DATA_PTR;
gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
#if CONFIG_NR_DRAM_BANKS > 1
gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
#endif
return 0;
}
+298
View File
@@ -0,0 +1,298 @@
/*
* Board specific setup info
*
* (C) Copyright 2003
* Texas Instruments, <www.ti.com>
* Kshitij Gupta <Kshitij@ti.com>
*
* Modified for the NS9750 DevBoard by
* (C) Copyright 2004 by FS Forth-Systeme GmbH.
* Markus Pietrek <mpietrek@fsforth.de>
* @References: [1] NS9750 Hardware Reference/December 2003
* [2] ns9750_a.cmd from MAJIC configuration
*
* 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 <config.h>
#include <version.h>
#if defined(CONFIG_NS9750DEV)
# ifdef CONFIG_INIT_CRITICAL
# include <./ns9750_sys.h>
# include <./ns9750_mem.h>
# endif
#endif
/***********************************************************************
* @Function: write_register_block
* @Return: nothing
* @Descr: Copies the register block of register_offset:register value to
* the registers at base r0. The block is assumed to start in RAM at r1
* and end at r2. The linked RAM base address of U-Boot is assumed to be
* in r5 while the ROM base address we are running from is r6
* Uses r3 and r4 as tempory registers
***********************************************************************/
.macro write_register_block
@@ map the addresses to high memory
sub r1, r1, r5
add r1, r1, r6
sub r2, r2, r5
add r2, r2, r6
@@ copy all
1:
@@ Write register/value pair starting at [r1] to register base r0
ldr r3, [r1], #4
ldr r4, [r1], #4
str r4, [r0,r3]
cmp r1, r2
blt 1b
.endm
_TEXT_BASE:
.word TEXT_BASE @ sdram load addr from config.mk
_PHYS_FLASH:
.word PHYS_FLASH_1 @ real flash address (without mirroring)
_CAS_LATENCY:
.word 0x00022000 @ for CAS2 latency
#ifdef CONFIG_INIT_CRITICAL
.globl platformsetup
platformsetup:
/* U-Boot may be linked to RAM at 0x780000. But this code will run in
flash from 0x0. But in order to enable RAM we have to disable the
mirror bit, therefore we have to jump to our real flash address
beginning at PHYS_FLASH_1 (CS4 Base). Therefore,
_run_at_real_flash_address may be 0x500003b0 while be linked to
0x7803b0. So we must modify our linked addresses */
@@ branch to high memory address, away from 0x0
ldr r5, _TEXT_BASE
ldr r6, _PHYS_FLASH
ldr r0, =_run_at_real_flash_address
sub r0, r0, r5
add r0, r0, r6
mov pc, r0
nop @ for pipelining
_run_at_real_flash_address:
@@ now we are running > PHYS_FLASH_1, safe to enable memory controller
@@ Write Memory Configuration Registers
ldr r0, _NS9750_MEM_MODULE_BASE
ldr r1, =_MEM_CONFIG_START
ldr r2, =_MEM_CONFIG_END
write_register_block
@@ Give SDRAM some time to settle
@@ @TODO. According to [2] it should be 2 AHB cycles. Check
ldr r1, =0x50
_sdram_settle:
subs r1, r1, #1
bne _sdram_settle
_enable_mappings:
@@ Enable SDRAM Mode
ldr r1, =_MEM_MODE_START
ldr r2, =_MEM_MODE_END
write_register_block
ldr r3, _CAS_LATENCY @ perform one read from SDRAM
ldr r3, [r3]
@@ Enable SDRAM and memory mappings
ldr r1, =_MEM_ENABLE_START
ldr r2, =_MEM_ENABLE_END
write_register_block
@@ Activate AHB monitor
ldr r0, =NS9750_SYS_MODULE_BASE
ldr r1, =_AHB_MONITOR_START
ldr r2, =_AHB_MONITOR_END
write_register_block
_relocate_lr:
/* lr and ip (from cpu_init_crit) are still based on 0x0, relocate it to
PHYS_FLASH. */
mov r1, ip
add r1, r1, r6
mov ip, r1
mov r1, lr
add r1, r1, r6
mov lr, r1
@@ back to arch calling code
mov pc, lr
.ltorg
_NS9750_MEM_MODULE_BASE:
.word NS9750_MEM_MODULE_BASE
_MEM_CONFIG_START:
/* Table of 2 32bit entries. First word is register address offset
relative to NS9750_MEM_MODULE_BASE, second one is value. They are
written in order of appearance */
@@ Register values taken from [2]
.word NS9750_MEM_CTRL
.word NS9750_MEM_CTRL_E
.word NS9750_MEM_DYN_REFRESH
.word (0x6 & NS9750_MEM_DYN_REFRESH_MA)
.word NS9750_MEM_DYN_READ_CFG
.word (0x1 & NS9750_MEM_DYN_READ_CFG_MA)
.word NS9750_MEM_DYN_TRP
.word (0x1 & NS9750_MEM_DYN_TRP_MA)
.word NS9750_MEM_DYN_TRAS
.word (0x4 & NS9750_MEM_DYN_TRAS_MA)
.word NS9750_MEM_DYN_TAPR
.word (0x1 & NS9750_MEM_DYN_TRAS_MA)
.word NS9750_MEM_DYN_TDAL
.word (0x5 & NS9750_MEM_DYN_TDAL_MA)
.word NS9750_MEM_DYN_TWR
.word (0x1 & NS9750_MEM_DYN_TWR_MA)
.word NS9750_MEM_DYN_TRC
.word (0x6 & NS9750_MEM_DYN_TRC_MA)
.word NS9750_MEM_DYN_TRFC
.word (0x6 & NS9750_MEM_DYN_TRFC_MA)
.word NS9750_MEM_DYN_TRRD
.word (0x1 & NS9750_MEM_DYN_TRRD_MA)
.word NS9750_MEM_DYN_TMRD
.word (0x1 & NS9750_MEM_DYN_TMRD_MA)
@@ CS 4
.word NS9750_MEM_DYN_CFG(0)
.word (NS9750_MEM_DYN_CFG_AM | \
(0x280 & NS9750_MEM_DYN_CFG_AM_MA))
.word NS9750_MEM_DYN_RAS_CAS(0)
.word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
(0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
@@ CS 5
.word NS9750_MEM_DYN_CFG(1)
.word (NS9750_MEM_DYN_CFG_AM | \
(0x280 & NS9750_MEM_DYN_CFG_AM_MA))
.word NS9750_MEM_DYN_RAS_CAS(1)
.word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
(0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
@@ CS 6
.word NS9750_MEM_DYN_CFG(2)
.word (NS9750_MEM_DYN_CFG_AM | \
(0x280 & NS9750_MEM_DYN_CFG_AM_MA))
.word NS9750_MEM_DYN_RAS_CAS(2)
.word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
(0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
@@ CS 7
.word NS9750_MEM_DYN_CFG(3)
.word (NS9750_MEM_DYN_CFG_AM | \
(0x280 & NS9750_MEM_DYN_CFG_AM_MA))
.word NS9750_MEM_DYN_RAS_CAS(3)
.word ((0x200 & NS9750_MEM_DYN_RAS_CAS_CAS_MA) | \
(0x03 & NS9750_MEM_DYN_RAS_CAS_RAS_MA))
.word NS9750_MEM_DYN_CTRL
.word (NS9750_MEM_DYN_CTRL_I_PALL | \
NS9750_MEM_DYN_CTRL_SR | \
NS9750_MEM_DYN_CTRL_CE )
.word NS9750_MEM_DYN_REFRESH
.word (0x1 & NS9750_MEM_DYN_REFRESH_MA)
@@ No further register settings after refresh
_MEM_CONFIG_END:
_MEM_MODE_START:
.word NS9750_MEM_DYN_REFRESH
.word (0x30 & NS9750_MEM_DYN_REFRESH_MA)
.word NS9750_MEM_DYN_CTRL
.word (NS9750_MEM_DYN_CTRL_I_MODE | \
NS9750_MEM_DYN_CTRL_SR | \
NS9750_MEM_DYN_CTRL_CE )
_MEM_MODE_END:
_MEM_ENABLE_START:
.word NS9750_MEM_DYN_CTRL
.word (NS9750_MEM_DYN_CTRL_I_NORMAL | \
NS9750_MEM_DYN_CTRL_SR | \
NS9750_MEM_DYN_CTRL_CE )
@@ CS 4
.word NS9750_MEM_DYN_CFG(0)
.word (NS9750_MEM_DYN_CFG_BDMC | \
NS9750_MEM_DYN_CFG_AM | \
(0x280 & NS9750_MEM_DYN_CFG_AM_MA))
@@ CS 5
.word NS9750_MEM_DYN_CFG(1)
.word (NS9750_MEM_DYN_CFG_BDMC | \
NS9750_MEM_DYN_CFG_AM | \
(0x280 & NS9750_MEM_DYN_CFG_AM_MA))
@@ CS 6
.word NS9750_MEM_DYN_CFG(2)
.word (NS9750_MEM_DYN_CFG_BDMC | \
NS9750_MEM_DYN_CFG_AM | \
(0x280 & NS9750_MEM_DYN_CFG_AM_MA))
@@ CS 7
.word NS9750_MEM_DYN_CFG(3)
.word (NS9750_MEM_DYN_CFG_BDMC | \
NS9750_MEM_DYN_CFG_AM | \
(0x280 & NS9750_MEM_DYN_CFG_AM_MA))
_MEM_ENABLE_END:
_AHB_MONITOR_START:
.word NS9750_SYS_AHB_TIMEOUT
.word 0x01000100 @ @TODO not calculated yet
.word NS9750_SYS_AHB_MON
.word (NS9750_SYS_AHB_MON_BMTC_GEN_IRQ | \
NS9750_SYS_AHB_MON_BATC_GEN_IRQ)
_AHB_MONITOR_END:
#endif /* CONFIG_INIT_CRITICAL */
+58
View File
@@ -0,0 +1,58 @@
/*
* (C) Copyright 2002
* Gary Jennejohn, DENX Software Engineering, <gj@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_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
/*OUTPUT_FORMAT("elf32-arm", "elf32-arm", "elf32-arm")*/
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x00000000;
. = ALIGN(4);
.text :
{
cpu/arm926ejs/start.o (.text)
*(.text)
}
. = ALIGN(4);
.rodata : { *(.rodata) }
. = ALIGN(4);
.data : { *(.data) }
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
_end = . ;
}
+9
View File
@@ -41,6 +41,15 @@ _TEXT_BASE:
platformsetup:
/*------------------------------------------------------*
*mask all IRQs by setting all bits in the INTMR default*
*------------------------------------------------------*/
mov r1, #0xffffffff
ldr r0, =REG_IHL1_MIR
str r1, [r0]
ldr r0, =REG_IHL2_MIR
str r1, [r0]
/*------------------------------------------------------*
* Set up ARM CLM registers (IDLECT1) *
*------------------------------------------------------*/
+47
View File
@@ -0,0 +1,47 @@
#
# (C) Copyright 2004
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
include $(TOPDIR)/config.mk
LIB = lib$(BOARD).a
OBJS := sx1.o flash.o
SOBJS := platform.o
$(LIB): $(OBJS) $(SOBJS)
$(AR) crv $@ $^
clean:
rm -f $(SOBJS) $(OBJS)
distclean: clean
rm -f $(LIB) core *.bak .depend
#########################################################################
.depend: Makefile $(SOBJS:.o=.S) $(OBJS:.o=.c)
$(CC) -M $(CPPFLAGS) $(SOBJS:.o=.S) $(OBJS:.o=.c) > $@
-include .depend
#########################################################################
+19
View File
@@ -0,0 +1,19 @@
#
# (C) Copyright 2004
# Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
#
# SX1 board with OMAP1510 (ARM925T) cpu
# see http://www.ti.com/ for more information on Texas Insturments
#
# SX1 has 1 bank of 256 MB SDRAM
# Physical Address:
# 1000'0000 to 2000'0000
#
#
# Linux-Kernel is expected to be at 1000'8000, entry 1000'8000 (mem base + reserved)
#
# we load ourself to 1108'0000
#
#
TEXT_BASE = 0x11080000
+436
View File
@@ -0,0 +1,436 @@
/*
* (C) Copyright 2001
* Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
*
* (C) Copyright 2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <linux/byteorder/swab.h>
#define PHYS_FLASH_SECT_SIZE 0x00020000 /* 256 KB sectors (x2) */
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
/* Board support for 1 or 2 flash devices */
#undef FLASH_PORT_WIDTH32
#define FLASH_PORT_WIDTH16
#ifdef FLASH_PORT_WIDTH16
#define FLASH_PORT_WIDTH ushort
#define FLASH_PORT_WIDTHV vu_short
#define SWAP(x) __swab16(x)
#else
#define FLASH_PORT_WIDTH ulong
#define FLASH_PORT_WIDTHV vu_long
#define SWAP(x) __swab32(x)
#endif
#define FPW FLASH_PORT_WIDTH
#define FPWV FLASH_PORT_WIDTHV
#define mb() __asm__ __volatile__ ("" : : : "memory")
/*-----------------------------------------------------------------------
* Functions
*/
static ulong flash_get_size (FPW * addr, flash_info_t * info);
static int write_data (flash_info_t * info, ulong dest, FPW data);
static void flash_get_offsets (ulong base, flash_info_t * info);
void inline spin_wheel (void);
/*-----------------------------------------------------------------------
*/
unsigned long flash_init (void)
{
int i;
ulong size = 0;
for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
switch (i) {
case 0:
flash_get_size ((FPW *) PHYS_FLASH_1, &flash_info[i]);
flash_get_offsets (PHYS_FLASH_1, &flash_info[i]);
break;
case 1:
flash_get_size ((FPW *) PHYS_FLASH_2, &flash_info[i]);
flash_get_offsets (PHYS_FLASH_2, &flash_info[i]);
break;
default:
panic ("configured too many flash banks!\n");
break;
}
size += flash_info[i].size;
}
/* Protect monitor and environment sectors
*/
flash_protect ( FLAG_PROTECT_SET,
CFG_FLASH_BASE,
CFG_FLASH_BASE + monitor_flash_len - 1,
&flash_info[0]);
flash_protect ( FLAG_PROTECT_SET,
CFG_ENV_ADDR,
CFG_ENV_ADDR + CFG_ENV_SIZE - 1,
&flash_info[0]);
return size;
}
/*-----------------------------------------------------------------------
*/
static void flash_get_offsets (ulong base, flash_info_t * info)
{
int i;
if (info->flash_id == FLASH_UNKNOWN) {
return;
}
if ((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL) {
for (i = 0; i < info->sector_count; i++) {
info->start[i] = base + (i * PHYS_FLASH_SECT_SIZE);
info->protect[i] = 0;
}
}
}
/*-----------------------------------------------------------------------
*/
void flash_print_info (flash_info_t * info)
{
int i;
if (info->flash_id == FLASH_UNKNOWN) {
printf ("missing or unknown FLASH type\n");
return;
}
switch (info->flash_id & FLASH_VENDMASK) {
case FLASH_MAN_INTEL:
printf ("INTEL ");
break;
default:
printf ("Unknown Vendor ");
break;
}
switch (info->flash_id & FLASH_TYPEMASK) {
case FLASH_28F128J3A:
printf ("28F128J3A\n");
break;
case FLASH_28F640J3A:
printf ("28F640J3A\n");
break;
default:
printf ("Unknown Chip Type\n");
break;
}
printf (" Size: %ld MB in %d Sectors\n",
info->size >> 20, info->sector_count);
printf (" Sector Start Addresses:");
for (i = 0; i < info->sector_count; ++i) {
if ((i % 5) == 0)
printf ("\n ");
printf (" %08lX%s",
info->start[i],
info->protect[i] ? " (RO)" : " ");
}
printf ("\n");
return;
}
/*
* The following code cannot be run from FLASH!
*/
static ulong flash_get_size (FPW * addr, flash_info_t * info)
{
volatile FPW value;
/* Write auto select command: read Manufacturer ID */
addr[0x5555] = (FPW) 0x00AA00AA;
addr[0x2AAA] = (FPW) 0x00550055;
addr[0x5555] = (FPW) 0x00900090;
mb ();
value = addr[0];
switch (value) {
case (FPW) INTEL_MANUFACT:
info->flash_id = FLASH_MAN_INTEL;
break;
default:
info->flash_id = FLASH_UNKNOWN;
info->sector_count = 0;
info->size = 0;
addr[0] = (FPW) 0x00FF00FF; /* restore read mode */
return (0); /* no or unknown flash */
}
mb ();
value = addr[1]; /* device ID */
switch (value) {
case (FPW) INTEL_ID_28F128J3A:
info->flash_id += FLASH_28F128J3A;
info->sector_count = 128;
info->size = 0x01000000;
break; /* => 16 MB */
case (FPW) INTEL_ID_28F640J3A:
info->flash_id += FLASH_28F640J3A;
info->sector_count = 64;
info->size = 0x00800000;
break; /* => 8 MB */
default:
info->flash_id = FLASH_UNKNOWN;
break;
}
if (info->sector_count > CFG_MAX_FLASH_SECT) {
printf ("** ERROR: sector count %d > max (%d) **\n",
info->sector_count, CFG_MAX_FLASH_SECT);
info->sector_count = CFG_MAX_FLASH_SECT;
}
addr[0] = (FPW) 0x00FF00FF; /* restore read mode */
return (info->size);
}
/*-----------------------------------------------------------------------
*/
int flash_erase (flash_info_t * info, int s_first, int s_last)
{
int flag, prot, sect;
ulong type, start, last;
int rcode = 0;
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;
}
type = (info->flash_id & FLASH_VENDMASK);
if ((type != FLASH_MAN_INTEL)) {
printf ("Can't erase unknown flash type %08lx - aborted\n",
info->flash_id);
return 1;
}
prot = 0;
for (sect = s_first; sect <= s_last; ++sect) {
if (info->protect[sect]) {
prot++;
}
}
if (prot) {
printf ("- Warning: %d protected sectors will not be erased!\n",
prot);
} else {
printf ("\n");
}
/*start = get_timer (0); */
last = start;
/* 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 */
FPWV *addr = (FPWV *) (info->start[sect]);
FPW status;
printf ("Erasing sector %2d ... ", sect);
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
*addr = (FPW) 0x00500050; /* clear status register */
*addr = (FPW) 0x00200020; /* erase setup */
*addr = (FPW) 0x00D000D0; /* erase confirm */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
if (get_timer_masked () > CFG_FLASH_ERASE_TOUT) {
printf ("Timeout\n");
*addr = (FPW) 0x00B000B0; /* suspend erase */
*addr = (FPW) 0x00FF00FF; /* reset to read mode */
rcode = 1;
break;
}
}
*addr = (FPW) 0x00500050; /* clear status register cmd. */
*addr = (FPW) 0x00FF00FF; /* resest to read mode */
printf (" done\n");
}
}
return rcode;
}
/*-----------------------------------------------------------------------
* Copy memory to flash, returns:
* 0 - OK
* 1 - write timeout
* 2 - Flash not erased
* 4 - Flash not identified
*/
int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
{
ulong cp, wp;
FPW data;
int count, i, l, rc, port_width;
if (info->flash_id == FLASH_UNKNOWN) {
return 4;
}
/* get lower word aligned address */
#ifdef FLASH_PORT_WIDTH16
wp = (addr & ~1);
port_width = 2;
#else
wp = (addr & ~3);
port_width = 4;
#endif
/*
* 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 < port_width && cnt > 0; ++i) {
data = (data << 8) | *src++;
--cnt;
++cp;
}
for (; cnt == 0 && i < port_width; ++i, ++cp) {
data = (data << 8) | (*(uchar *) cp);
}
if ((rc = write_data (info, wp, SWAP (data))) != 0) {
return (rc);
}
wp += port_width;
}
/*
* handle word aligned part
*/
count = 0;
while (cnt >= port_width) {
data = 0;
for (i = 0; i < port_width; ++i) {
data = (data << 8) | *src++;
}
if ((rc = write_data (info, wp, SWAP (data))) != 0) {
return (rc);
}
wp += port_width;
cnt -= port_width;
if (count++ > 0x800) {
spin_wheel ();
count = 0;
}
}
if (cnt == 0) {
return (0);
}
/*
* handle unaligned tail bytes
*/
data = 0;
for (i = 0, cp = wp; i < port_width && cnt > 0; ++i, ++cp) {
data = (data << 8) | *src++;
--cnt;
}
for (; i < port_width; ++i, ++cp) {
data = (data << 8) | (*(uchar *) cp);
}
return (write_data (info, wp, SWAP (data)));
}
/*-----------------------------------------------------------------------
* Write a word or halfword to Flash, returns:
* 0 - OK
* 1 - write timeout
* 2 - Flash not erased
*/
static int write_data (flash_info_t * info, ulong dest, FPW data)
{
FPWV *addr = (FPWV *) dest;
ulong status;
int flag;
/* Check if Flash is (sufficiently) erased */
if ((*addr & data) != data) {
printf ("not erased at %08lx (%x)\n", (ulong) addr, *addr);
return (2);
}
/* Disable interrupts which might cause a timeout here */
flag = disable_interrupts ();
*addr = (FPW) 0x00400040; /* write setup */
*addr = data;
/* arm simple, non interrupt dependent timer */
reset_timer_masked ();
/* wait while polling the status register */
while (((status = *addr) & (FPW) 0x00800080) != (FPW) 0x00800080) {
if (get_timer_masked () > CFG_FLASH_WRITE_TOUT) {
*addr = (FPW) 0x00FF00FF; /* restore read mode */
return (1);
}
}
*addr = (FPW) 0x00FF00FF; /* restore read mode */
return (0);
}
void inline spin_wheel (void)
{
static int p = 0;
static char w[] = "\\/-";
printf ("\010%c", w[p]);
(++p == 3) ? (p = 0) : 0;
}
+406
View File
@@ -0,0 +1,406 @@
/*
* Board specific setup info
*
* (C) Copyright 2003
* Texas Instruments, <www.ti.com>
*
* -- Some bits of code used from rrload's head_OMAP1510.s --
* Copyright (C) 2002 RidgeRun, Inc.
*
* 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 <config.h>
#include <version.h>
#if defined(CONFIG_OMAP1510)
#include <./configs/omap1510.h>
#endif
#define OMAP1510_CLKS ((1<<EN_XORPCK)|(1<<EN_PERCK)|(1<<EN_TIMCK)|(1<<EN_GPIOCK))
_TEXT_BASE:
.word TEXT_BASE /* sdram load addr from config.mk */
.globl platformsetup
platformsetup:
/*
* Configure 1510 pins functions to match our board.
*/
ldr r0, REG_PULL_DWN_CTRL_0
ldr r1, VAL_PULL_DWN_CTRL_0
str r1, [r0]
ldr r0, REG_PULL_DWN_CTRL_1
ldr r1, VAL_PULL_DWN_CTRL_1
str r1, [r0]
ldr r0, REG_PULL_DWN_CTRL_2
ldr r1, VAL_PULL_DWN_CTRL_2
str r1, [r0]
ldr r0, REG_PULL_DWN_CTRL_3
ldr r1, VAL_PULL_DWN_CTRL_3
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_4
ldr r1, VAL_FUNC_MUX_CTRL_4
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_5
ldr r1, VAL_FUNC_MUX_CTRL_5
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_6
ldr r1, VAL_FUNC_MUX_CTRL_6
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_7
ldr r1, VAL_FUNC_MUX_CTRL_7
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_8
ldr r1, VAL_FUNC_MUX_CTRL_8
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_9
ldr r1, VAL_FUNC_MUX_CTRL_9
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_A
ldr r1, VAL_FUNC_MUX_CTRL_A
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_B
ldr r1, VAL_FUNC_MUX_CTRL_B
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_C
ldr r1, VAL_FUNC_MUX_CTRL_C
str r1, [r0]
ldr r0, REG_FUNC_MUX_CTRL_D
ldr r1, VAL_FUNC_MUX_CTRL_D
str r1, [r0]
ldr r0, REG_VOLTAGE_CTRL_0
ldr r1, VAL_VOLTAGE_CTRL_0
str r1, [r0]
ldr r0, REG_TEST_DBG_CTRL_0
ldr r1, VAL_TEST_DBG_CTRL_0
str r1, [r0]
ldr r0, REG_MOD_CONF_CTRL_0
ldr r1, VAL_MOD_CONF_CTRL_0
str r1, [r0]
/* Move to 1510 mode */
ldr r0, REG_COMP_MODE_CTRL_0
ldr r1, VAL_COMP_MODE_CTRL_0
str r1, [r0]
/* Set up Traffic Ctlr*/
ldr r0, REG_TC_IMIF_PRIO
mov r1, #0x0
str r1, [r0]
ldr r0, REG_TC_EMIFS_PRIO
str r1, [r0]
ldr r0, REG_TC_EMIFF_PRIO
str r1, [r0]
ldr r0, REG_TC_EMIFS_CONFIG
ldr r1, [r0]
bic r1, r1, #0x08 /* clear the global power-down enable PDE bit */
bic r1, r1, #0x01 /* write protect flash by clearing the WP bit */
str r1, [r0] /* EMIFS GlB Configuration. (value 0x12 most likely) */
ldr r0, _GPIO_PIN_CONTROL_REG
ldrh r1,[r0]
orr r1, r1, #0x0001 /* M_PCM_SYNC */
orr r1, r1, #0x4000 /* IPC_ACTIVE */
orr r1, r1, #0x0002 /* A_IRDA_OFF */
orr r1, r1, #0x0800 /* A_SWITCH */
orr r1, r1, #0x8000 /* A_USB_ON */
strh r1,[r0]
ldr r0, _GPIO_DIR_CONTROL_REG
ldrh r1,[r0]
bic r1, r1, #0x0001 /* M_PCM_SYNC */
bic r1, r1, #0x4000 /* IPC_ACTIVE */
bic r1, r1, #0x0002 /* A_IRDA_OFF */
bic r1, r1, #0x0800 /* A_SWITCH */
bic r1, r1, #0x8000 /* A_USB_ON */
strh r1,[r0]
ldr r0, _GPIO_DATA_OUTPUT_REG
ldrh r1,[r0]
bic r1, r1, #0x0001 /* M_PCM_SYNC */
orr r1, r1, #0x4000 /* IPC_ACTIVE */
orr r1, r1, #0x0002 /* A_IRDA_OFF */
bic r1, r1, #0x0800 /* A_SWITCH */
bic r1, r1, #0x8000 /* A_USB_ON */
strh r1,[r0]
/* Setup some clock domains */
ldr r1, =OMAP1510_CLKS
ldr r0, REG_ARM_IDLECT2
strh r1, [r0] /* CLKM, Clock domain control. */
mov r1, #0x01 /* PER_EN bit */
ldr r0, REG_ARM_RSTCT2
strh r1, [r0] /* CLKM; Peripheral reset. */
/* Set CLKM to Sync-Scalable */
/* I supposidly need to enable the dsp clock before switching */
mov r1, #0x1000
ldr r0, REG_ARM_SYSST
strh r1, [r0]
mov r0, #0x400
1:
subs r0, r0, #0x1 /* wait for any bubbles to finish */
bne 1b
ldr r1, VAL_ARM_CKCTL /* use 12Mhz ref, PER must be <= 50Mhz so /2 */
ldr r0, REG_ARM_CKCTL
strh r1, [r0]
/* setup DPLL 1 */
ldr r1, VAL_DPLL1_CTL
ldr r0, REG_DPLL1_CTL
strh r1, [r0]
ands r1, r1, #0x10 /* Check if PLL is enabled. */
beq lock_end /* Do not look for lock if BYPASS selected */
2:
ldrh r1, [r0]
ands r1, r1, #0x01 /* Check the LOCK bit. */
beq 2b /* ...loop until bit goes hi. */
lock_end:
/* Set memory timings corresponding to the new clock speed */
/* Check execution location to determine current execution location
* and branch to appropriate initialization code.
*/
mov r0, #0x10000000 /* Load physical SDRAM base. */
mov r1, pc /* Get current execution location. */
cmp r1, r0 /* Compare. */
bge skip_sdram /* Skip over EMIF-fast initialization if running from SDRAM. */
/*
* Delay for SDRAM initialization.
*/
mov r3, #0x1800 /* value should be checked */
3:
subs r3, r3, #0x1 /* Decrement count */
bne 3b
/*
* Set SDRAM control values. Disable refresh before MRS command.
*/
ldr r0, VAL_TC_EMIFF_SDRAM_CONFIG /* get good value */
bic r3, r0, #0xC /* (BIT3|BIT2) ulConfig with auto-refresh disabled. */
orr r3, r3, #0x8000000 /* (BIT27) Disable CLK when Power down or Self-Refresh */
orr r3, r3, #0x4000000 /* BIT26 Power Down Enable */
ldr r2, REG_TC_EMIFF_SDRAM_CONFIG /* Point to configuration register. */
str r3, [r2] /* Store the passed value with AR disabled. */
ldr r1, VAL_TC_EMIFF_MRS /* get MRS value */
ldr r2, REG_TC_EMIFF_MRS /* Point to MRS register. */
str r1, [r2] /* Store the passed value.*/
ldr r2, REG_TC_EMIFF_SDRAM_CONFIG /* Point to configuration register. */
str r0, [r2] /* Store the passed value. */
/*
* Delay for SDRAM initialization.
*/
mov r3, #0x1800
4:
subs r3, r3, #1 /* Decrement count. */
bne 4b
skip_sdram:
/* slow interface */
ldr r1, VAL_TC_EMIFS_CS0_CONFIG
ldr r0, REG_TC_EMIFS_CS0_CONFIG
str r1, [r0] /* Chip Select 0 */
ldr r1, VAL_TC_EMIFS_CS1_CONFIG
ldr r0, REG_TC_EMIFS_CS1_CONFIG
str r1, [r0] /* Chip Select 1 */
ldr r1, VAL_TC_EMIFS_CS2_CONFIG
ldr r0, REG_TC_EMIFS_CS2_CONFIG
str r1, [r0] /* Chip Select 2 */
ldr r1, VAL_TC_EMIFS_CS3_CONFIG
ldr r0, REG_TC_EMIFS_CS3_CONFIG
str r1, [r0] /* Chip Select 3 */
/* back to arch calling code */
mov pc, lr
/* the literal pools origin */
.ltorg
/* OMAP configuration registers */
REG_FUNC_MUX_CTRL_0: /* 32 bits */
.word 0xfffe1000
REG_FUNC_MUX_CTRL_1: /* 32 bits */
.word 0xfffe1004
REG_FUNC_MUX_CTRL_2: /* 32 bits */
.word 0xfffe1008
REG_COMP_MODE_CTRL_0: /* 32 bits */
.word 0xfffe100c
REG_FUNC_MUX_CTRL_3: /* 32 bits */
.word 0xfffe1010
REG_FUNC_MUX_CTRL_4: /* 32 bits */
.word 0xfffe1014
REG_FUNC_MUX_CTRL_5: /* 32 bits */
.word 0xfffe1018
REG_FUNC_MUX_CTRL_6: /* 32 bits */
.word 0xfffe101c
REG_FUNC_MUX_CTRL_7: /* 32 bits */
.word 0xfffe1020
REG_FUNC_MUX_CTRL_8: /* 32 bits */
.word 0xfffe1024
REG_FUNC_MUX_CTRL_9: /* 32 bits */
.word 0xfffe1028
REG_FUNC_MUX_CTRL_A: /* 32 bits */
.word 0xfffe102C
REG_FUNC_MUX_CTRL_B: /* 32 bits */
.word 0xfffe1030
REG_FUNC_MUX_CTRL_C: /* 32 bits */
.word 0xfffe1034
REG_FUNC_MUX_CTRL_D: /* 32 bits */
.word 0xfffe1038
REG_PULL_DWN_CTRL_0: /* 32 bits */
.word 0xfffe1040
REG_PULL_DWN_CTRL_1: /* 32 bits */
.word 0xfffe1044
REG_PULL_DWN_CTRL_2: /* 32 bits */
.word 0xfffe1048
REG_PULL_DWN_CTRL_3: /* 32 bits */
.word 0xfffe104c
REG_VOLTAGE_CTRL_0: /* 32 bits */
.word 0xfffe1060
REG_TEST_DBG_CTRL_0: /* 32 bits */
.word 0xfffe1070
REG_MOD_CONF_CTRL_0: /* 32 bits */
.word 0xfffe1080
REG_TC_IMIF_PRIO: /* 32 bits */
.word 0xfffecc00
REG_TC_EMIFS_PRIO: /* 32 bits */
.word 0xfffecc04
REG_TC_EMIFF_PRIO: /* 32 bits */
.word 0xfffecc08
REG_TC_EMIFS_CONFIG: /* 32 bits */
.word 0xfffecc0c
REG_TC_EMIFS_CS0_CONFIG: /* 32 bits */
.word 0xfffecc10
REG_TC_EMIFS_CS1_CONFIG: /* 32 bits */
.word 0xfffecc14
REG_TC_EMIFS_CS2_CONFIG: /* 32 bits */
.word 0xfffecc18
REG_TC_EMIFS_CS3_CONFIG: /* 32 bits */
.word 0xfffecc1c
REG_TC_EMIFF_SDRAM_CONFIG: /* 32 bits */
.word 0xfffecc20
REG_TC_EMIFF_MRS: /* 32 bits */
.word 0xfffecc24
/* MPU clock/reset/power mode control registers */
REG_ARM_CKCTL: /* 16 bits */
.word 0xfffece00
REG_ARM_IDLECT2: /* 16 bits */
.word 0xfffece08
REG_ARM_RSTCT2: /* 16 bits */
.word 0xfffece14
REG_ARM_SYSST: /* 16 bits */
.word 0xfffece18
/* DPLL control registers */
REG_DPLL1_CTL: /* 16 bits */
.word 0xfffecf00
/* identification code register */
REG_IDCODE: /* 32 bits */
.word 0xfffed404
/* SX1 specific */
_GPIO_PIN_CONTROL_REG:
.word GPIO_PIN_CONTROL_REG
_GPIO_DIR_CONTROL_REG:
.word GPIO_DIR_CONTROL_REG
_GPIO_DATA_OUTPUT_REG:
.word GPIO_DATA_OUTPUT_REG
VAL_COMP_MODE_CTRL_0:
.word 0x0000eaef
VAL_FUNC_MUX_CTRL_4:
.word 0x00000000
VAL_FUNC_MUX_CTRL_5:
.word 0x00000000
VAL_FUNC_MUX_CTRL_6:
.word 0x00000001
VAL_FUNC_MUX_CTRL_7:
.word 0x00001000
VAL_FUNC_MUX_CTRL_8:
.word 0x00001240 /*[Knoller] Value of Symbian Image Wing B2*/
VAL_FUNC_MUX_CTRL_9:
.word 0x00201008
VAL_FUNC_MUX_CTRL_A:
.word 0x00001000
VAL_FUNC_MUX_CTRL_B:
.word 0x00000000
VAL_FUNC_MUX_CTRL_C:
.word 0x09008001 /*[Knoller] Value of Symbian Image Wing B2*/
VAL_FUNC_MUX_CTRL_D:
.word 0x00000000
VAL_PULL_DWN_CTRL_0:
.word 0xfffeffff
VAL_PULL_DWN_CTRL_1:
.word 0xd1ffffec
VAL_PULL_DWN_CTRL_2:
.word 0xffa80c5b
VAL_PULL_DWN_CTRL_3:
.word 0xffffc0fe
VAL_VOLTAGE_CTRL_0:
.word 0x00000007
VAL_TEST_DBG_CTRL_0:
/* The OMAP5910 TRM says this register must be 0, but HelenConfRegs
* says to write a 7. Don't know what the right thing is to do, so
* I'm leaving it at 7 since that's what was already here.
*/
.word 0x00000007
VAL_MOD_CONF_CTRL_0:
.word 0x0da20000 /*[Knoller] Value of Symbian Image Wing B2*/
VAL_ARM_CKCTL:
.word 0x010D
VAL_DPLL1_CTL:
.word 0x3A33 /*[Hertle] Value of Symbian Image*/
VAL_TC_EMIFS_CS1_CONFIG_PRELIM:
.word 0x00001149
VAL_TC_EMIFS_CS2_CONFIG_PRELIM:
.word 0x00004158
VAL_TC_EMIFS_CS0_CONFIG:
.word 0x00213090 /*[Knoller] Value of Symbian Image Wing B2*/
VAL_TC_EMIFS_CS1_CONFIG:
.word 0x00215070 /*[Knoller] Value of Symbian Image Wing B2*/
VAL_TC_EMIFS_CS2_CONFIG:
.word 0x00001139 /*[Knoller] Value of Symbian Image Wing B2*/
VAL_TC_EMIFS_CS3_CONFIG:
.word 0x00001139 /*[Knoller] Value of Symbian Image Wing B2*/
VAL_TC_EMIFF_SDRAM_CONFIG:
.word 0x0105f0b4 /*[Knoller] Value of Symbian Image Wing B2*/
VAL_TC_EMIFF_MRS:
.word 0x00000027 /*[Knoller] Value of Symbian Image Wing B2*/
+125
View File
@@ -0,0 +1,125 @@
/*
* (C) Copyright 2004
* Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
*
* (C) Copyright 2003
* Texas Instruments, <www.ti.com>
* Kshitij Gupta <Kshitij@ti.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>
static void flash__init (void);
static void ether__init (void);
static inline void delay (unsigned long loops)
{
__asm__ volatile ("1:\n"
"subs %0, %1, #1\n"
"bne 1b":"=r" (loops):"0" (loops));
}
/*
* Miscellaneous platform dependent initialisations
*/
int board_init (void)
{
DECLARE_GLOBAL_DATA_PTR;
/* arch number of SX1 Board */
gd->bd->bi_arch_number = 241;
/* adress of boot parameters */
gd->bd->bi_boot_params = 0x10000100;
/* kk - this speeds up your boot a quite a bit. However to make it
* work, you need make sure your kernel startup flush bug is fixed.
* ... rkw ...
*/
icache_enable ();
flash__init ();
ether__init ();
return 0;
}
int misc_init_r (void)
{
/* volatile ushort *gdir = (ushort *) (GPIO_DIR_CONTROL_REG); */
/* volatile ushort *mdir = (ushort *) (MPUIO_DIR_CONTROL_REG); */
/* setup gpio direction to match board (no floats!) */
/**gdir = 0xCFF9; */
/**mdir = 0x103F; */
return (0);
}
/******************************
Routine:
Description:
******************************/
static void flash__init (void)
{
#define CS0_CHIP_SELECT_REG 0xfffecc10
#define CS3_CHIP_SELECT_REG 0xfffecc1c
#define EMIFS_GlB_Config_REG 0xfffecc0c
unsigned int regval;
regval = *((volatile unsigned int *) EMIFS_GlB_Config_REG);
regval = regval | 0x0001; /* Turn off write protection for flash devices. */
if (regval & 0x0002) {
regval = regval & 0xfffd; /* Swap CS0 and CS3 so that flash is visible at 0x0 and eeprom at 0x0c000000. */
/* If, instead, you want to reference flash at 0x0c000000, then it seemed the following were necessary. */
/* *((volatile unsigned int *)CS0_CHIP_SELECT_REG) = 0x202090; / * Overrides head.S setting of 0x212090 */
/* *((volatile unsigned int *)CS3_CHIP_SELECT_REG) = 0x202090; / * Let's flash chips be fully functional. */
}
*((volatile unsigned int *) EMIFS_GlB_Config_REG) = regval;
}
/******************************
Routine:
Description:
******************************/
static void ether__init (void)
{
#define ETH_CONTROL_REG 0x0800000b
/* take the Ethernet controller out of reset and wait
* for the EEPROM load to complete.
*/
*((volatile unsigned char *) ETH_CONTROL_REG) &= ~0x01;
udelay (3);
}
int dram_init (void)
{
DECLARE_GLOBAL_DATA_PTR;
gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
return 0;
}
+56
View File
@@ -0,0 +1,56 @@
/*
* (C) Copyright 2004
* Wolfgang Denk, DENX Software Engineering, <wg@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_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
/*OUTPUT_FORMAT("elf32-arm", "elf32-arm", "elf32-arm")*/
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = 0x00000000;
. = ALIGN(4);
.text :
{
cpu/arm925t/start.o (.text)
*(.text)
}
. = ALIGN(4);
.rodata : { *(.rodata) }
. = ALIGN(4);
.data : { *(.data) }
. = ALIGN(4);
.got : { *(.got) }
__u_boot_cmd_start = .;
.u_boot_cmd : { *(.u_boot_cmd) }
__u_boot_cmd_end = .;
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss) }
_end = .;
}
+3 -8
View File
@@ -31,17 +31,12 @@
#if (CONFIG_FPGA & (CFG_ALTERA | CFG_ACEX1K))
/* Define FPGA_DEBUG to get debug printf's */
/* #define FPGA_DEBUG */
#ifdef FPGA_DEBUG
#define PRINTF(fmt,args...) printf (fmt ,##args)
#else
#define PRINTF(fmt,args...)
#endif
#undef CFG_FPGA_CHECK_BUSY
#define CFG_FPGA_PROG_FEEDBACK
/* Note: The assumption is that we cannot possibly run fast enough to
* overrun the device (the Slave Parallel mode can free run at 50MHz).
* If there is a need to operate slower, define CONFIG_FPGA_DELAY in
@@ -52,7 +47,7 @@
#endif
#ifndef CFG_FPGA_WAIT
#define CFG_FPGA_WAIT 100
#define CFG_FPGA_WAIT CFG_HZ/10 /* 100 ms */
#endif
static int ACEX1K_ps_load( Altera_desc *desc, void *buf, size_t bsize );
@@ -162,7 +157,7 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize)
__FUNCTION__, &fn, fn, fn->config, fn->status,
fn->clk, fn->data, fn->done);
#ifdef CFG_FPGA_PROG_FEEDBACK
printf ("Loading FPGA Device %d (@ %ld)...\n", cookie, ts);
printf ("Loading FPGA Device %d...", cookie);
#endif
/*
@@ -246,7 +241,7 @@ static int ACEX1K_ps_load (Altera_desc * desc, void *buf, size_t bsize)
CONFIG_FPGA_DELAY ();
#ifdef CFG_FPGA_PROG_FEEDBACK
putc ('\n'); /* terminate the dotted line */
putc (' '); /* terminate the dotted line */
#endif
/*
+4 -4
View File
@@ -1,5 +1,5 @@
#
# (C) Copyright 2000, 2001
# (C) Copyright 2004
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
#
# 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
# 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
@@ -47,7 +47,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o \
hush.o kgdb.o lists.o lynxkdi.o memsize.o miiphybb.o miiphyutil.o \
s_record.o soft_i2c.o soft_spi.o spartan2.o \
usb.o usb_kbd.o usb_storage.o \
virtex2.o xilinx.o
virtex2.o xilinx.o circbuf.o
OBJS = $(AOBJS) $(COBJS)
@@ -55,7 +55,7 @@ CPPFLAGS += -I..
all: $(LIB) $(AOBJS)
$(LIB): .depend $(OBJS)
$(LIB): .depend $(OBJS)
$(AR) crv $@ $(OBJS)
environment.o: environment.c ../tools/envcrc
+110
View File
@@ -0,0 +1,110 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* 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 <malloc.h>
#include <circbuf.h>
int buf_init (circbuf_t * buf, unsigned int size)
{
assert (buf != NULL);
buf->size = 0;
buf->totalsize = size;
buf->data = (char *) malloc (sizeof (char) * size);
assert (buf->data != NULL);
buf->top = buf->data;
buf->tail = buf->data;
buf->end = &(buf->data[size]);
return 1;
}
int buf_free (circbuf_t * buf)
{
assert (buf != NULL);
assert (buf->data != NULL);
free (buf->data);
memset (buf, 0, sizeof (circbuf_t));
return 1;
}
int buf_pop (circbuf_t * buf, char *dest, unsigned int len)
{
unsigned int i;
char *p = buf->top;
assert (buf != NULL);
assert (dest != NULL);
/* Cap to number of bytes in buffer */
if (len > buf->size)
len = buf->size;
for (i = 0; i < len; i++) {
dest[i] = *p++;
/* Bounds check. */
if (p == buf->end) {
p = buf->data;
}
}
/* Update 'top' pointer */
buf->top = p;
buf->size -= len;
return len;
}
int buf_push (circbuf_t * buf, const char *src, unsigned int len)
{
/* NOTE: this function allows push to overwrite old data. */
unsigned int i;
char *p = buf->tail;
assert (buf != NULL);
assert (src != NULL);
for (i = 0; i < len; i++) {
*p++ = src[i];
if (p == buf->end) {
p = buf->data;
}
/* Make sure pushing too much data just replaces old data */
if (buf->size < buf->totalsize) {
buf->size++;
} else {
buf->top++;
if (buf->top == buf->end) {
buf->top = buf->data;
}
}
}
/* Update 'tail' pointer */
buf->tail = p;
return len;
}
+48 -22
View File
@@ -121,6 +121,7 @@ static unsigned long systemace_read(int dev,
{
unsigned val;
int retry;
unsigned blk_countdown;
unsigned char*dp = (unsigned char*)buffer;
if (get_cf_lock() < 0) {
@@ -136,6 +137,10 @@ static unsigned long systemace_read(int dev,
return 0;
}
#ifdef DEBUG_SYSTEMACE
printf("... systemace read %lu sectors at %lu\n", blkcnt, start);
#endif
retry = 2000;
for (;;) {
unsigned val = ace_readw(0x04);
@@ -161,34 +166,55 @@ static unsigned long systemace_read(int dev,
retry -= 1;
}
/* Write LBA block address */
ace_writew(start & 0xffff, 0x10);
start >>= 16;
ace_writew(start & 0xff, 0x12);
/* The SystemACE can only transfer 256 sectors at a time, so
limit the current chunk of sectors. The blk_countdown
variable is the number of sectors left to transfer. */
/* Write sector count | ReadMemCardData. */
ace_writew(blkcnt | 0x0300, 0x14);
blk_countdown = blkcnt;
while (blk_countdown > 0) {
unsigned trans = blk_countdown;
/* CONTROLREG = CFGRESET|LOCKREQ */
ace_writew(0x0082, 0x18);
if (trans > 256) trans = 256;
retry = blkcnt * 16;
while (retry > 0) {
int idx;
#ifdef DEBUG_SYSTEMACE
printf("... transfer %lu sector in a chunk\n", trans);
#endif
/* Write LBA block address */
ace_writew((start>> 0) & 0xffff, 0x10);
ace_writew((start>>16) & 0x00ff, 0x12);
/* Wait for buffer to become ready. */
while (! (ace_readw(0x04) & 0x0020)) {
udelay(1000);
/* NOTE: in the Write Sector count below, a count of 0
causes a transfer of 256, so &0xff gives the right
value for whatever transfer count we want. */
/* Write sector count | ReadMemCardData. */
ace_writew((trans&0xff) | 0x0300, 0x14);
/* CONTROLREG = CFGRESET|LOCKREQ */
ace_writew(0x0082, 0x18);
retry = trans * 16;
while (retry > 0) {
int idx;
/* Wait for buffer to become ready. */
while (! (ace_readw(0x04) & 0x0020)) {
udelay(1000);
}
/* Read 16 words of 2bytes from the sector buffer. */
for (idx = 0 ; idx < 16 ; idx += 1) {
unsigned short val = ace_readw(0x40);
*dp++ = val & 0xff;
*dp++ = (val>>8) & 0xff;
}
retry -= 1;
}
/* Read 16 words of 2bytes from the sector buffer. */
for (idx = 0 ; idx < 16 ; idx += 1) {
unsigned short val = ace_readw(0x40);
*dp++ = val & 0xff;
*dp++ = (val>>8) & 0xff;
}
retry -= 1;
/* Count the blocks we transfer this time. */
start += trans;
blk_countdown -= trans;
}
release_cf_lock();
+3
View File
@@ -37,6 +37,9 @@
#ifdef CONFIG_8xx
# include <mpc8xx.h>
#endif
#ifdef CONFIG_MPC5xxx
#include <mpc5xxx.h>
#endif
#include <ide.h>
#include <ata.h>
#ifdef CONFIG_STATUS_LED
+21 -21
View File
@@ -1,5 +1,5 @@
/*
* (C) Copyright 2000-2003
* (C) Copyright 2000-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
@@ -104,8 +104,8 @@ int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
* box some time (100 * 1 ms)
*/
for (i=0; i<100; ++i) {
if (serial_tstc()) {
(void) serial_getc();
if (tstc()) {
(void) getc();
}
udelay(1000);
}
@@ -220,9 +220,9 @@ read_record (char *buf, ulong len)
--len; /* always leave room for terminating '\0' byte */
for (p=buf; p < buf+len; ++p) {
c = serial_getc(); /* read character */
c = getc(); /* read character */
if (do_echo)
serial_putc (c); /* ... and echo it */
putc (c); /* ... and echo it */
switch (c) {
case '\r':
@@ -237,7 +237,7 @@ read_record (char *buf, ulong len)
}
/* Check for the console hangup (if any different from serial) */
if (gd->jt[XF_getc] != serial_getc) {
if (gd->jt[XF_getc] != getc) {
if (ctrlc()) {
return (-1);
}
@@ -387,7 +387,7 @@ write_record (char *buf)
char c;
while((c = *buf++))
serial_putc(c);
putc(c);
/* Check for the console hangup (if any different from serial) */
@@ -531,8 +531,8 @@ static ulong load_serial_bin (ulong offset)
* box some time (100 * 1 ms)
*/
for (i=0; i<100; ++i) {
if (serial_tstc()) {
(void) serial_getc();
if (tstc()) {
(void) getc();
}
udelay(1000);
}
@@ -551,7 +551,7 @@ void send_pad (void)
int count = his_pad_count;
while (count-- > 0)
serial_putc (his_pad_char);
putc (his_pad_char);
}
/* converts escaped kermit char to binary char */
@@ -579,7 +579,7 @@ void s1_sendpacket (char *packet)
{
send_pad ();
while (*packet) {
serial_putc (*packet++);
putc (*packet++);
}
}
@@ -841,7 +841,7 @@ static int k_recv (void)
/* get a packet */
/* wait for the starting character or ^C */
for (;;) {
switch (serial_getc ()) {
switch (getc ()) {
case START_CHAR: /* start packet */
goto START;
case ETX_CHAR: /* ^C waiting for packet */
@@ -853,13 +853,13 @@ static int k_recv (void)
START:
/* get length of packet */
sum = 0;
new_char = serial_getc ();
new_char = getc ();
if ((new_char & 0xE0) == 0)
goto packet_error;
sum += new_char & 0xff;
length = untochar (new_char);
/* get sequence number */
new_char = serial_getc ();
new_char = getc ();
if ((new_char & 0xE0) == 0)
goto packet_error;
sum += new_char & 0xff;
@@ -886,7 +886,7 @@ START:
/* END NEW CODE */
/* get packet type */
new_char = serial_getc ();
new_char = getc ();
if ((new_char & 0xE0) == 0)
goto packet_error;
sum += new_char & 0xff;
@@ -896,19 +896,19 @@ START:
if (length == -2) {
/* (length byte was 0, decremented twice) */
/* get the two length bytes */
new_char = serial_getc ();
new_char = getc ();
if ((new_char & 0xE0) == 0)
goto packet_error;
sum += new_char & 0xff;
len_hi = untochar (new_char);
new_char = serial_getc ();
new_char = getc ();
if ((new_char & 0xE0) == 0)
goto packet_error;
sum += new_char & 0xff;
len_lo = untochar (new_char);
length = len_hi * 95 + len_lo;
/* check header checksum */
new_char = serial_getc ();
new_char = getc ();
if ((new_char & 0xE0) == 0)
goto packet_error;
if (new_char != tochar ((sum + ((sum >> 6) & 0x03)) & 0x3f))
@@ -918,7 +918,7 @@ START:
}
/* bring in rest of packet */
while (length > 1) {
new_char = serial_getc ();
new_char = getc ();
if ((new_char & 0xE0) == 0)
goto packet_error;
sum += new_char & 0xff;
@@ -935,13 +935,13 @@ START:
}
}
/* get and validate checksum character */
new_char = serial_getc ();
new_char = getc ();
if ((new_char & 0xE0) == 0)
goto packet_error;
if (new_char != tochar ((sum + ((sum >> 6) & 0x03)) & 0x3f))
goto packet_error;
/* get END_CHAR */
new_char = serial_getc ();
new_char = getc ();
if (new_char != END_CHAR) {
packet_error:
/* restore state machines */
+1
View File
@@ -129,6 +129,7 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
last_op = op;
last_addr = addr;
last_data = data;
last_reg = reg;
return rcode;
}
+3
View File
@@ -194,6 +194,9 @@ int devices_init (void)
drv_logbuff_init ();
#endif
drv_system_init ();
#ifdef CONFIG_USB_TTY
drv_usbtty_init ();
#endif
return (0);
}
+1 -1
View File
@@ -47,7 +47,7 @@
#endif
#ifndef CFG_FPGA_WAIT
#define CFG_FPGA_WAIT 10
#define CFG_FPGA_WAIT CFG_HZ/100 /* 10 ms */
#endif
static int Spartan2_sp_load( Xilinx_desc *desc, void *buf, size_t bsize );
+52 -40
View File
@@ -19,7 +19,7 @@
*
* 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
* 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
@@ -53,10 +53,12 @@
#ifdef CONFIG_USB_STORAGE
#undef USB_STOR_DEBUG
#undef USB_STOR_DEBUG
#undef BBB_COMDAT_TRACE
#undef BBB_XPORT_TRACE
#ifdef USB_STOR_DEBUG
#define USB_STOR_PRINTF(fmt,args...) printf (fmt ,##args)
#define USB_STOR_PRINTF(fmt,args...) printf (fmt ,##args)
#else
#define USB_STOR_PRINTF(fmt,args...)
#endif
@@ -102,7 +104,7 @@ typedef struct {
# define CBWCDBLENGTH 16
__u8 CBWCDB[CBWCDBLENGTH];
} umass_bbb_cbw_t;
#define UMASS_BBB_CBW_SIZE 31
#define UMASS_BBB_CBW_SIZE 31
static __u32 CBWTag = 0;
/* Command Status Wrapper */
@@ -113,10 +115,10 @@ typedef struct {
__u32 dCSWDataResidue;
__u8 bCSWStatus;
# define CSWSTATUS_GOOD 0x0
# define CSWSTATUS_FAILED 0x1
# define CSWSTATUS_FAILED 0x1
# define CSWSTATUS_PHASE 0x2
} umass_bbb_csw_t;
#define UMASS_BBB_CSW_SIZE 13
#define UMASS_BBB_CSW_SIZE 13
#define USB_MAX_STOR_DEV 5
static int usb_max_devs; /* number of highest available usb device */
@@ -128,7 +130,7 @@ typedef int (*trans_cmnd)(ccb*, struct us_data*);
typedef int (*trans_reset)(struct us_data*);
struct us_data {
struct usb_device *pusb_dev; /* this usb_device */
struct usb_device *pusb_dev; /* this usb_device */
unsigned int flags; /* from filter initially */
unsigned char ifnum; /* interface number */
unsigned char ep_in; /* in endpoint */
@@ -136,14 +138,14 @@ struct us_data {
unsigned char ep_int; /* interrupt . */
unsigned char subclass; /* as in overview */
unsigned char protocol; /* .............. */
unsigned char attention_done; /* force attn on first cmd */
unsigned char attention_done; /* force attn on first cmd */
unsigned short ip_data; /* interrupt data */
int action; /* what to do */
int ip_wanted; /* needed */
int *irq_handle; /* for USB int requests */
unsigned int irqpipe; /* pipe for release_irq */
unsigned char irqmaxp; /* max packed for irq Pipe */
unsigned char irqinterval; /* Intervall for IRQ Pipe */
unsigned char irqinterval; /* Intervall for IRQ Pipe */
ccb *srb; /* current srb */
trans_reset transport_reset; /* reset routine */
trans_cmnd transport; /* transport routine */
@@ -152,7 +154,7 @@ struct us_data {
static struct us_data usb_stor[USB_MAX_STOR_DEV];
#define USB_STOR_TRANSPORT_GOOD 0
#define USB_STOR_TRANSPORT_GOOD 0
#define USB_STOR_TRANSPORT_FAILED -1
#define USB_STOR_TRANSPORT_ERROR -2
@@ -517,45 +519,47 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
}
int usb_stor_CBI_get_status(ccb *srb, struct us_data *us)
int usb_stor_CBI_get_status (ccb * srb, struct us_data *us)
{
int timeout;
us->ip_wanted=1;
submit_int_msg(us->pusb_dev,us->irqpipe,
(void *)&us->ip_data,us->irqmaxp ,us->irqinterval);
timeout=1000;
while(timeout--) {
if((volatile int *)us->ip_wanted==0)
us->ip_wanted = 1;
submit_int_msg (us->pusb_dev, us->irqpipe,
(void *) &us->ip_data, us->irqmaxp, us->irqinterval);
timeout = 1000;
while (timeout--) {
if ((volatile int *) us->ip_wanted == 0)
break;
wait_ms(10);
wait_ms (10);
}
if (us->ip_wanted) {
printf(" Did not get interrupt on CBI\n");
printf (" Did not get interrupt on CBI\n");
us->ip_wanted = 0;
return USB_STOR_TRANSPORT_ERROR;
}
USB_STOR_PRINTF("Got interrupt data 0x%x, transfered %d status 0x%lX\n", us->ip_data,us->pusb_dev->irq_act_len,us->pusb_dev->irq_status);
USB_STOR_PRINTF
("Got interrupt data 0x%x, transfered %d status 0x%lX\n",
us->ip_data, us->pusb_dev->irq_act_len,
us->pusb_dev->irq_status);
/* UFI gives us ASC and ASCQ, like a request sense */
if (us->subclass == US_SC_UFI) {
if (srb->cmd[0] == SCSI_REQ_SENSE ||
srb->cmd[0] == SCSI_INQUIRY)
return USB_STOR_TRANSPORT_GOOD; /* Good */
else if (us->ip_data)
return USB_STOR_TRANSPORT_FAILED;
else
if (us->ip_data)
return USB_STOR_TRANSPORT_FAILED;
else
return USB_STOR_TRANSPORT_GOOD;
return USB_STOR_TRANSPORT_GOOD;
}
/* otherwise, we interpret the data normally */
switch (us->ip_data) {
case 0x0001:
return USB_STOR_TRANSPORT_GOOD;
case 0x0002:
return USB_STOR_TRANSPORT_FAILED;
default:
return USB_STOR_TRANSPORT_ERROR;
} /* switch */
case 0x0001:
return USB_STOR_TRANSPORT_GOOD;
case 0x0002:
return USB_STOR_TRANSPORT_FAILED;
default:
return USB_STOR_TRANSPORT_ERROR;
} /* switch */
return USB_STOR_TRANSPORT_ERROR;
}
@@ -601,11 +605,11 @@ int usb_stor_BBB_transport(ccb *srb, struct us_data *us)
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;
USB_STOR_PRINTF("DATA phase\n");
if (dir_in)
pipe = pipein;
else
@@ -732,7 +736,7 @@ do_retry:
}
if((us->protocol==US_PR_CBI) &&
((srb->cmd[0]==SCSI_REQ_SENSE) ||
(srb->cmd[0]==SCSI_INQUIRY))) { /* do not issue an autorequest after request sense */
(srb->cmd[0]==SCSI_INQUIRY))) { /* do not issue an autorequest after request sense */
USB_STOR_PRINTF("No auto request and good\n");
return USB_STOR_TRANSPORT_GOOD;
}
@@ -749,7 +753,7 @@ do_retry:
USB_STOR_PRINTF("auto request returned %d\n",result);
/* if this is an CBI Protocol, get IRQ */
if(us->protocol==US_PR_CBI) {
status=usb_stor_CBI_get_status(psrb,us);
status=usb_stor_CBI_get_status(psrb,us);
}
if((result<0)&&!(us->pusb_dev->status & USB_ST_STALLED)) {
USB_STOR_PRINTF(" AUTO REQUEST ERROR %d\n",us->pusb_dev->status);
@@ -765,7 +769,7 @@ do_retry:
switch(srb->sense_buf[2]) {
case 0x01: /* Recovered Error */
return USB_STOR_TRANSPORT_GOOD;
break;
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",
@@ -817,7 +821,7 @@ static int usb_inquiry(ccb *srb,struct us_data *ss)
static int usb_request_sense(ccb *srb,struct us_data *ss)
{
char *ptr;
return 0;
ptr=srb->pdata;
memset(&srb->cmd[0],0,12);
srb->cmd[0]=SCSI_REQ_SENSE;
@@ -845,6 +849,8 @@ static int usb_test_unit_ready(ccb *srb,struct us_data *ss)
if(ss->transport(srb,ss)==USB_STOR_TRANSPORT_GOOD) {
return 0;
}
usb_request_sense (srb, ss);
wait_ms (100);
} while(retries--);
return -1;
@@ -893,8 +899,12 @@ unsigned long usb_stor_read(int device, unsigned long blknr, unsigned long blkcn
unsigned short smallblks;
struct usb_device *dev;
int retry,i;
ccb *srb=&usb_ccb;
device&=0xff;
ccb *srb = &usb_ccb;
if (blkcnt == 0)
return 0;
device &= 0xff;
/* Setup device
*/
USB_STOR_PRINTF("\nusb_read: dev %d \n",device);
@@ -1026,7 +1036,7 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data
ss->transport_reset = usb_stor_BBB_reset;
break;
default:
printf("USB Starage Transport unknown / not yet implemented\n");
printf("USB Storage Transport unknown / not yet implemented\n");
return 0;
break;
}
@@ -1069,8 +1079,10 @@ int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,struct us_data
/* set class specific stuff */
/* We only handle certain protocols. Currently, these are
* the only ones.
* The SFF8070 accepts the requests used in u-boot
*/
if (ss->subclass != US_SC_UFI && ss->subclass != US_SC_SCSI) {
if (ss->subclass != US_SC_UFI && ss->subclass != US_SC_SCSI &&
ss->subclass != US_SC_8070) {
printf("Sorry, protocol %d not yet supported.\n",ss->subclass);
return 0;
}
+3 -3
View File
@@ -80,7 +80,7 @@
* an XC2V1000, if anyone can ever get ahold of one.
*/
#ifndef CFG_FPGA_WAIT_INIT
#define CFG_FPGA_WAIT_INIT 500 /* time in milliseconds */
#define CFG_FPGA_WAIT_INIT CFG_HZ/2 /* 500 ms */
#endif
/*
@@ -89,14 +89,14 @@
* clock frequencies (i.e. 66 MHz or less), BUSY monitoring is unnecessary.
*/
#ifndef CFG_FPGA_WAIT_BUSY
#define CFG_FPGA_WAIT_BUSY 5 /* time in milliseconds */
#define CFG_FPGA_WAIT_BUSY CFG_HZ/200 /* 5 ms*/
#endif
/* Default timeout for waiting for FPGA to enter operational mode after
* configuration data has been written.
*/
#ifndef CFG_FPGA_WAIT_CONFIG
#define CFG_FPGA_WAIT_CONFIG 200 /* time in milliseconds */
#define CFG_FPGA_WAIT_CONFIG CFG_HZ/5 /* 200 ms */
#endif
static int Virtex2_ssm_load (Xilinx_desc * desc, void *buf, size_t bsize);
+19 -19
View File
@@ -23,7 +23,7 @@
*
* 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
* 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
@@ -107,15 +107,15 @@ void show_regs (struct pt_regs *regs)
flags = condition_codes (regs);
printf ("pc : [<%08lx>] lr : [<%08lx>]\n"
"sp : %08lx ip : %08lx fp : %08lx\n",
printf ("pc : [<%08lx>] lr : [<%08lx>]\n"
"sp : %08lx ip : %08lx fp : %08lx\n",
instruction_pointer (regs),
regs->ARM_lr, regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
printf ("Flags: %c%c%c%c",
flags & CC_N_BIT ? 'N' : 'n',
@@ -227,17 +227,17 @@ void udelay (unsigned long usec)
#else
ulong tmo, tmp;
if(usec >= 1000){ /* if "big" number, spread normalization to seconds */
tmo = usec / 1000; /* start to normalize for usec to ticks per sec */
tmo *= CFG_HZ; /* find number of "ticks" to wait to achieve target */
tmo /= 1000; /* finish normalize. */
}else{ /* else small number, don't kill it prior to HZ multiply */
if(usec >= 1000){ /* if "big" number, spread normalization to seconds */
tmo = usec / 1000; /* start to normalize for usec to ticks per sec */
tmo *= CFG_HZ; /* find number of "ticks" to wait to achieve target */
tmo /= 1000; /* finish normalize. */
}else{ /* else small number, don't kill it prior to HZ multiply */
tmo = usec * CFG_HZ;
tmo /= (1000*1000);
}
tmp = get_timer (0); /* get current timestamp */
if( (tmo + tmp + 1) < tmp ) /* if setting this fordward will roll time stamp */
if( (tmo + tmp + 1) < tmp ) /* if setting this fordward will roll time stamp */
reset_timer_masked (); /* reset "advancing" timestamp to 0, set lastdec value */
else
tmo += tmp; /* else, set advancing stamp wake up time */
@@ -251,7 +251,7 @@ void reset_timer_masked (void)
{
/* reset time */
lastdec = READ_TIMER; /* capure current decrementer value time */
timestamp = 0; /* start "advancing" time stamp from 0 */
timestamp = 0; /* start "advancing" time stamp from 0 */
}
ulong get_timer_masked (void)
@@ -283,13 +283,13 @@ void udelay_masked (unsigned long usec)
for (i=time_remaining; i>0; i--) { }
#else
ulong tmo, tmp;
ulong tmo;
if(usec >= 1000){ /* if "big" number, spread normalization to seconds */
tmo = usec / 1000; /* start to normalize for usec to ticks per sec */
tmo *= CFG_HZ; /* find number of "ticks" to wait to achieve target */
tmo /= 1000; /* finish normalize. */
}else{ /* else small number, don't kill it prior to HZ multiply */
if(usec >= 1000){ /* if "big" number, spread normalization to seconds */
tmo = usec / 1000; /* start to normalize for usec to ticks per sec */
tmo *= CFG_HZ; /* find number of "ticks" to wait to achieve target */
tmo /= 1000; /* finish normalize. */
}else{ /* else small number, don't kill it prior to HZ multiply */
tmo = usec * CFG_HZ;
tmo /= (1000*1000);
}
-21
View File
@@ -133,27 +133,6 @@ reset:
orr r0,r0,#0xd3
msr cpsr,r0
/*
* turn off the watchdog, unlock/diable sequence
*/
mov r1, #0xF5
ldr r0, =WDTIM_MODE
strh r1, [r0]
mov r1, #0xA0
strh r1, [r0]
/*
* mask all IRQs by setting all bits in the INTMR - default
*/
mov r1, #0xffffffff
ldr r0, =REG_IHL1_MIR
str r1, [r0]
ldr r0, =REG_IHL2_MIR
str r1, [r0]
/*
* we do sys-critical inits only at reboot,
* not when booting from ram!
+2 -2
View File
@@ -27,8 +27,8 @@ LIB = lib$(CPU).a
START = start.o
ASOBJS = io.o firmware_sc_task_bestcomm.impl.o firmware_sc_task.impl.o
OBJS = i2c.o traps.o cpu.o cpu_init.o speed.o interrupts.o serial.o \
loadtask.o fec.o pci_mpc5200.o
OBJS = i2c.o traps.o cpu.o cpu_init.o fec.o ide.o interrupts.o \
loadtask.o pci_mpc5200.o serial.o speed.o usb_ohci.o
all: .depend $(START) $(ASOBJS) $(LIB)
+93
View File
@@ -0,0 +1,93 @@
/*
* (C) Copyright 2004
* Pierre AUBERT, Staubli Faverges, <p.aubert@staubli.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
*
* Init is derived from Linux code.
*/
#include <common.h>
#ifdef CFG_CMD_IDE
#include <mpc5xxx.h>
#define CALC_TIMING(t) (t + period - 1) / period
#define GPIO_PSC1_4 0x01000000ul
int ide_preinit (void)
{
DECLARE_GLOBAL_DATA_PTR;
long period, t0, t1, t2_8, t2_16, t4, ta;
vu_long reg;
struct mpc5xxx_sdma *psdma = (struct mpc5xxx_sdma *) MPC5XXX_SDMA;
reg = *(vu_long *) MPC5XXX_GPS_PORT_CONFIG;
reg = (reg & ~0x03000000ul) | 0x01000000ul;
*(vu_long *) MPC5XXX_GPS_PORT_CONFIG = reg;
/* All sample codes do that... */
*(vu_long *) MPC5XXX_ATA_SHARE_COUNT = 0;
/* Configure and reset host */
*(vu_long *) MPC5XXX_ATA_HOST_CONFIG = MPC5xxx_ATA_HOSTCONF_IORDY |
MPC5xxx_ATA_HOSTCONF_SMR | MPC5xxx_ATA_HOSTCONF_FR;
udelay (10);
*(vu_long *) MPC5XXX_ATA_HOST_CONFIG = MPC5xxx_ATA_HOSTCONF_IORDY;
/* Disable prefetch on Commbus */
psdma->PtdCntrl |= 1;
/* Init timings : we use PIO mode 0 timings */
period = 1000000000 / gd->ipb_clk; /* period in ns */
t0 = CALC_TIMING (600);
t2_8 = CALC_TIMING (290);
t2_16 = CALC_TIMING (165);
reg = (t0 << 24) | (t2_8 << 16) | (t2_16 << 8);
*(vu_long *) MPC5XXX_ATA_PIO1 = reg;
t4 = CALC_TIMING (30);
t1 = CALC_TIMING (70);
ta = CALC_TIMING (35);
reg = (t4 << 24) | (t1 << 16) | (ta << 8);
*(vu_long *) MPC5XXX_ATA_PIO2 = reg;
#if defined (CONFIG_ICECUBE) && defined (CONFIG_IDE_RESET)
/* Configure PSC1_4 as GPIO output for ATA reset */
*(vu_long *) MPC5XXX_WU_GPIO_DATA |= GPIO_PSC1_4;
*(vu_long *) MPC5XXX_WU_GPIO_ENABLE |= GPIO_PSC1_4;
*(vu_long *) MPC5XXX_WU_GPIO_DIR |= GPIO_PSC1_4;
#endif /* defined (CONFIG_ICECUBE) && defined (CONFIG_IDE_RESET) */
return (0);
}
#if defined (CONFIG_ICECUBE) && defined (CONFIG_IDE_RESET)
void ide_set_reset (int idereset)
{
if (idereset) {
*(vu_long *) MPC5XXX_WU_GPIO_DATA &= ~GPIO_PSC1_4;
} else {
*(vu_long *) MPC5XXX_WU_GPIO_DATA |= GPIO_PSC1_4;
}
}
#endif /* defined (CONFIG_ICECUBE) && defined (CONFIG_IDE_RESET) */
#endif /* CFG_CMD_IDE */
+17 -16
View File
@@ -108,18 +108,19 @@ boot_warm:
#error CFG_LOWBOOT is incompatible with CFG_RAMBOOT
#endif /* CFG_RAMBOOT */
lis r4, CFG_DEFAULT_MBAR@h
lis r3, 0x0000FF00@h
ori r3, r3, 0x0000FF00@l
stw r3, 0x4(r4)
lis r3, 0x0000FFFF@h
ori r3, r3, 0x0000FFFF@l
stw r3, 0x8(r4)
lis r3, START_REG(CFG_BOOTCS_START)@h
ori r3, r3, START_REG(CFG_BOOTCS_START)@l
stw r3, 0x4(r4) /* CS0 start */
lis r3, STOP_REG(CFG_BOOTCS_START, CFG_BOOTCS_SIZE)@h
ori r3, r3, STOP_REG(CFG_BOOTCS_START, CFG_BOOTCS_SIZE)@l
stw r3, 0x8(r4) /* CS0 stop */
lis r3, 0x00047800@h
ori r3, r3, 0x00047800@l
stw r3, 0x300(r4)
stw r3, 0x300(r4) /* set timing, CS0/boot conf reg */
lis r3, 0x02010000@h
ori r3, r3, 0x02010000@l
stw r3, 0x54(r4)
stw r3, 0x54(r4) /* CS0 and Boot enable, IPBI ctrl reg */
lis r3, lowboot_reentry@h
ori r3, r3, lowboot_reentry@l
@@ -127,18 +128,18 @@ boot_warm:
blr /* jump to flash based address */
lowboot_reentry:
lis r3, 0x0000FF00@h
ori r3, r3, 0x0000FF00@l
stw r3, 0x4c(r4)
lis r3, 0x0000FFFF@h
ori r3, r3, 0x0000FFFF@l
stw r3, 0x50(r4)
lis r3, START_REG(CFG_BOOTCS_START)@h
ori r3, r3, START_REG(CFG_BOOTCS_START)@l
stw r3, 0x4c(r4) /* Boot start */
lis r3, STOP_REG(CFG_BOOTCS_START, CFG_BOOTCS_SIZE)@h
ori r3, r3, STOP_REG(CFG_BOOTCS_START, CFG_BOOTCS_SIZE)@l
stw r3, 0x50(r4) /* Boot stop */
lis r3, 0x00047800@h
ori r3, r3, 0x00047800@l
stw r3, 0x300(r4)
stw r3, 0x300(r4) /* set timing, CS0/boot conf reg */
lis r3, 0x02000001@h
ori r3, r3, 0x02000001@l
stw r3, 0x54(r4)
stw r3, 0x54(r4) /* Boot enable, CS0 disable, wait state enable */
#endif /* CFG_LOWBOOT */
#if defined(CFG_DEFAULT_MBAR) && !defined(CFG_RAMBOOT)
File diff suppressed because it is too large. Load diff
+424
View File
@@ -0,0 +1,424 @@
/*
* 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 */
#if defined(CONFIG_MPC5200)
__u16 pad1; /* set to 0 on each frame_no change */
__u16 frame_no; /* current frame number */
#else
__u16 frame_no; /* current frame number */
__u16 pad1; /* set to 0 on each frame_no change */
#endif
__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;
}
+36
View File
@@ -0,0 +1,36 @@
U-Boot Port to the NS9750 DevKit from NetSilicon
1 Overview
2 Board Configuration
3 Installation
1 Overview
----------
This port supports these NS9750 features.
o one UART
2 Board Configuration
---------------------
Switches:
SW10: 4
SW11: 6,7
SW16: 6,7,8
SW17-SW20: 1
SW4: 3, 6
SW 1: 1
SW2: 4
SW3: 3
SW8: 3 (rotated by 180 degree!!!!)
Serial Console is Port B (bottom right port)
3 Installation
--------------
Have fun,
--
Markus Pietrek <mpietrek@fsforth.de>
+6 -5
View File
@@ -1,5 +1,5 @@
#
# (C) Copyright 2000
# (C) Copyright 2000-2004
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
@@ -12,7 +12,7 @@
#
# 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
# 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
@@ -29,7 +29,7 @@ LIB = libdrivers.a
OBJS = 3c589.o 5701rls.o ali512x.o \
bcm570x.o bcm570x_autoneg.o cfb_console.o cfi_flash.o \
cs8900.o ct69000.o dataflash.o dc2114x.o \
cs8900.o ct69000.o dataflash.o dc2114x.o \
e1000.o eepro100.o \
i8042.o i82365.o inca-ip_sw.o \
lan91c96.o natsemi.o netarm_eth.o \
@@ -40,11 +40,12 @@ OBJS = 3c589.o 5701rls.o ali512x.o \
rtl8019.o rtl8139.o \
s3c24x0_i2c.o sed13806.o serial.o serial_max3100.o \
smc91111.o smiLynxEM.o status_led.o sym53c8xx.o \
ti_pci1410a.o tigon3.o w83c553f.o
ti_pci1410a.o tigon3.o w83c553f.o omap1510_i2c.o \
usbdcore.o usbdcore_ep0.o usbdcore_omap1510.o usbtty.o
all: $(LIB)
$(LIB): $(OBJS)
$(LIB): $(OBJS)
$(AR) crv $@ $(OBJS)
#########################################################################
+223 -124
View File
@@ -1,7 +1,7 @@
/*
* INCA-IP internal switch ethernet driver.
*
* (C) Copyright 2003
* (C) Copyright 2003-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
@@ -14,7 +14,7 @@
*
* 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
* 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
@@ -45,49 +45,54 @@
#define DMA_WRITE_REG(reg, value) *((volatile u32 *)reg) = (u32)value;
#define DMA_READ_REG(reg, value) value = (u32)*((volatile u32*)reg)
#define SW_WRITE_REG(reg, value) \
*((volatile u32*)reg) = (u32)value;\
DELAY;\
*((volatile u32*)reg) = (u32)value;
*((volatile u32*)reg) = (u32)value;\
DELAY;\
*((volatile u32*)reg) = (u32)value;
#define SW_READ_REG(reg, value) \
value = (u32)*((volatile u32*)reg);\
DELAY;\
value = (u32)*((volatile u32*)reg);
#define SW_READ_REG(reg, value) \
value = (u32)*((volatile u32*)reg);\
DELAY;\
value = (u32)*((volatile u32*)reg);
#define INCA_DMA_TX_POLLING_TIME 0x07
#define INCA_DMA_RX_POLLING_TIME 0x07
#define INCA_DMA_TX_POLLING_TIME 0x07
#define INCA_DMA_RX_POLLING_TIME 0x07
#define INCA_DMA_TX_HOLD 0x80000000
#define INCA_DMA_TX_EOP 0x40000000
#define INCA_DMA_TX_SOP 0x20000000
#define INCA_DMA_TX_ICPT 0x10000000
#define INCA_DMA_TX_IEOP 0x08000000
#define INCA_DMA_TX_HOLD 0x80000000
#define INCA_DMA_TX_EOP 0x40000000
#define INCA_DMA_TX_SOP 0x20000000
#define INCA_DMA_TX_ICPT 0x10000000
#define INCA_DMA_TX_IEOP 0x08000000
#define INCA_DMA_RX_C 0x80000000
#define INCA_DMA_RX_SOP 0x40000000
#define INCA_DMA_RX_EOP 0x20000000
#define INCA_DMA_RX_C 0x80000000
#define INCA_DMA_RX_SOP 0x40000000
#define INCA_DMA_RX_EOP 0x20000000
#define INCA_SWITCH_PHY_SPEED_10H 0x1
#define INCA_SWITCH_PHY_SPEED_10F 0x5
#define INCA_SWITCH_PHY_SPEED_100H 0x2
#define INCA_SWITCH_PHY_SPEED_100F 0x6
/************************ Auto MDIX settings ************************/
#define INCA_IP_AUTO_MDIX_LAN_PORTS_DIR INCA_IP_Ports_P1_DIR
#define INCA_IP_AUTO_MDIX_LAN_PORTS_ALTSEL INCA_IP_Ports_P1_ALTSEL
#define INCA_IP_AUTO_MDIX_LAN_PORTS_OUT INCA_IP_Ports_P1_OUT
#define INCA_IP_AUTO_MDIX_LAN_GPIO_PIN_RXTX 16
#define INCA_IP_AUTO_MDIX_LAN_PORTS_DIR INCA_IP_Ports_P1_DIR
#define INCA_IP_AUTO_MDIX_LAN_PORTS_ALTSEL INCA_IP_Ports_P1_ALTSEL
#define INCA_IP_AUTO_MDIX_LAN_PORTS_OUT INCA_IP_Ports_P1_OUT
#define INCA_IP_AUTO_MDIX_LAN_GPIO_PIN_RXTX 16
#define WAIT_SIGNAL_RETRIES 100
#define WAIT_LINK_RETRIES 100
#define LINK_RETRY_DELAY 300 /* ms */
#define WAIT_SIGNAL_RETRIES 100
#define WAIT_LINK_RETRIES 100
#define LINK_RETRY_DELAY 2000 /* ms */
/********************************************************************/
typedef struct
{
union {
struct {
volatile u32 HOLD :1;
volatile u32 ICpt :1;
volatile u32 IEop :1;
volatile u32 offset :3;
volatile u32 reserved0 :4;
volatile u32 NFB :22;
volatile u32 HOLD :1;
volatile u32 ICpt :1;
volatile u32 IEop :1;
volatile u32 offset :3;
volatile u32 reserved0 :4;
volatile u32 NFB :22;
}field;
volatile u32 word;
@@ -99,11 +104,11 @@ typedef struct
union {
struct {
volatile u32 C :1;
volatile u32 Sop :1;
volatile u32 Eop :1;
volatile u32 reserved3 :12;
volatile u32 NBT :17;
volatile u32 C :1;
volatile u32 Sop :1;
volatile u32 Eop :1;
volatile u32 reserved3 :12;
volatile u32 NBT :17;
}field;
volatile u32 word;
@@ -116,13 +121,13 @@ typedef struct
{
union {
struct {
volatile u32 HOLD :1;
volatile u32 Eop :1;
volatile u32 Sop :1;
volatile u32 ICpt :1;
volatile u32 IEop :1;
volatile u32 reserved0 :5;
volatile u32 NBA :22;
volatile u32 HOLD :1;
volatile u32 Eop :1;
volatile u32 Sop :1;
volatile u32 ICpt :1;
volatile u32 IEop :1;
volatile u32 reserved0 :5;
volatile u32 NBA :22;
}field;
volatile u32 word;
@@ -132,8 +137,8 @@ typedef struct
volatile u32 TxDataPtr;
volatile u32 C :1;
volatile u32 reserved3 :31;
volatile u32 C :1;
volatile u32 reserved3 :31;
} inca_tx_descriptor_t;
@@ -143,12 +148,11 @@ static inca_tx_descriptor_t tx_ring[NUM_TX_DESC] __attribute__ ((aligned(16)));
static int tx_new, rx_new, tx_hold, rx_hold;
static int tx_old_hold = -1;
static int initialized = 0;
static int initialized = 0;
static int inca_switch_init(struct eth_device *dev, bd_t * bis);
static int inca_switch_send(struct eth_device *dev, volatile void *packet,
int length);
static int inca_switch_send(struct eth_device *dev, volatile void *packet, int length);
static int inca_switch_recv(struct eth_device *dev);
static void inca_switch_halt(struct eth_device *dev);
static void inca_init_switch_chip(void);
@@ -174,7 +178,9 @@ int inca_switch_initialize(bd_t * bis)
inca_init_switch_chip();
#if defined(CONFIG_INCA_IP_SWITCH_AMDIX)
inca_amdix();
#endif
sprintf(dev->name, "INCA-IP Switch");
dev->init = inca_switch_init;
@@ -219,8 +225,7 @@ static int inca_switch_init(struct eth_device *dev, bd_t * bis)
/* Initialize the descriptor rings.
*/
for (i = 0; i < NUM_RX_DESC; i++)
{
for (i = 0; i < NUM_RX_DESC; i++) {
inca_rx_descriptor_t * rx_desc = KSEG1ADDR(&rx_ring[i]);
memset(rx_desc, 0, sizeof(rx_ring[i]));
@@ -259,9 +264,9 @@ static int inca_switch_init(struct eth_device *dev, bd_t * bis)
memset(tx_desc, 0, sizeof(tx_ring[i]));
tx_desc->params.word = 0;
tx_desc->params.word = 0;
tx_desc->params.field.HOLD = 1;
tx_desc->C = 1;
tx_desc->C = 1;
/* Check if it is the last descriptor.
*/
@@ -290,8 +295,7 @@ static int inca_switch_init(struct eth_device *dev, bd_t * bis)
/* Writing to the COMMAND REG.
*/
DMA_WRITE_REG(INCA_IP_DMA_DMA_RXCCR0,
INCA_IP_DMA_DMA_RXCCR0_INIT);
DMA_WRITE_REG(INCA_IP_DMA_DMA_RXCCR0, INCA_IP_DMA_DMA_RXCCR0_INIT);
/* Initialize TxDMA.
*/
@@ -314,9 +318,9 @@ static int inca_switch_init(struct eth_device *dev, bd_t * bis)
#endif
/* enable spanning tree forwarding, enable the CPU port */
/* ST_PT:
* CPS (CPU port status) 0x3 (forwarding)
* LPS (LAN port status) 0x3 (forwarding)
* PPS (PC port status) 0x3 (forwarding)
* CPS (CPU port status) 0x3 (forwarding)
* LPS (LAN port status) 0x3 (forwarding)
* PPS (PC port status) 0x3 (forwarding)
*/
SW_WRITE_REG(INCA_IP_Switch_ST_PT,0x3f);
@@ -328,14 +332,13 @@ static int inca_switch_init(struct eth_device *dev, bd_t * bis)
}
static int inca_switch_send(struct eth_device *dev, volatile void *packet,
int length)
static int inca_switch_send(struct eth_device *dev, volatile void *packet, int length)
{
int i;
int res = -1;
u32 command;
u32 regValue;
inca_tx_descriptor_t * tx_desc = KSEG1ADDR(&tx_ring[tx_new]);
int i;
int res = -1;
u32 command;
u32 regValue;
inca_tx_descriptor_t * tx_desc = KSEG1ADDR(&tx_ring[tx_new]);
#if 0
printf("Entered inca_switch_send()\n");
@@ -368,7 +371,7 @@ static int inca_switch_send(struct eth_device *dev, volatile void *packet,
KSEG1ADDR(&tx_ring[tx_hold])->params.field.HOLD = 0;
tx_hold = tx_new;
tx_new = (tx_new + 1) % NUM_TX_DESC;
tx_new = (tx_new + 1) % NUM_TX_DESC;
if (! initialized) {
@@ -404,7 +407,7 @@ Done:
static int inca_switch_recv(struct eth_device *dev)
{
int length = 0;
int length = 0;
inca_rx_descriptor_t * rx_desc;
#if 0
@@ -445,8 +448,7 @@ static int inca_switch_recv(struct eth_device *dev)
#if 0
printf("Received %d bytes\n", length);
#endif
NetReceive((void*)KSEG1ADDR(NetRxPackets[rx_new]),
length - 4);
NetReceive((void*)KSEG1ADDR(NetRxPackets[rx_new]), length - 4);
} else {
#if 1
printf("Zero length!!!\n");
@@ -511,13 +513,13 @@ static void inca_init_switch_chip(void)
#if 1
/* init MDIO configuration:
* MDS (Poll speed): 0x01 (4ms)
* PHY_LAN_ADDR: 0x06
* PHY_PC_ADDR: 0x05
* MDS (Poll speed): 0x01 (4ms)
* PHY_LAN_ADDR: 0x06
* PHY_PC_ADDR: 0x05
* UEP (Use External PHY): 0x00 (Internal PHY is used)
* PS (Port Select): 0x00 (PT/UMM for LAN)
* PT (PHY Test): 0x00 (no test mode)
* UMM (Use MDIO Mode): 0x00 (state machine is disabled)
* PS (Port Select): 0x00 (PT/UMM for LAN)
* PT (PHY Test): 0x00 (no test mode)
* UMM (Use MDIO Mode): 0x00 (state machine is disabled)
*/
SW_WRITE_REG(INCA_IP_Switch_MDIO_CFG, 0x4c50);
@@ -535,39 +537,39 @@ static void inca_init_switch_chip(void)
/* MDIO_ACC:
* RA (Request/Ack) 0x01 (Request)
* RW (Read/Write) 0x01 (Write)
* PHY_ADDR 0x05 (PC)
* REG_ADDR 0x00 (PHY_BCR: basic control register)
* PHY_DATA 0x8000
* Reset - software reset
* LB (loop back) - normal
* SS (speed select) - 10 Mbit/s
* RW (Read/Write) 0x01 (Write)
* PHY_ADDR 0x05 (PC)
* REG_ADDR 0x00 (PHY_BCR: basic control register)
* PHY_DATA 0x8000
* Reset - software reset
* LB (loop back) - normal
* SS (speed select) - 10 Mbit/s
* ANE (auto neg. enable) - enable
* PD (power down) - normal
* ISO (isolate) - normal
* PD (power down) - normal
* ISO (isolate) - normal
* RAN (restart auto neg.) - normal
* DM (duplex mode) - half duplex
* DM (duplex mode) - half duplex
* CT (collision test) - enable
*/
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC, 0xc0a09000);
/* MDIO_ACC:
* RA (Request/Ack) 0x01 (Request)
* RW (Read/Write) 0x01 (Write)
* PHY_ADDR 0x06 (LAN)
* REG_ADDR 0x00 (PHY_BCR: basic control register)
* PHY_DATA 0x8000
* Reset - software reset
* LB (loop back) - normal
* SS (speed select) - 10 Mbit/s
* RW (Read/Write) 0x01 (Write)
* PHY_ADDR 0x06 (LAN)
* REG_ADDR 0x00 (PHY_BCR: basic control register)
* PHY_DATA 0x8000
* Reset - software reset
* LB (loop back) - normal
* SS (speed select) - 10 Mbit/s
* ANE (auto neg. enable) - enable
* PD (power down) - normal
* ISO (isolate) - normal
* PD (power down) - normal
* ISO (isolate) - normal
* RAN (restart auto neg.) - normal
* DM (duplex mode) - half duplex
* DM (duplex mode) - half duplex
* CT (collision test) - enable
*/
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC, 0xc0c09000);
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC, 0xc0c09000);
#endif
@@ -623,9 +625,15 @@ static void inca_dma_init(void)
DMA_WRITE_REG(INCA_IP_DMA_DMA_RXISR, 0xFFFFFFFF);
}
#if defined(CONFIG_INCA_IP_SWITCH_AMDIX)
static int inca_amdix(void)
{
u32 regValue = 0;
u32 phyReg1 = 0;
u32 phyReg4 = 0;
u32 phyReg5 = 0;
u32 phyReg6 = 0;
u32 phyReg31 = 0;
u32 regEphy = 0;
int mdi_flag;
int retries;
@@ -634,31 +642,29 @@ static int inca_amdix(void)
*INCA_IP_AUTO_MDIX_LAN_PORTS_DIR |= (1 << INCA_IP_AUTO_MDIX_LAN_GPIO_PIN_RXTX);
*INCA_IP_AUTO_MDIX_LAN_PORTS_ALTSEL |= (1 << INCA_IP_AUTO_MDIX_LAN_GPIO_PIN_RXTX);
#if 0
/* Wait for signal.
*/
retries = WAIT_SIGNAL_RETRIES;
while (--retries)
{
while (--retries) {
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC,
(0x1 << 31) | /* RA */
(0x0 << 30) | /* Read */
(0x6 << 21) | /* LAN */
(17 << 16)); /* PHY_MCSR */
do
{
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, regValue);
}
while (regValue & (1 << 31));
do {
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, phyReg1);
} while (phyReg1 & (1 << 31));
if (regValue & (1 << 1))
{
if (phyReg1 & (1 << 1)) {
/* Signal detected */
break;
}
}
if (!retries)
return -1;
goto Fail;
#endif
/* Set MDI mode.
*/
@@ -668,43 +674,136 @@ static int inca_amdix(void)
/* Wait for link.
*/
retries = WAIT_LINK_RETRIES;
while (--retries)
{
while (--retries) {
udelay(LINK_RETRY_DELAY * 1000);
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC,
(0x1 << 31) | /* RA */
(0x0 << 30) | /* Read */
(0x6 << 21) | /* LAN */
(1 << 16)); /* PHY_BSR */
do
{
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, regValue);
}
while (regValue & (1 << 31));
do {
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, phyReg1);
} while (phyReg1 & (1 << 31));
if (regValue & (1 << 2))
{
if (phyReg1 & (1 << 2)) {
/* Link is up */
break;
}
else if (mdi_flag)
{
} else if (mdi_flag) {
/* Set MDIX mode */
*INCA_IP_AUTO_MDIX_LAN_PORTS_OUT |= (1 << INCA_IP_AUTO_MDIX_LAN_GPIO_PIN_RXTX);
mdi_flag = 0;
}
else
{
} else {
/* Set MDI mode */
*INCA_IP_AUTO_MDIX_LAN_PORTS_OUT &= ~(1 << INCA_IP_AUTO_MDIX_LAN_GPIO_PIN_RXTX);
mdi_flag = 1;
}
}
if (!retries)
return -1;
if (!retries) {
goto Fail;
} else {
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC,
(0x1 << 31) | /* RA */
(0x0 << 30) | /* Read */
(0x6 << 21) | /* LAN */
(1 << 16)); /* PHY_BSR */
do {
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, phyReg1);
} while (phyReg1 & (1 << 31));
/* Auto-negotiation / Parallel detection complete
*/
if (phyReg1 & (1 << 5)) {
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC,
(0x1 << 31) | /* RA */
(0x0 << 30) | /* Read */
(0x6 << 21) | /* LAN */
(31 << 16)); /* PHY_SCSR */
do {
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, phyReg31);
} while (phyReg31 & (1 << 31));
switch ((phyReg31 >> 2) & 0x7) {
case INCA_SWITCH_PHY_SPEED_10H:
/* 10Base-T Half-duplex */
regEphy = 0;
break;
case INCA_SWITCH_PHY_SPEED_10F:
/* 10Base-T Full-duplex */
regEphy = INCA_IP_Switch_EPHY_DL;
break;
case INCA_SWITCH_PHY_SPEED_100H:
/* 100Base-TX Half-duplex */
regEphy = INCA_IP_Switch_EPHY_SL;
break;
case INCA_SWITCH_PHY_SPEED_100F:
/* 100Base-TX Full-duplex */
regEphy = INCA_IP_Switch_EPHY_SL | INCA_IP_Switch_EPHY_DL;
break;
}
/* In case of Auto-negotiation,
* update the negotiated PAUSE support status
*/
if (phyReg1 & (1 << 3)) {
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC,
(0x1 << 31) | /* RA */
(0x0 << 30) | /* Read */
(0x6 << 21) | /* LAN */
(6 << 16)); /* PHY_ANER */
do {
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, phyReg6);
} while (phyReg6 & (1 << 31));
/* We are Autoneg-able.
* Is Link partner also able to autoneg?
*/
if (phyReg6 & (1 << 0)) {
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC,
(0x1 << 31) | /* RA */
(0x0 << 30) | /* Read */
(0x6 << 21) | /* LAN */
(4 << 16)); /* PHY_ANAR */
do {
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, phyReg4);
} while (phyReg4 & (1 << 31));
/* We advertise PAUSE capab.
* Does link partner also advertise it?
*/
if (phyReg4 & (1 << 10)) {
SW_WRITE_REG(INCA_IP_Switch_MDIO_ACC,
(0x1 << 31) | /* RA */
(0x0 << 30) | /* Read */
(0x6 << 21) | /* LAN */
(5 << 16)); /* PHY_ANLPAR */
do {
SW_READ_REG(INCA_IP_Switch_MDIO_ACC, phyReg5);
} while (phyReg5 & (1 << 31));
/* Link partner is PAUSE capab.
*/
if (phyReg5 & (1 << 10)) {
regEphy |= INCA_IP_Switch_EPHY_PL;
}
}
}
}
/* Link is up */
regEphy |= INCA_IP_Switch_EPHY_LL;
SW_WRITE_REG(INCA_IP_Switch_EPHY, regEphy);
}
}
return 0;
Fail:
printf("No Link on LAN port\n");
return -1;
}
#endif /* CONFIG_INCA_IP_SWITCH_AMDIX */
#endif
+7 -2
View File
@@ -18,7 +18,7 @@ void NS16550_init (NS16550_t com_port, int baud_divisor)
{
com_port->ier = 0x00;
#ifdef CONFIG_OMAP1510
com_port->mdr1 = 0x7; /* mode select reset TL16C750*/
com_port->mdr1 = 0x7; /* mode select reset TL16C750*/
#endif
com_port->lcr = LCR_BKSE | LCRVAL;
com_port->dll = baud_divisor & 0xff;
@@ -50,7 +50,12 @@ void NS16550_putc (NS16550_t com_port, char c)
char NS16550_getc (NS16550_t com_port)
{
while ((com_port->lsr & LSR_DR) == 0);
while ((com_port->lsr & LSR_DR) == 0) {
#ifdef CONFIG_USB_TTY
extern void usbtty_poll(void);
usbtty_poll();
#endif
}
return (com_port->rbr);
}
+797
View File
@@ -0,0 +1,797 @@
/***********************************************************************
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
*
* $Id: ns9750_eth.c,v 1.2 2004/02/24 14:09:39 mpietrek Exp $
* @Author: Markus Pietrek
* @Descr: Ethernet driver for the NS9750. Uses DMA Engine with polling
* interrupt status. But interrupts are not enabled.
* Only one tx buffer descriptor and the RXA buffer descriptor are used
* Currently no transmit lockup handling is included. eth_send has a 5s
* timeout for sending frames. No retransmits are performed when an
* error occurs.
* @References: [1] NS9750 Hardware Reference, December 2003
* [2] Intel LXT971 Datasheet #249414 Rev. 02
* [3] NS7520 Linux Ethernet Driver
*
* 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 <net.h> /* NetSendPacket */
#include "ns9750_eth.h" /* for Ethernet and PHY */
#ifdef CONFIG_DRIVER_NS9750_ETHERNET
/* some definition to make transistion to linux easier */
#define NS9750_DRIVER_NAME "eth"
#define KERN_WARNING "Warning:"
#define KERN_ERR "Error:"
#define KERN_INFO "Info:"
#if 0
# define DEBUG
#endif
#ifdef DEBUG
# define printk printf
# define DEBUG_INIT 0x0001
# define DEBUG_MINOR 0x0002
# define DEBUG_RX 0x0004
# define DEBUG_TX 0x0008
# define DEBUG_INT 0x0010
# define DEBUG_POLL 0x0020
# define DEBUG_LINK 0x0040
# define DEBUG_MII 0x0100
# define DEBUG_MII_LOW 0x0200
# define DEBUG_MEM 0x0400
# define DEBUG_ERROR 0x4000
# define DEBUG_ERROR_CRIT 0x8000
static int nDebugLvl = DEBUG_ERROR_CRIT;
# define DEBUG_ARGS0( FLG, a0 ) if( ( nDebugLvl & (FLG) ) == (FLG) ) \
printf("%s: " a0, __FUNCTION__, 0, 0, 0, 0, 0, 0 )
# define DEBUG_ARGS1( FLG, a0, a1 ) if( ( nDebugLvl & (FLG) ) == (FLG)) \
printf("%s: " a0, __FUNCTION__, (int)(a1), 0, 0, 0, 0, 0 )
# define DEBUG_ARGS2( FLG, a0, a1, a2 ) if( (nDebugLvl & (FLG)) ==(FLG))\
printf("%s: " a0, __FUNCTION__, (int)(a1), (int)(a2), 0, 0,0,0 )
# define DEBUG_ARGS3( FLG, a0, a1, a2, a3 ) if((nDebugLvl &(FLG))==(FLG))\
printf("%s: "a0,__FUNCTION__,(int)(a1),(int)(a2),(int)(a3),0,0,0)
# define DEBUG_FN( FLG ) if( (nDebugLvl & (FLG)) == (FLG) ) \
printf("\r%s:line %d\n", (int)__FUNCTION__, __LINE__, 0,0,0,0);
# define ASSERT( expr, func ) if( !( expr ) ) { \
printf( "Assertion failed! %s:line %d %s\n", \
(int)__FUNCTION__,__LINE__,(int)(#expr),0,0,0); \
func }
#else /* DEBUG */
# define printk(...)
# define DEBUG_ARGS0( FLG, a0 )
# define DEBUG_ARGS1( FLG, a0, a1 )
# define DEBUG_ARGS2( FLG, a0, a1, a2 )
# define DEBUG_ARGS3( FLG, a0, a1, a2, a3 )
# define DEBUG_FN( n )
# define ASSERT(expr, func)
#endif /* DEBUG */
#define NS9750_MII_NEG_DELAY (5*CFG_HZ) /* in s */
#define TX_TIMEOUT (5*CFG_HZ) /* in s */
/* @TODO move it to eeprom.h */
#define FS_EEPROM_AUTONEG_MASK 0x7
#define FS_EEPROM_AUTONEG_SPEED_MASK 0x1
#define FS_EEPROM_AUTONEG_SPEED_10 0x0
#define FS_EEPROM_AUTONEG_SPEED_100 0x1
#define FS_EEPROM_AUTONEG_DUPLEX_MASK 0x2
#define FS_EEPROM_AUTONEG_DUPLEX_HALF 0x0
#define FS_EEPROM_AUTONEG_DUPLEX_FULL 0x2
#define FS_EEPROM_AUTONEG_ENABLE_MASK 0x4
#define FS_EEPROM_AUTONEG_DISABLE 0x0
#define FS_EEPROM_AUTONEG_ENABLE 0x4
/* buffer descriptors taken from [1] p.306 */
typedef struct
{
unsigned int* punSrc;
unsigned int unLen; /* 11 bits */
unsigned int* punDest; /* unused */
union {
unsigned int unReg;
struct {
unsigned uStatus : 16;
unsigned uRes : 12;
unsigned uFull : 1;
unsigned uEnable : 1;
unsigned uInt : 1;
unsigned uWrap : 1;
} bits;
} s;
} rx_buffer_desc_t;
typedef struct
{
unsigned int* punSrc;
unsigned int unLen; /* 10 bits */
unsigned int* punDest; /* unused */
union {
unsigned int unReg; /* only 32bit accesses may done to NS9750
* eth engine */
struct {
unsigned uStatus : 16;
unsigned uRes : 12;
unsigned uFull : 1;
unsigned uLast : 1;
unsigned uInt : 1;
unsigned uWrap : 1;
} bits;
} s;
} tx_buffer_desc_t;
static int ns9750_eth_reset( void );
static void ns9750_link_force( void );
static void ns9750_link_auto_negotiate( void );
static void ns9750_link_update_egcr( void );
static void ns9750_link_print_changed( void );
/* the PHY stuff */
static char ns9750_mii_identify_phy( void );
static unsigned short ns9750_mii_read( unsigned short uiRegister );
static void ns9750_mii_write( unsigned short uiRegister, unsigned short uiData );
static unsigned int ns9750_mii_get_clock_divisor( unsigned int unMaxMDIOClk );
static unsigned int ns9750_mii_poll_busy( void );
static unsigned int nPhyMaxMdioClock = PHY_MDIO_MAX_CLK;
static unsigned char ucLinkMode = FS_EEPROM_AUTONEG_ENABLE;
static unsigned int uiLastLinkStatus;
static PhyType phyDetected = PHY_NONE;
/* we use only one tx buffer descriptor */
static tx_buffer_desc_t* pTxBufferDesc =
(tx_buffer_desc_t*) get_eth_reg_addr( NS9750_ETH_TXBD );
/* we use only one rx buffer descriptor of the 4 */
static rx_buffer_desc_t aRxBufferDesc[ 4 ];
/***********************************************************************
* @Function: eth_init
* @Return: -1 on failure otherwise 0
* @Descr: Initializes the ethernet engine and uses either FS Forth's default
* MAC addr or the one in environment
***********************************************************************/
int eth_init (bd_t * pbis)
{
/* This default MAC Addr is reserved by FS Forth-Systeme for the case of
EEPROM failures */
unsigned char aucMACAddr[6] = { 0x00, 0x04, 0xf3, 0x00, 0x06, 0x35 };
char *pcTmp = getenv ("ethaddr");
char *pcEnd;
int i;
DEBUG_FN (DEBUG_INIT);
/* no need to check for hardware */
if (!ns9750_eth_reset ())
return -1;
if (pcTmp != NULL)
for (i = 0; i < 6; i++) {
aucMACAddr[i] =
pcTmp ? simple_strtoul (pcTmp, &pcEnd,
16) : 0;
pcTmp = (*pcTmp) ? pcEnd + 1 : pcEnd;
}
/* configure ethernet address */
*get_eth_reg_addr (NS9750_ETH_SA1) =
aucMACAddr[5] << 8 | aucMACAddr[4];
*get_eth_reg_addr (NS9750_ETH_SA2) =
aucMACAddr[3] << 8 | aucMACAddr[2];
*get_eth_reg_addr (NS9750_ETH_SA3) =
aucMACAddr[1] << 8 | aucMACAddr[0];
/* enable hardware */
*get_eth_reg_addr (NS9750_ETH_MAC1) = NS9750_ETH_MAC1_RXEN;
/* the linux kernel may give packets < 60 bytes, for example arp */
*get_eth_reg_addr (NS9750_ETH_MAC2) = NS9750_ETH_MAC2_CRCEN |
NS9750_ETH_MAC2_PADEN | NS9750_ETH_MAC2_HUGE;
/* enable receive and transmit FIFO, use 10/100 Mbps MII */
*get_eth_reg_addr (NS9750_ETH_EGCR1) =
NS9750_ETH_EGCR1_ETXWM |
NS9750_ETH_EGCR1_ERX |
NS9750_ETH_EGCR1_ERXDMA |
NS9750_ETH_EGCR1_ETX |
NS9750_ETH_EGCR1_ETXDMA | NS9750_ETH_EGCR1_ITXA;
/* prepare DMA descriptors */
for (i = 0; i < 4; i++) {
aRxBufferDesc[i].punSrc = 0;
aRxBufferDesc[i].unLen = 0;
aRxBufferDesc[i].s.bits.uWrap = 1;
aRxBufferDesc[i].s.bits.uInt = 1;
aRxBufferDesc[i].s.bits.uEnable = 0;
aRxBufferDesc[i].s.bits.uFull = 0;
}
/* NetRxPackets[ 0 ] is initialized before eth_init is called and never
changes. NetRxPackets is 32bit aligned */
aRxBufferDesc[0].punSrc = (unsigned int *) NetRxPackets[0];
aRxBufferDesc[0].s.bits.uEnable = 1;
aRxBufferDesc[0].unLen = 1522; /* as stated in [1] p.307 */
*get_eth_reg_addr (NS9750_ETH_RXAPTR) =
(unsigned int) &aRxBufferDesc[0];
/* [1] Tab. 221 states less than 5us */
*get_eth_reg_addr (NS9750_ETH_EGCR1) |= NS9750_ETH_EGCR1_ERXINIT;
while (!
(*get_eth_reg_addr (NS9750_ETH_EGSR) & NS9750_ETH_EGSR_RXINIT))
/* wait for finish */
udelay (1);
/* @TODO do we need to clear RXINIT? */
*get_eth_reg_addr (NS9750_ETH_EGCR1) &= ~NS9750_ETH_EGCR1_ERXINIT;
*get_eth_reg_addr (NS9750_ETH_RXFREE) = 0x1;
return 0;
}
/***********************************************************************
* @Function: eth_send
* @Return: -1 on timeout otherwise 1
* @Descr: sends one frame by DMA
***********************************************************************/
int eth_send (volatile void *pPacket, int nLen)
{
ulong ulTimeout;
DEBUG_FN (DEBUG_TX);
/* clear old status values */
*get_eth_reg_addr (NS9750_ETH_EINTR) &=
*get_eth_reg_addr (NS9750_ETH_EINTR) & NS9750_ETH_EINTR_TX_MA;
/* prepare Tx Descriptors */
pTxBufferDesc->punSrc = (unsigned int *) pPacket; /* pPacket is 32bit
* aligned */
pTxBufferDesc->unLen = nLen;
/* only 32bit accesses allowed. wrap, full, interrupt and enabled to 1 */
pTxBufferDesc->s.unReg = 0xf0000000;
/* pTxBufferDesc is the first possible buffer descriptor */
*get_eth_reg_addr (NS9750_ETH_TXPTR) = 0x0;
/* enable processor for next frame */
*get_eth_reg_addr (NS9750_ETH_EGCR2) &= ~NS9750_ETH_EGCR2_TCLER;
*get_eth_reg_addr (NS9750_ETH_EGCR2) |= NS9750_ETH_EGCR2_TCLER;
ulTimeout = get_timer (0);
DEBUG_ARGS0 (DEBUG_TX | DEBUG_MINOR,
"Waiting for transmission to finish\n");
while (!
(*get_eth_reg_addr (NS9750_ETH_EINTR) &
(NS9750_ETH_EINTR_TXDONE | NS9750_ETH_EINTR_TXERR))) {
/* do nothing, wait for completion */
if (get_timer (0) - ulTimeout > TX_TIMEOUT) {
DEBUG_ARGS0 (DEBUG_TX, "Transmit Timed out\n");
return -1;
}
}
DEBUG_ARGS0 (DEBUG_TX | DEBUG_MINOR, "transmitted...\n");
return 0;
}
/***********************************************************************
* @Function: eth_rx
* @Return: size of last frame in bytes or 0 if no frame available
* @Descr: gives one frame to U-Boot which has been copied by DMA engine already
* to NetRxPackets[ 0 ].
***********************************************************************/
int eth_rx (void)
{
int nLen = 0;
unsigned int unStatus;
unStatus =
*get_eth_reg_addr (NS9750_ETH_EINTR) & NS9750_ETH_EINTR_RX_MA;
if (!unStatus)
/* no packet available, return immediately */
return 0;
DEBUG_FN (DEBUG_RX);
/* unLen always < max(nLen) and discard checksum */
nLen = (int) aRxBufferDesc[0].unLen - 4;
/* acknowledge status register */
*get_eth_reg_addr (NS9750_ETH_EINTR) = unStatus;
aRxBufferDesc[0].unLen = 1522;
aRxBufferDesc[0].s.bits.uFull = 0;
/* Buffer A descriptor available again */
*get_eth_reg_addr (NS9750_ETH_RXFREE) |= 0x1;
/* NetReceive may call eth_send. Due to a possible bug of the NS9750 we
* have to acknowledge the received frame before sending a new one */
if (unStatus & NS9750_ETH_EINTR_RXDONEA)
NetReceive (NetRxPackets[0], nLen);
return nLen;
}
/***********************************************************************
* @Function: eth_halt
* @Return: n/a
* @Descr: stops the ethernet engine
***********************************************************************/
void eth_halt (void)
{
DEBUG_FN (DEBUG_INIT);
*get_eth_reg_addr (NS9750_ETH_MAC1) &= ~NS9750_ETH_MAC1_RXEN;
*get_eth_reg_addr (NS9750_ETH_EGCR1) &= ~(NS9750_ETH_EGCR1_ERX |
NS9750_ETH_EGCR1_ERXDMA |
NS9750_ETH_EGCR1_ETX |
NS9750_ETH_EGCR1_ETXDMA);
}
/***********************************************************************
* @Function: ns9750_eth_reset
* @Return: 0 on failure otherwise 1
* @Descr: resets the ethernet interface and the PHY,
* performs auto negotiation or fixed modes
***********************************************************************/
static int ns9750_eth_reset (void)
{
DEBUG_FN (DEBUG_MINOR);
/* Reset MAC */
*get_eth_reg_addr (NS9750_ETH_EGCR1) |= NS9750_ETH_EGCR1_MAC_HRST;
udelay (5); /* according to [1], p.322 */
*get_eth_reg_addr (NS9750_ETH_EGCR1) &= ~NS9750_ETH_EGCR1_MAC_HRST;
/* reset and initialize PHY */
*get_eth_reg_addr (NS9750_ETH_MAC1) &= ~NS9750_ETH_MAC1_SRST;
/* we don't support hot plugging of PHY, therefore we don't reset
phyDetected and nPhyMaxMdioClock here. The risk is if the setting is
incorrect the first open
may detect the PHY correctly but succeding will fail
For reseting the PHY and identifying we have to use the standard
MDIO CLOCK value 2.5 MHz only after hardware reset
After having identified the PHY we will do faster */
*get_eth_reg_addr (NS9750_ETH_MCFG) =
ns9750_mii_get_clock_divisor (nPhyMaxMdioClock);
/* reset PHY */
ns9750_mii_write (PHY_COMMON_CTRL, PHY_COMMON_CTRL_RESET);
ns9750_mii_write (PHY_COMMON_CTRL, 0);
/* @TODO check time */
udelay (3000); /* [2] p.70 says at least 300us reset recovery time. But
go sure, it didn't worked stable at higher timer
frequencies under LxNETES-2.x */
/* MII clock has been setup to default, ns9750_mii_identify_phy should
work for all */
if (!ns9750_mii_identify_phy ()) {
printk (KERN_ERR NS9750_DRIVER_NAME
": Unsupported PHY, aborting\n");
return 0;
}
/* now take the highest MDIO clock possible after detection */
*get_eth_reg_addr (NS9750_ETH_MCFG) =
ns9750_mii_get_clock_divisor (nPhyMaxMdioClock);
/* PHY has been detected, so there can be no abort reason and we can
finish initializing ethernet */
uiLastLinkStatus = 0xff; /* undefined */
if ((ucLinkMode & FS_EEPROM_AUTONEG_ENABLE_MASK) ==
FS_EEPROM_AUTONEG_DISABLE)
/* use parameters defined */
ns9750_link_force ();
else
ns9750_link_auto_negotiate ();
if (phyDetected == PHY_LXT971A)
/* set LED2 to link mode */
ns9750_mii_write (PHY_LXT971_LED_CFG,
PHY_LXT971_LED_CFG_LINK_ACT <<
PHY_LXT971_LED_CFG_SHIFT_LED2);
return 1;
}
/***********************************************************************
* @Function: ns9750_link_force
* @Return: void
* @Descr: configures eth and MII to use the link mode defined in
* ucLinkMode
***********************************************************************/
static void ns9750_link_force (void)
{
unsigned short uiControl;
DEBUG_FN (DEBUG_LINK);
uiControl = ns9750_mii_read (PHY_COMMON_CTRL);
uiControl &= ~(PHY_COMMON_CTRL_SPD_MA |
PHY_COMMON_CTRL_AUTO_NEG | PHY_COMMON_CTRL_DUPLEX);
uiLastLinkStatus = 0;
if ((ucLinkMode & FS_EEPROM_AUTONEG_SPEED_MASK) ==
FS_EEPROM_AUTONEG_SPEED_100) {
uiControl |= PHY_COMMON_CTRL_SPD_100;
uiLastLinkStatus |= PHY_LXT971_STAT2_100BTX;
} else
uiControl |= PHY_COMMON_CTRL_SPD_10;
if ((ucLinkMode & FS_EEPROM_AUTONEG_DUPLEX_MASK) ==
FS_EEPROM_AUTONEG_DUPLEX_FULL) {
uiControl |= PHY_COMMON_CTRL_DUPLEX;
uiLastLinkStatus |= PHY_LXT971_STAT2_DUPLEX_MODE;
}
ns9750_mii_write (PHY_COMMON_CTRL, uiControl);
ns9750_link_print_changed ();
ns9750_link_update_egcr ();
}
/***********************************************************************
* @Function: ns9750_link_auto_negotiate
* @Return: void
* @Descr: performs auto-negotation of link.
***********************************************************************/
static void ns9750_link_auto_negotiate (void)
{
unsigned long ulStartJiffies;
unsigned short uiStatus;
DEBUG_FN (DEBUG_LINK);
/* run auto-negotation */
/* define what we are capable of */
ns9750_mii_write (PHY_COMMON_AUTO_ADV,
PHY_COMMON_AUTO_ADV_100BTXFD |
PHY_COMMON_AUTO_ADV_100BTX |
PHY_COMMON_AUTO_ADV_10BTFD |
PHY_COMMON_AUTO_ADV_10BT |
PHY_COMMON_AUTO_ADV_802_3);
/* start auto-negotiation */
ns9750_mii_write (PHY_COMMON_CTRL,
PHY_COMMON_CTRL_AUTO_NEG |
PHY_COMMON_CTRL_RES_AUTO);
/* wait for completion */
ulStartJiffies = get_ticks ();
while (get_ticks () < ulStartJiffies + NS9750_MII_NEG_DELAY) {
uiStatus = ns9750_mii_read (PHY_COMMON_STAT);
if ((uiStatus &
(PHY_COMMON_STAT_AN_COMP | PHY_COMMON_STAT_LNK_STAT)) ==
(PHY_COMMON_STAT_AN_COMP | PHY_COMMON_STAT_LNK_STAT)) {
/* lucky we are, auto-negotiation succeeded */
ns9750_link_print_changed ();
ns9750_link_update_egcr ();
return;
}
}
DEBUG_ARGS0 (DEBUG_LINK, "auto-negotiation timed out\n");
/* ignore invalid link settings */
}
/***********************************************************************
* @Function: ns9750_link_update_egcr
* @Return: void
* @Descr: updates the EGCR and MAC2 link status after mode change or
* auto-negotation
***********************************************************************/
static void ns9750_link_update_egcr (void)
{
unsigned int unEGCR;
unsigned int unMAC2;
unsigned int unIPGT;
DEBUG_FN (DEBUG_LINK);
unEGCR = *get_eth_reg_addr (NS9750_ETH_EGCR1);
unMAC2 = *get_eth_reg_addr (NS9750_ETH_MAC2);
unIPGT = *get_eth_reg_addr (NS9750_ETH_IPGT) & ~NS9750_ETH_IPGT_MA;
unMAC2 &= ~NS9750_ETH_MAC2_FULLD;
if ((uiLastLinkStatus & PHY_LXT971_STAT2_DUPLEX_MODE)
== PHY_LXT971_STAT2_DUPLEX_MODE) {
unMAC2 |= NS9750_ETH_MAC2_FULLD;
unIPGT |= 0x15; /* see [1] p. 339 */
} else
unIPGT |= 0x12; /* see [1] p. 339 */
*get_eth_reg_addr (NS9750_ETH_MAC2) = unMAC2;
*get_eth_reg_addr (NS9750_ETH_EGCR1) = unEGCR;
*get_eth_reg_addr (NS9750_ETH_IPGT) = unIPGT;
}
/***********************************************************************
* @Function: ns9750_link_print_changed
* @Return: void
* @Descr: checks whether the link status has changed and if so prints
* the new mode
***********************************************************************/
static void ns9750_link_print_changed (void)
{
unsigned short uiStatus;
unsigned short uiControl;
DEBUG_FN (DEBUG_LINK);
uiControl = ns9750_mii_read (PHY_COMMON_CTRL);
if ((uiControl & PHY_COMMON_CTRL_AUTO_NEG) ==
PHY_COMMON_CTRL_AUTO_NEG) {
/* PHY_COMMON_STAT_LNK_STAT is only set on autonegotiation */
uiStatus = ns9750_mii_read (PHY_COMMON_STAT);
if (!(uiStatus & PHY_COMMON_STAT_LNK_STAT)) {
printk (KERN_WARNING NS9750_DRIVER_NAME
": link down\n");
/* @TODO Linux: carrier_off */
} else {
/* @TODO Linux: carrier_on */
if (phyDetected == PHY_LXT971A) {
uiStatus = ns9750_mii_read (PHY_LXT971_STAT2);
uiStatus &= (PHY_LXT971_STAT2_100BTX |
PHY_LXT971_STAT2_DUPLEX_MODE |
PHY_LXT971_STAT2_AUTO_NEG);
/* mask out all uninteresting parts */
}
/* other PHYs must store there link information in
uiStatus as PHY_LXT971 */
}
} else {
/* mode has been forced, so uiStatus should be the same as the
last link status, enforce printing */
uiStatus = uiLastLinkStatus;
uiLastLinkStatus = 0xff;
}
if (uiStatus != uiLastLinkStatus) {
/* save current link status */
uiLastLinkStatus = uiStatus;
/* print new link status */
printk (KERN_INFO NS9750_DRIVER_NAME
": link mode %i Mbps %s duplex %s\n",
(uiStatus & PHY_LXT971_STAT2_100BTX) ? 100 : 10,
(uiStatus & PHY_LXT971_STAT2_DUPLEX_MODE) ? "full" :
"half",
(uiStatus & PHY_LXT971_STAT2_AUTO_NEG) ? "(auto)" :
"");
}
}
/***********************************************************************
* the MII low level stuff
***********************************************************************/
/***********************************************************************
* @Function: ns9750_mii_identify_phy
* @Return: 1 if supported PHY has been detected otherwise 0
* @Descr: checks for supported PHY and prints the IDs.
***********************************************************************/
static char ns9750_mii_identify_phy (void)
{
unsigned short uiID1;
unsigned short uiID2;
unsigned char *szName;
char cRes = 0;
DEBUG_FN (DEBUG_MII);
phyDetected = (PhyType) uiID1 = ns9750_mii_read (PHY_COMMON_ID1);
switch (phyDetected) {
case PHY_LXT971A:
szName = "LXT971A";
uiID2 = ns9750_mii_read (PHY_COMMON_ID2);
nPhyMaxMdioClock = PHY_LXT971_MDIO_MAX_CLK;
cRes = 1;
break;
case PHY_NONE:
default:
/* in case uiID1 == 0 && uiID2 == 0 we may have the wrong
address or reset sets the wrong NS9750_ETH_MCFG_CLKS */
uiID2 = 0;
szName = "unknown";
nPhyMaxMdioClock = PHY_MDIO_MAX_CLK;
phyDetected = PHY_NONE;
}
printk (KERN_INFO NS9750_DRIVER_NAME
": PHY (0x%x, 0x%x) = %s detected\n", uiID1, uiID2, szName);
return cRes;
}
/***********************************************************************
* @Function: ns9750_mii_read
* @Return: the data read from PHY register uiRegister
* @Descr: the data read may be invalid if timed out. If so, a message
* is printed but the invalid data is returned.
* The fixed device address is being used.
***********************************************************************/
static unsigned short ns9750_mii_read (unsigned short uiRegister)
{
DEBUG_FN (DEBUG_MII_LOW);
/* write MII register to be read */
*get_eth_reg_addr (NS9750_ETH_MADR) =
NS9750_ETH_PHY_ADDRESS << 8 | uiRegister;
*get_eth_reg_addr (NS9750_ETH_MCMD) = NS9750_ETH_MCMD_READ;
if (!ns9750_mii_poll_busy ())
printk (KERN_WARNING NS9750_DRIVER_NAME
": MII still busy in read\n");
/* continue to read */
*get_eth_reg_addr (NS9750_ETH_MCMD) = 0;
return (unsigned short) (*get_eth_reg_addr (NS9750_ETH_MRDD));
}
/***********************************************************************
* @Function: ns9750_mii_write
* @Return: nothing
* @Descr: writes the data to the PHY register. In case of a timeout,
* no special handling is performed but a message printed
* The fixed device address is being used.
***********************************************************************/
static void ns9750_mii_write (unsigned short uiRegister,
unsigned short uiData)
{
DEBUG_FN (DEBUG_MII_LOW);
/* write MII register to be written */
*get_eth_reg_addr (NS9750_ETH_MADR) =
NS9750_ETH_PHY_ADDRESS << 8 | uiRegister;
*get_eth_reg_addr (NS9750_ETH_MWTD) = uiData;
if (!ns9750_mii_poll_busy ()) {
printf (KERN_WARNING NS9750_DRIVER_NAME
": MII still busy in write\n");
}
}
/***********************************************************************
* @Function: ns9750_mii_get_clock_divisor
* @Return: the clock divisor that should be used in NS9750_ETH_MCFG_CLKS
* @Descr: if no clock divisor can be calculated for the
* current SYSCLK and the maximum MDIO Clock, a warning is printed
* and the greatest divisor is taken
***********************************************************************/
static unsigned int ns9750_mii_get_clock_divisor (unsigned int unMaxMDIOClk)
{
struct {
unsigned int unSysClkDivisor;
unsigned int unClks; /* field for NS9750_ETH_MCFG_CLKS */
} PHYClockDivisors[] = {
{
4, NS9750_ETH_MCFG_CLKS_4}, {
6, NS9750_ETH_MCFG_CLKS_6}, {
8, NS9750_ETH_MCFG_CLKS_8}, {
10, NS9750_ETH_MCFG_CLKS_10}, {
20, NS9750_ETH_MCFG_CLKS_20}, {
30, NS9750_ETH_MCFG_CLKS_30}, {
40, NS9750_ETH_MCFG_CLKS_40}
};
int nIndexSysClkDiv;
int nArraySize =
sizeof (PHYClockDivisors) / sizeof (PHYClockDivisors[0]);
unsigned int unClks = NS9750_ETH_MCFG_CLKS_40; /* defaults to
greatest div */
DEBUG_FN (DEBUG_INIT);
for (nIndexSysClkDiv = 0; nIndexSysClkDiv < nArraySize;
nIndexSysClkDiv++) {
/* find first sysclock divisor that isn't higher than 2.5 MHz
clock */
if (AHB_CLK_FREQ /
PHYClockDivisors[nIndexSysClkDiv].unSysClkDivisor <=
unMaxMDIOClk) {
unClks = PHYClockDivisors[nIndexSysClkDiv].unClks;
break;
}
}
DEBUG_ARGS2 (DEBUG_INIT,
"Taking MDIO Clock bit mask 0x%0x for max clock %i\n",
unClks, unMaxMDIOClk);
/* return greatest divisor */
return unClks;
}
/***********************************************************************
* @Function: ns9750_mii_poll_busy
* @Return: 0 if timed out otherwise the remaing timeout
* @Descr: waits until the MII has completed a command or it times out
* code may be interrupted by hard interrupts.
* It is not checked what happens on multiple actions when
* the first is still being busy and we timeout.
***********************************************************************/
static unsigned int ns9750_mii_poll_busy (void)
{
unsigned int unTimeout = 10000;
DEBUG_FN (DEBUG_MII_LOW);
while (((*get_eth_reg_addr (NS9750_ETH_MIND) & NS9750_ETH_MIND_BUSY)
== NS9750_ETH_MIND_BUSY) && unTimeout)
unTimeout--;
return unTimeout;
}
#endif /* CONFIG_DRIVER_NS9750_ETHERNET */
+212
View File
@@ -0,0 +1,212 @@
/***********************************************************************
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
*
* $Id: ns9750_serial.c,v 1.1 2004/02/16 10:37:20 mpietrek Exp $
* @Author: Markus Pietrek
* @Descr: Serial driver for the NS9750. Only one UART is supported yet.
* @References: [1] NS9750 Hardware Reference/December 2003
* @TODO: Implement Character GAP Timer when chip is fixed for PLL bypass
*
* 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>
#ifdef CFG_NS9750_UART
#include "ns9750_bbus.h" /* for GPIOs */
#include "ns9750_ser.h" /* for serial configuration */
#define CONSOLE CONFIG_CONS_INDEX
static unsigned int calcBitrateRegister( void );
static unsigned int calcRxCharGapRegister( void );
static char cCharsAvailable; /* Numbers of chars in unCharCache */
static unsigned int unCharCache; /* unCharCache is only valid if
* cCharsAvailable > 0 */
/***********************************************************************
* @Function: serial_init
* @Return: 0
* @Descr: configures GPIOs and UART. Requires BBUS Master Reset turned off
***********************************************************************/
int serial_init( void )
{
unsigned int aunGPIOTxD[] = { 0, 8, 40, 44 };
unsigned int aunGPIORxD[] = { 1, 9, 41, 45 };
cCharsAvailable = 0;
/* configure TxD and RxD pins for their special function */
set_gpio_cfg_reg_val( aunGPIOTxD[ CONSOLE ],
NS9750_GPIO_CFG_FUNC_0 | NS9750_GPIO_CFG_OUTPUT );
set_gpio_cfg_reg_val( aunGPIORxD[ CONSOLE ],
NS9750_GPIO_CFG_FUNC_0 | NS9750_GPIO_CFG_INPUT );
/* configure serial engine */
*get_ser_reg_addr_channel( NS9750_SER_CTRL_A, CONSOLE ) =
NS9750_SER_CTRL_A_CE |
NS9750_SER_CTRL_A_STOP |
NS9750_SER_CTRL_A_WLS_8;
serial_setbrg();
*get_ser_reg_addr_channel( NS9750_SER_CTRL_B, CONSOLE ) =
NS9750_SER_CTRL_B_RCGT;
return 0;
}
/***********************************************************************
* @Function: serial_putc
* @Return: n/a
* @Descr: writes one character to the FIFO. Blocks until FIFO is not full
***********************************************************************/
void serial_putc( const char c )
{
if (c == '\n')
serial_putc( '\r' );
while (!(*get_ser_reg_addr_channel( NS9750_SER_STAT_A, CONSOLE) &
NS9750_SER_STAT_A_TRDY ) ) {
/* do nothing, wait for characters in FIFO sent */
}
*(volatile char*) get_ser_reg_addr_channel( NS9750_SER_FIFO,
CONSOLE) = c;
}
/***********************************************************************
* @Function: serial_puts
* @Return: n/a
* @Descr: writes non-zero string to the FIFO.
***********************************************************************/
void serial_puts( const char *s )
{
while (*s) {
serial_putc( *s++ );
}
}
/***********************************************************************
* @Function: serial_getc
* @Return: the character read
* @Descr: performs only 8bit accesses to the FIFO. No error handling
***********************************************************************/
int serial_getc( void )
{
int i;
while (!serial_tstc() ) {
/* do nothing, wait for incoming characters */
}
/* at least one character in unCharCache */
i = (int) (unCharCache & 0xff);
unCharCache >>= 8;
cCharsAvailable--;
return i;
}
/***********************************************************************
* @Function: serial_tstc
* @Return: 0 if no input available, otherwise != 0
* @Descr: checks for incoming FIFO not empty. Stores the incoming chars in
* unCharCache and the numbers of characters in cCharsAvailable
***********************************************************************/
int serial_tstc( void )
{
unsigned int unRegCache;
if ( cCharsAvailable )
return 1;
unRegCache = *get_ser_reg_addr_channel( NS9750_SER_STAT_A,CONSOLE );
if( unRegCache & NS9750_SER_STAT_A_RBC ) {
*get_ser_reg_addr_channel( NS9750_SER_STAT_A, CONSOLE ) =
NS9750_SER_STAT_A_RBC;
unRegCache = *get_ser_reg_addr_channel( NS9750_SER_STAT_A,
CONSOLE );
}
if ( unRegCache & NS9750_SER_STAT_A_RRDY ) {
cCharsAvailable = (unRegCache & NS9750_SER_STAT_A_RXFDB_MA)>>20;
if ( !cCharsAvailable )
cCharsAvailable = 4;
unCharCache = *get_ser_reg_addr_channel( NS9750_SER_FIFO,
CONSOLE );
return 1;
}
/* no chars available */
return 0;
}
void serial_setbrg( void )
{
*get_ser_reg_addr_channel( NS9750_SER_BITRATE, CONSOLE ) =
calcBitrateRegister();
*get_ser_reg_addr_channel( NS9750_SER_RX_CHAR_TIMER, CONSOLE ) =
calcRxCharGapRegister();
}
/***********************************************************************
* @Function: calcBitrateRegister
* @Return: value for the serial bitrate register
* @Descr: register value depends on clock frequency and baudrate
***********************************************************************/
static unsigned int calcBitrateRegister( void )
{
DECLARE_GLOBAL_DATA_PTR;
return ( NS9750_SER_BITRATE_EBIT |
NS9750_SER_BITRATE_CLKMUX_BCLK |
NS9750_SER_BITRATE_TMODE |
NS9750_SER_BITRATE_TCDR_16 |
NS9750_SER_BITRATE_RCDR_16 |
( ( ( ( CONFIG_SYS_CLK_FREQ / 8 ) / /* BBUS clock,[1] Fig. 38 */
( gd->baudrate * 16 ) ) - 1 ) &
NS9750_SER_BITRATE_N_MA ) );
}
/***********************************************************************
* @Function: calcRxCharGapRegister
* @Return: value for the character gap timer register
* @Descr: register value depends on clock frequency and baudrate. Currently 0
* is used as there is a bug with the gap timer in PLL bypass mode.
***********************************************************************/
static unsigned int calcRxCharGapRegister( void )
{
DECLARE_GLOBAL_DATA_PTR;
return NS9750_SER_RX_CHAR_TIMER_TRUN;
}
#endif /* CFG_NS9750_UART */
+281
View File
@@ -0,0 +1,281 @@
/*
* Basic I2C functions
*
* Copyright (c) 2003 Texas Instruments
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the license found in the file
* named COPYING that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Author: Jian Zhang jzhang@ti.com, Texas Instruments
*
* Copyright (c) 2003 Wolfgang Denk, wd@denx.de
* Rewritten to fit into the current U-Boot framework
*
*/
#include <common.h>
#ifdef CONFIG_DRIVER_OMAP1510_I2C
static void wait_for_bb (void);
static u16 wait_for_pin (void);
void i2c_init (int speed, int slaveadd)
{
u16 scl;
if (inw (I2C_CON) & I2C_CON_EN) {
outw (0, I2C_CON);
udelay (5000);
}
/* 12Mhz I2C module clock */
outw (0, I2C_PSC);
outw (I2C_CON_EN, I2C_CON);
outw (0, I2C_SYSTEST);
/* have to enable intrrupts or OMAP i2c module doesn't work */
outw (I2C_IE_XRDY_IE | I2C_IE_RRDY_IE | I2C_IE_ARDY_IE |
I2C_IE_NACK_IE | I2C_IE_AL_IE, I2C_IE);
scl = (12000000 / 2) / speed - 6;
outw (scl, I2C_SCLL);
outw (scl, I2C_SCLH);
/* own address */
outw (slaveadd, I2C_OA);
outw (0, I2C_CNT);
udelay (1000);
}
static int i2c_read_byte (u8 devaddr, u8 regoffset, u8 * value)
{
int i2c_error = 0;
u16 status;
/* wait until bus not busy */
wait_for_bb ();
/* one byte only */
outw (1, I2C_CNT);
/* set slave address */
outw (devaddr, I2C_SA);
/* no stop bit needed here */
outw (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_TRX, I2C_CON);
status = wait_for_pin ();
if (status & I2C_STAT_XRDY) {
/* Important: have to use byte access */
*(volatile u8 *) (I2C_DATA) = regoffset;
udelay (20000);
if (inw (I2C_STAT) & I2C_STAT_NACK) {
i2c_error = 1;
}
} else {
i2c_error = 1;
}
if (!i2c_error) {
/* free bus, otherwise we can't use a combined transction */
outw (0, I2C_CON);
while (inw (I2C_STAT) || (inw (I2C_CON) & I2C_CON_MST)) {
udelay (10000);
/* Have to clear pending interrupt to clear I2C_STAT */
inw (I2C_IV);
}
wait_for_bb ();
/* set slave address */
outw (devaddr, I2C_SA);
/* read one byte from slave */
outw (1, I2C_CNT);
/* need stop bit here */
outw (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP,
I2C_CON);
status = wait_for_pin ();
if (status & I2C_STAT_RRDY) {
*value = inw (I2C_DATA);
udelay (20000);
} else {
i2c_error = 1;
}
if (!i2c_error) {
outw (I2C_CON_EN, I2C_CON);
while (inw (I2C_STAT)
|| (inw (I2C_CON) & I2C_CON_MST)) {
udelay (10000);
inw (I2C_IV);
}
}
}
return i2c_error;
}
static int i2c_write_byte (u8 devaddr, u8 regoffset, u8 value)
{
int i2c_error = 0;
u16 status;
/* wait until bus not busy */
wait_for_bb ();
/* two bytes */
outw (2, I2C_CNT);
/* set slave address */
outw (devaddr, I2C_SA);
/* stop bit needed here */
outw (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_TRX |
I2C_CON_STP, I2C_CON);
/* wait until state change */
status = wait_for_pin ();
if (status & I2C_STAT_XRDY) {
/* send out two bytes */
outw ((value << 8) + regoffset, I2C_DATA);
/* must have enough delay to allow BB bit to go low */
udelay (30000);
if (inw (I2C_STAT) & I2C_STAT_NACK) {
i2c_error = 1;
}
} else {
i2c_error = 1;
}
if (!i2c_error) {
outw (I2C_CON_EN, I2C_CON);
while (inw (I2C_STAT) || (inw (I2C_CON) & I2C_CON_MST)) {
udelay (1000);
/* have to read to clear intrrupt */
inw (I2C_IV);
}
}
return i2c_error;
}
int i2c_probe (uchar chip)
{
int res = 1;
if (chip == inw (I2C_OA)) {
return res;
}
/* wait until bus not busy */
wait_for_bb ();
/* try to read one byte */
outw (1, I2C_CNT);
/* set slave address */
outw (chip, I2C_SA);
/* stop bit needed here */
outw (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP, I2C_CON);
/* enough delay for the NACK bit set */
udelay (2000);
if (!(inw (I2C_STAT) & I2C_STAT_NACK)) {
res = 0;
} else {
outw (inw (I2C_CON) | I2C_CON_STP, I2C_CON);
udelay (20);
wait_for_bb ();
}
return res;
}
int i2c_read (uchar chip, uint addr, int alen, uchar * buffer, int len)
{
int i;
if (alen > 1) {
printf ("I2C read: addr len %d not supported\n", alen);
return 1;
}
if (addr + len > 256) {
printf ("I2C read: address out of range\n");
return 1;
}
for (i = 0; i < len; i++) {
if (i2c_read_byte (chip, addr + i, &buffer[i])) {
printf ("I2C read: I/O error\n");
i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
return 1;
}
}
return 0;
}
int i2c_write (uchar chip, uint addr, int alen, uchar * buffer, int len)
{
int i;
if (alen > 1) {
printf ("I2C read: addr len %d not supported\n", alen);
return 1;
}
if (addr + len > 256) {
printf ("I2C read: address out of range\n");
return 1;
}
for (i = 0; i < len; i++) {
if (i2c_write_byte (chip, addr + i, buffer[i])) {
printf ("I2C read: I/O error\n");
i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
return 1;
}
}
return 0;
}
static void wait_for_bb (void)
{
int timeout = 10;
while ((inw (I2C_STAT) & I2C_STAT_BB) && timeout--) {
inw (I2C_IV);
udelay (1000);
}
if (timeout <= 0) {
printf ("timed out in wait_for_bb: I2C_STAT=%x\n",
inw (I2C_STAT));
}
}
static u16 wait_for_pin (void)
{
u16 status, iv;
int timeout = 10;
do {
udelay (1000);
status = inw (I2C_STAT);
iv = inw (I2C_IV);
} while (!iv &&
!(status &
(I2C_STAT_ROVR | I2C_STAT_XUDF | I2C_STAT_XRDY |
I2C_STAT_RRDY | I2C_STAT_ARDY | I2C_STAT_NACK |
I2C_STAT_AL)) && timeout--);
if (timeout <= 0) {
printf ("timed out in wait_for_pin: I2C_STAT=%x\n",
inw (I2C_STAT));
}
return status;
}
#endif /* CONFIG_DRIVER_OMAP1510_I2C */
+684
View File
@@ -0,0 +1,684 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* Based on
* linux/drivers/usbd/usbd.c.c - USB Device Core Layer
*
* Copyright (c) 2000, 2001, 2002 Lineo
* Copyright (c) 2001 Hewlett Packard
*
* By:
* Stuart Lynne <sl@lineo.com>,
* Tom Rushworth <tbr@lineo.com>,
* Bruce Balden <balden@lineo.com>
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <malloc.h>
#include "usbdcore.h"
#define MAX_INTERFACES 2
int maxstrings = 20;
/* Global variables ************************************************************************** */
struct usb_string_descriptor **usb_strings;
int usb_devices;
extern struct usb_function_driver ep0_driver;
int registered_functions;
int registered_devices;
char *usbd_device_events[] = {
"DEVICE_UNKNOWN",
"DEVICE_INIT",
"DEVICE_CREATE",
"DEVICE_HUB_CONFIGURED",
"DEVICE_RESET",
"DEVICE_ADDRESS_ASSIGNED",
"DEVICE_CONFIGURED",
"DEVICE_SET_INTERFACE",
"DEVICE_SET_FEATURE",
"DEVICE_CLEAR_FEATURE",
"DEVICE_DE_CONFIGURED",
"DEVICE_BUS_INACTIVE",
"DEVICE_BUS_ACTIVITY",
"DEVICE_POWER_INTERRUPTION",
"DEVICE_HUB_RESET",
"DEVICE_DESTROY",
"DEVICE_FUNCTION_PRIVATE",
};
char *usbd_device_states[] = {
"STATE_INIT",
"STATE_CREATED",
"STATE_ATTACHED",
"STATE_POWERED",
"STATE_DEFAULT",
"STATE_ADDRESSED",
"STATE_CONFIGURED",
"STATE_UNKNOWN",
};
char *usbd_device_requests[] = {
"GET STATUS", /* 0 */
"CLEAR FEATURE", /* 1 */
"RESERVED", /* 2 */
"SET FEATURE", /* 3 */
"RESERVED", /* 4 */
"SET ADDRESS", /* 5 */
"GET DESCRIPTOR", /* 6 */
"SET DESCRIPTOR", /* 7 */
"GET CONFIGURATION", /* 8 */
"SET CONFIGURATION", /* 9 */
"GET INTERFACE", /* 10 */
"SET INTERFACE", /* 11 */
"SYNC FRAME", /* 12 */
};
char *usbd_device_descriptors[] = {
"UNKNOWN", /* 0 */
"DEVICE", /* 1 */
"CONFIG", /* 2 */
"STRING", /* 3 */
"INTERFACE", /* 4 */
"ENDPOINT", /* 5 */
"DEVICE QUALIFIER", /* 6 */
"OTHER SPEED", /* 7 */
"INTERFACE POWER", /* 8 */
};
char *usbd_device_status[] = {
"USBD_OPENING",
"USBD_OK",
"USBD_SUSPENDED",
"USBD_CLOSING",
};
/* Descriptor support functions ************************************************************** */
/**
* usbd_get_string - find and return a string descriptor
* @index: string index to return
*
* Find an indexed string and return a pointer to a it.
*/
struct usb_string_descriptor *usbd_get_string (__u8 index)
{
if (index >= maxstrings) {
return NULL;
}
return usb_strings[index];
}
/* Access to device descriptor functions ***************************************************** */
/* *
* usbd_device_configuration_instance - find a configuration instance for this device
* @device:
* @configuration: index to configuration, 0 - N-1
*
* Get specifed device configuration. Index should be bConfigurationValue-1.
*/
static struct usb_configuration_instance *usbd_device_configuration_instance (struct usb_device_instance *device,
unsigned int port, unsigned int configuration)
{
/* XXX */
configuration = configuration ? configuration - 1 : 0;
if (configuration >= device->configurations) {
return NULL;
}
return device->configuration_instance_array + configuration;
}
/* *
* usbd_device_interface_instance
* @device:
* @configuration: index to configuration, 0 - N-1
* @interface: index to interface
*
* Return the specified interface descriptor for the specified device.
*/
struct usb_interface_instance *usbd_device_interface_instance (struct usb_device_instance *device, int port, int configuration, int interface)
{
struct usb_configuration_instance *configuration_instance;
if ((configuration_instance = usbd_device_configuration_instance (device, port, configuration)) == NULL) {
return NULL;
}
if (interface >= configuration_instance->interfaces) {
return NULL;
}
return configuration_instance->interface_instance_array + interface;
}
/* *
* usbd_device_alternate_descriptor_list
* @device:
* @configuration: index to configuration, 0 - N-1
* @interface: index to interface
* @alternate: alternate setting
*
* Return the specified alternate descriptor for the specified device.
*/
struct usb_alternate_instance *usbd_device_alternate_instance (struct usb_device_instance *device, int port, int configuration, int interface, int alternate)
{
struct usb_interface_instance *interface_instance;
if ((interface_instance = usbd_device_interface_instance (device, port, configuration, interface)) == NULL) {
return NULL;
}
if (alternate >= interface_instance->alternates) {
return NULL;
}
return interface_instance->alternates_instance_array + alternate;
}
/* *
* usbd_device_device_descriptor
* @device: which device
* @configuration: index to configuration, 0 - N-1
* @port: which port
*
* Return the specified configuration descriptor for the specified device.
*/
struct usb_device_descriptor *usbd_device_device_descriptor (struct usb_device_instance *device, int port)
{
return (device->device_descriptor);
}
/**
* usbd_device_configuration_descriptor
* @device: which device
* @port: which port
* @configuration: index to configuration, 0 - N-1
*
* Return the specified configuration descriptor for the specified device.
*/
struct usb_configuration_descriptor *usbd_device_configuration_descriptor (struct
usb_device_instance
*device, int port, int configuration)
{
struct usb_configuration_instance *configuration_instance;
if (!(configuration_instance = usbd_device_configuration_instance (device, port, configuration))) {
return NULL;
}
return (configuration_instance->configuration_descriptor);
}
/**
* usbd_device_interface_descriptor
* @device: which device
* @port: which port
* @configuration: index to configuration, 0 - N-1
* @interface: index to interface
* @alternate: alternate setting
*
* Return the specified interface descriptor for the specified device.
*/
struct usb_interface_descriptor *usbd_device_interface_descriptor (struct usb_device_instance
*device, int port, int configuration, int interface, int alternate)
{
struct usb_interface_instance *interface_instance;
if (!(interface_instance = usbd_device_interface_instance (device, port, configuration, interface))) {
return NULL;
}
if ((alternate < 0) || (alternate >= interface_instance->alternates)) {
return NULL;
}
return (interface_instance->alternates_instance_array[alternate].interface_descriptor);
}
/**
* usbd_device_endpoint_descriptor_index
* @device: which device
* @port: which port
* @configuration: index to configuration, 0 - N-1
* @interface: index to interface
* @alternate: index setting
* @index: which index
*
* Return the specified endpoint descriptor for the specified device.
*/
struct usb_endpoint_descriptor *usbd_device_endpoint_descriptor_index (struct usb_device_instance
*device, int port, int configuration, int interface, int alternate, int index)
{
struct usb_alternate_instance *alternate_instance;
if (!(alternate_instance = usbd_device_alternate_instance (device, port, configuration, interface, alternate))) {
return NULL;
}
if (index >= alternate_instance->endpoints) {
return NULL;
}
return *(alternate_instance->endpoints_descriptor_array + index);
}
/**
* usbd_device_endpoint_transfersize
* @device: which device
* @port: which port
* @configuration: index to configuration, 0 - N-1
* @interface: index to interface
* @index: which index
*
* Return the specified endpoint transfer size;
*/
int usbd_device_endpoint_transfersize (struct usb_device_instance *device, int port, int configuration, int interface, int alternate, int index)
{
struct usb_alternate_instance *alternate_instance;
if (!(alternate_instance = usbd_device_alternate_instance (device, port, configuration, interface, alternate))) {
return 0;
}
if (index >= alternate_instance->endpoints) {
return 0;
}
return *(alternate_instance->endpoint_transfersize_array + index);
}
/**
* usbd_device_endpoint_descriptor
* @device: which device
* @port: which port
* @configuration: index to configuration, 0 - N-1
* @interface: index to interface
* @alternate: alternate setting
* @endpoint: which endpoint
*
* Return the specified endpoint descriptor for the specified device.
*/
struct usb_endpoint_descriptor *usbd_device_endpoint_descriptor (struct usb_device_instance *device, int port, int configuration, int interface, int alternate, int endpoint)
{
struct usb_endpoint_descriptor *endpoint_descriptor;
int i;
for (i = 0; !(endpoint_descriptor = usbd_device_endpoint_descriptor_index (device, port, configuration, interface, alternate, i)); i++) {
if (endpoint_descriptor->bEndpointAddress == endpoint) {
return endpoint_descriptor;
}
}
return NULL;
}
/**
* usbd_endpoint_halted
* @device: point to struct usb_device_instance
* @endpoint: endpoint to check
*
* Return non-zero if endpoint is halted.
*/
int usbd_endpoint_halted (struct usb_device_instance *device, int endpoint)
{
return (device->status == USB_STATUS_HALT);
}
/**
* usbd_rcv_complete - complete a receive
* @endpoint:
* @len:
* @urb_bad:
*
* Called from rcv interrupt to complete.
*/
void usbd_rcv_complete(struct usb_endpoint_instance *endpoint, int len, int urb_bad)
{
if (endpoint) {
struct urb *rcv_urb;
/*usbdbg("len: %d urb: %p\n", len, endpoint->rcv_urb); */
/* if we had an urb then update actual_length, dispatch if neccessary */
if ((rcv_urb = endpoint->rcv_urb)) {
/*usbdbg("actual: %d buffer: %d\n", */
/*rcv_urb->actual_length, rcv_urb->buffer_length); */
/* check the urb is ok, are we adding data less than the packetsize */
if (!urb_bad && (len <= endpoint->rcv_packetSize)) {
/*usbdbg("updating actual_length by %d\n",len); */
/* increment the received data size */
rcv_urb->actual_length += len;
} else {
usberr(" RECV_ERROR actual: %d buffer: %d urb_bad: %d\n",
rcv_urb->actual_length, rcv_urb->buffer_length, urb_bad);
rcv_urb->actual_length = 0;
rcv_urb->status = RECV_ERROR;
}
} else {
usberr("no rcv_urb!");
}
} else {
usberr("no endpoint!");
}
}
/**
* usbd_tx_complete - complete a transmit
* @endpoint:
* @resetart:
*
* Called from tx interrupt to complete.
*/
void usbd_tx_complete (struct usb_endpoint_instance *endpoint)
{
if (endpoint) {
struct urb *tx_urb;
/* if we have a tx_urb advance or reset, finish if complete */
if ((tx_urb = endpoint->tx_urb)) {
int sent = endpoint->last;
endpoint->sent += sent;
endpoint->last -= sent;
if( (endpoint->tx_urb->actual_length - endpoint->sent) <= 0 ) {
tx_urb->actual_length = 0;
endpoint->sent = 0;
endpoint->last = 0;
/* Remove from active, save for re-use */
urb_detach(tx_urb);
urb_append(&endpoint->done, tx_urb);
/*usbdbg("done->next %p, tx_urb %p, done %p", */
/* endpoint->done.next, tx_urb, &endpoint->done); */
endpoint->tx_urb = first_urb_detached(&endpoint->tx);
if( endpoint->tx_urb ) {
endpoint->tx_queue--;
usbdbg("got urb from tx list");
}
if( !endpoint->tx_urb ) {
/*usbdbg("taking urb from done list"); */
endpoint->tx_urb = first_urb_detached(&endpoint->done);
}
if( !endpoint->tx_urb ) {
usbdbg("allocating new urb for tx_urb");
endpoint->tx_urb = usbd_alloc_urb(tx_urb->device, endpoint);
}
}
}
}
}
/* URB linked list functions ***************************************************** */
/*
* Initialize an urb_link to be a single element list.
* If the urb_link is being used as a distinguished list head
* the list is empty when the head is the only link in the list.
*/
void urb_link_init (urb_link * ul)
{
if (ul) {
ul->prev = ul->next = ul;
}
}
/*
* Detach an urb_link from a list, and set it
* up as a single element list, so no dangling
* pointers can be followed, and so it can be
* joined to another list if so desired.
*/
void urb_detach (struct urb *urb)
{
if (urb) {
urb_link *ul = &urb->link;
ul->next->prev = ul->prev;
ul->prev->next = ul->next;
urb_link_init (ul);
}
}
/*
* Return the first urb_link in a list with a distinguished
* head "hd", or NULL if the list is empty. This will also
* work as a predicate, returning NULL if empty, and non-NULL
* otherwise.
*/
urb_link *first_urb_link (urb_link * hd)
{
urb_link *nx;
if (NULL != hd && NULL != (nx = hd->next) && nx != hd) {
/* There is at least one element in the list */
/* (besides the distinguished head). */
return (nx);
}
/* The list is empty */
return (NULL);
}
/*
* Return the first urb in a list with a distinguished
* head "hd", or NULL if the list is empty.
*/
struct urb *first_urb (urb_link * hd)
{
urb_link *nx;
if (NULL == (nx = first_urb_link (hd))) {
/* The list is empty */
return (NULL);
}
return (p2surround (struct urb, link, nx));
}
/*
* Detach and return the first urb in a list with a distinguished
* head "hd", or NULL if the list is empty.
*
*/
struct urb *first_urb_detached (urb_link * hd)
{
struct urb *urb;
if ((urb = first_urb (hd))) {
urb_detach (urb);
}
return urb;
}
/*
* Append an urb_link (or a whole list of
* urb_links) to the tail of another list
* of urb_links.
*/
void urb_append (urb_link * hd, struct urb *urb)
{
if (hd && urb) {
urb_link *new = &urb->link;
/* This allows the new urb to be a list of urbs, */
/* with new pointing at the first, but the link */
/* must be initialized. */
/* Order is important here... */
urb_link *pul = hd->prev;
new->prev->next = hd;
hd->prev = new->prev;
new->prev = pul;
pul->next = new;
}
}
/* URB create/destroy functions ***************************************************** */
/**
* usbd_alloc_urb - allocate an URB appropriate for specified endpoint
* @device: device instance
* @endpoint: endpoint
*
* Allocate an urb structure. The usb device urb structure is used to
* contain all data associated with a transfer, including a setup packet for
* control transfers.
*
* NOTE: endpoint_address MUST contain a direction flag.
*/
struct urb *usbd_alloc_urb (struct usb_device_instance *device, struct usb_endpoint_instance *endpoint)
{
struct urb *urb;
if( !(urb = (struct urb*)malloc(sizeof(struct urb))) ) {
usberr(" F A T A L: malloc(%u) FAILED!!!!", sizeof(struct urb));
return NULL;
}
/* Fill in known fields */
memset(urb, 0, sizeof(struct urb));
urb->endpoint = endpoint;
urb->device = device;
urb->buffer = (u8*)urb->buffer_data;
urb->buffer_length = sizeof(urb->buffer_data);
urb_link_init (&urb->link);
return urb;
}
/**
* usbd_dealloc_urb - deallocate an URB and associated buffer
* @urb: pointer to an urb structure
*
* Deallocate an urb structure and associated data.
*/
void usbd_dealloc_urb (struct urb *urb)
{
if (urb) {
free (urb);
}
}
/* Event signaling functions ***************************************************** */
/**
* usbd_device_event - called to respond to various usb events
* @device: pointer to struct device
* @event: event to respond to
*
* Used by a Bus driver to indicate an event.
*/
void usbd_device_event_irq (struct usb_device_instance *device, usb_device_event_t event, int data)
{
usb_device_state_t state;
if (!device || !device->bus) {
usberr("(%p,%d) NULL device or device->bus", device, event);
return;
}
state = device->device_state;
usbinfo("%s", usbd_device_events[event]);
switch (event) {
case DEVICE_UNKNOWN:
break;
case DEVICE_INIT:
device->device_state = STATE_INIT;
break;
case DEVICE_CREATE:
device->device_state = STATE_ATTACHED;
break;
case DEVICE_HUB_CONFIGURED:
device->device_state = STATE_POWERED;
break;
case DEVICE_RESET:
device->device_state = STATE_DEFAULT;
device->address = 0;
break;
case DEVICE_ADDRESS_ASSIGNED:
device->device_state = STATE_ADDRESSED;
break;
case DEVICE_CONFIGURED:
device->device_state = STATE_CONFIGURED;
break;
case DEVICE_DE_CONFIGURED:
device->device_state = STATE_ADDRESSED;
break;
case DEVICE_BUS_INACTIVE:
if (device->status != USBD_CLOSING) {
device->status = USBD_SUSPENDED;
}
break;
case DEVICE_BUS_ACTIVITY:
if (device->status != USBD_CLOSING) {
device->status = USBD_OK;
}
break;
case DEVICE_SET_INTERFACE:
break;
case DEVICE_SET_FEATURE:
break;
case DEVICE_CLEAR_FEATURE:
break;
case DEVICE_POWER_INTERRUPTION:
device->device_state = STATE_POWERED;
break;
case DEVICE_HUB_RESET:
device->device_state = STATE_ATTACHED;
break;
case DEVICE_DESTROY:
device->device_state = STATE_UNKNOWN;
break;
case DEVICE_FUNCTION_PRIVATE:
break;
default:
usbdbg("event %d - not handled",event);
break;
}
/*usbdbg("%s event: %d oldstate: %d newstate: %d status: %d address: %d",
device->name, event, state,
device->device_state, device->status, device->address); */
/* tell the bus interface driver */
if( device->event ) {
/* usbdbg("calling device->event"); */
device->event(device, event, data);
}
}
+686
View File
@@ -0,0 +1,686 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* Based on
* linux/drivers/usbd/ep0.c
*
* Copyright (c) 2000, 2001, 2002 Lineo
* Copyright (c) 2001 Hewlett Packard
*
* By:
* Stuart Lynne <sl@lineo.com>,
* Tom Rushworth <tbr@lineo.com>,
* Bruce Balden <balden@lineo.com>
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/*
* This is the builtin ep0 control function. It implements all required functionality
* for responding to control requests (SETUP packets).
*
* XXX
*
* Currently we do not pass any SETUP packets (or other) to the configured
* function driver. This may need to change.
*
* XXX
*/
#include <common.h>
#if defined(CONFIG_OMAP1510) && defined(CONFIG_USB_DEVICE)
#include "usbdcore.h"
#if 0
#define dbg_ep0(lvl,fmt,args...) serial_printf("[%s] %s:%d: "fmt"\n",__FILE__,__FUNCTION__,__LINE__,##args)
#else
#define dbg_ep0(lvl,fmt,args...)
#endif
/* EP0 Configuration Set ********************************************************************* */
/**
* ep0_get_status - fill in URB data with appropriate status
* @device:
* @urb:
* @index:
* @requesttype:
*
*/
static int ep0_get_status (struct usb_device_instance *device,
struct urb *urb, int index, int requesttype)
{
char *cp;
urb->actual_length = 2;
cp = urb->buffer;
cp[0] = cp[1] = 0;
switch (requesttype) {
case USB_REQ_RECIPIENT_DEVICE:
cp[0] = USB_STATUS_SELFPOWERED;
break;
case USB_REQ_RECIPIENT_INTERFACE:
break;
case USB_REQ_RECIPIENT_ENDPOINT:
cp[0] = usbd_endpoint_halted (device, index);
break;
case USB_REQ_RECIPIENT_OTHER:
urb->actual_length = 0;
default:
break;
}
dbg_ep0 (2, "%02x %02x", cp[0], cp[1]);
return 0;
}
/**
* ep0_get_one
* @device:
* @urb:
* @result:
*
* Set a single byte value in the urb send buffer. Return non-zero to signal
* a request error.
*/
static int ep0_get_one (struct usb_device_instance *device, struct urb *urb,
__u8 result)
{
urb->actual_length = 1; /* XXX 2? */
((char *) urb->buffer)[0] = result;
return 0;
}
/**
* copy_config
* @urb: pointer to urb
* @data: pointer to configuration data
* @length: length of data
*
* Copy configuration data to urb transfer buffer if there is room for it.
*/
static void copy_config (struct urb *urb, void *data, int max_length,
int max_buf)
{
int available;
int length;
/*dbg_ep0(3, "-> actual: %d buf: %d max_buf: %d max_length: %d data: %p", */
/* urb->actual_length, urb->buffer_length, max_buf, max_length, data); */
if (!data) {
dbg_ep0 (1, "data is NULL");
return;
}
if (!(length = *(unsigned char *) data)) {
dbg_ep0 (1, "length is zero");
return;
}
if (length > max_length) {
dbg_ep0 (1, "length: %d >= max_length: %d", length,
max_length);
return;
}
/*dbg_ep0(1, " actual: %d buf: %d max_buf: %d max_length: %d length: %d", */
/* urb->actual_length, urb->buffer_length, max_buf, max_length, length); */
if ((available =
/*urb->buffer_length */ max_buf - urb->actual_length) <= 0) {
return;
}
/*dbg_ep0(1, "actual: %d buf: %d max_buf: %d length: %d available: %d", */
/* urb->actual_length, urb->buffer_length, max_buf, length, available); */
if (length > available) {
length = available;
}
/*dbg_ep0(1, "actual: %d buf: %d max_buf: %d length: %d available: %d", */
/* urb->actual_length, urb->buffer_length, max_buf, length, available); */
memcpy (urb->buffer + urb->actual_length, data, length);
urb->actual_length += length;
dbg_ep0 (3,
"copy_config: <- actual: %d buf: %d max_buf: %d max_length: %d available: %d",
urb->actual_length, urb->buffer_length, max_buf, max_length,
available);
}
/**
* ep0_get_descriptor
* @device:
* @urb:
* @max:
* @descriptor_type:
* @index:
*
* Called by ep0_rx_process for a get descriptor device command. Determine what
* descriptor is being requested, copy to send buffer. Return zero if ok to send,
* return non-zero to signal a request error.
*/
static int ep0_get_descriptor (struct usb_device_instance *device,
struct urb *urb, int max, int descriptor_type,
int index)
{
int port = 0; /* XXX compound device */
char *cp;
/*dbg_ep0(3, "max: %x type: %x index: %x", max, descriptor_type, index); */
if (!urb || !urb->buffer || !urb->buffer_length
|| (urb->buffer_length < 255)) {
dbg_ep0 (2, "invalid urb %p", urb);
return -1L;
}
/* setup tx urb */
urb->actual_length = 0;
cp = urb->buffer;
dbg_ep0 (2, "%s", USBD_DEVICE_DESCRIPTORS (descriptor_type));
switch (descriptor_type) {
case USB_DESCRIPTOR_TYPE_DEVICE:
{
struct usb_device_descriptor *device_descriptor;
if (!
(device_descriptor =
usbd_device_device_descriptor (device, port))) {
return -1;
}
/* copy descriptor for this device */
copy_config (urb, device_descriptor,
sizeof (struct usb_device_descriptor),
max);
/* correct the correct control endpoint 0 max packet size into the descriptor */
device_descriptor =
(struct usb_device_descriptor *) urb->buffer;
device_descriptor->bMaxPacketSize0 =
urb->device->bus->maxpacketsize;
}
/*dbg_ep0(3, "copied device configuration, actual_length: %x", urb->actual_length); */
break;
case USB_DESCRIPTOR_TYPE_CONFIGURATION:
{
int bNumInterface;
struct usb_configuration_descriptor
*configuration_descriptor;
struct usb_device_descriptor *device_descriptor;
if (!
(device_descriptor =
usbd_device_device_descriptor (device, port))) {
return -1;
}
/*dbg_ep0(2, "%d %d", index, device_descriptor->bNumConfigurations); */
if (index > device_descriptor->bNumConfigurations) {
dbg_ep0 (0, "index too large: %d > %d", index,
device_descriptor->
bNumConfigurations);
return -1;
}
if (!
(configuration_descriptor =
usbd_device_configuration_descriptor (device,
port,
index))) {
dbg_ep0 (0,
"usbd_device_configuration_descriptor failed: %d",
index);
return -1;
}
copy_config (urb, configuration_descriptor,
sizeof (struct
usb_configuration_descriptor),
max);
/* iterate across interfaces for specified configuration */
dbg_ep0 (0, "bNumInterfaces: %d",
configuration_descriptor->bNumInterfaces);
for (bNumInterface = 0;
bNumInterface <
configuration_descriptor->bNumInterfaces;
bNumInterface++) {
int bAlternateSetting;
struct usb_interface_instance
*interface_instance;
dbg_ep0 (3, "[%d] bNumInterfaces: %d",
bNumInterface,
configuration_descriptor->bNumInterfaces);
if (! (interface_instance = usbd_device_interface_instance (device,
port, index, bNumInterface)))
{
dbg_ep0 (3, "[%d] interface_instance NULL",
bNumInterface);
return -1;
}
/* iterate across interface alternates */
for (bAlternateSetting = 0;
bAlternateSetting < interface_instance->alternates;
bAlternateSetting++) {
/*int class; */
int bNumEndpoint;
struct usb_interface_descriptor *interface_descriptor;
struct usb_alternate_instance *alternate_instance;
dbg_ep0 (3, "[%d:%d] alternates: %d",
bNumInterface,
bAlternateSetting,
interface_instance->alternates);
if (! (alternate_instance = usbd_device_alternate_instance (device, port, index, bNumInterface, bAlternateSetting))) {
dbg_ep0 (3, "[%d] alternate_instance NULL",
bNumInterface);
return -1;
}
/* copy descriptor for this interface */
copy_config (urb, alternate_instance->interface_descriptor,
sizeof (struct usb_interface_descriptor),
max);
/*dbg_ep0(3, "[%d:%d] classes: %d endpoints: %d", bNumInterface, bAlternateSetting, */
/* alternate_instance->classes, alternate_instance->endpoints); */
/* iterate across classes for this alternate interface */
#if 0
for (class = 0;
class < alternate_instance->classes;
class++) {
struct usb_class_descriptor *class_descriptor;
/*dbg_ep0(3, "[%d:%d:%d] classes: %d", bNumInterface, bAlternateSetting, */
/* class, alternate_instance->classes); */
if (!(class_descriptor = usbd_device_class_descriptor_index (device, port, index, bNumInterface, bAlternateSetting, class))) {
dbg_ep0 (3, "[%d] class NULL",
class);
return -1;
}
/* copy descriptor for this class */
copy_config (urb, class_descriptor,
sizeof (struct usb_class_descriptor),
max);
}
#endif
/* iterate across endpoints for this alternate interface */
interface_descriptor = alternate_instance->interface_descriptor;
for (bNumEndpoint = 0;
bNumEndpoint < alternate_instance->endpoints;
bNumEndpoint++) {
struct usb_endpoint_descriptor *endpoint_descriptor;
dbg_ep0 (3, "[%d:%d:%d] endpoint: %d",
bNumInterface,
bAlternateSetting,
bNumEndpoint,
interface_descriptor->
bNumEndpoints);
if (!(endpoint_descriptor = usbd_device_endpoint_descriptor_index (device, port, index, bNumInterface, bAlternateSetting, bNumEndpoint))) {
dbg_ep0 (3, "[%d] endpoint NULL",
bNumEndpoint);
return -1;
}
/* copy descriptor for this endpoint */
copy_config (urb, endpoint_descriptor,
sizeof (struct usb_endpoint_descriptor),
max);
}
}
}
dbg_ep0 (3, "lengths: %d %d",
le16_to_cpu (configuration_descriptor->wTotalLength),
urb->actual_length);
}
break;
case USB_DESCRIPTOR_TYPE_STRING:
{
struct usb_string_descriptor *string_descriptor;
if (!(string_descriptor = usbd_get_string (index))) {
return -1;
}
/*dbg_ep0(3, "string_descriptor: %p", string_descriptor); */
copy_config (urb, string_descriptor, string_descriptor->bLength, max);
}
break;
case USB_DESCRIPTOR_TYPE_INTERFACE:
return -1;
case USB_DESCRIPTOR_TYPE_ENDPOINT:
return -1;
case USB_DESCRIPTOR_TYPE_HID:
{
return -1; /* unsupported at this time */
#if 0
int bNumInterface =
le16_to_cpu (urb->device_request.wIndex);
int bAlternateSetting = 0;
int class = 0;
struct usb_class_descriptor *class_descriptor;
if (!(class_descriptor =
usbd_device_class_descriptor_index (device,
port, 0,
bNumInterface,
bAlternateSetting,
class))
|| class_descriptor->descriptor.hid.bDescriptorType != USB_DT_HID) {
dbg_ep0 (3, "[%d] interface is not HID",
bNumInterface);
return -1;
}
/* copy descriptor for this class */
copy_config (urb, class_descriptor,
class_descriptor->descriptor.hid.bLength,
max);
#endif
}
break;
case USB_DESCRIPTOR_TYPE_REPORT:
{
return -1; /* unsupported at this time */
#if 0
int bNumInterface =
le16_to_cpu (urb->device_request.wIndex);
int bAlternateSetting = 0;
int class = 0;
struct usb_class_report_descriptor *report_descriptor;
if (!(report_descriptor =
usbd_device_class_report_descriptor_index
(device, port, 0, bNumInterface,
bAlternateSetting, class))
|| report_descriptor->bDescriptorType !=
USB_DT_REPORT) {
dbg_ep0 (3, "[%d] descriptor is not REPORT",
bNumInterface);
return -1;
}
/* copy report descriptor for this class */
/*copy_config(urb, &report_descriptor->bData[0], report_descriptor->wLength, max); */
if (max - urb->actual_length > 0) {
int length =
MIN (report_descriptor->wLength,
max - urb->actual_length);
memcpy (urb->buffer + urb->actual_length,
&report_descriptor->bData[0], length);
urb->actual_length += length;
}
#endif
}
break;
default:
return -1;
}
dbg_ep0 (1, "urb: buffer: %p buffer_length: %2d actual_length: %2d packet size: %2d",
urb->buffer, urb->buffer_length, urb->actual_length,
device->bus->endpoint_array[0].tx_packetSize);
/*
if ((urb->actual_length < max) && !(urb->actual_length % device->bus->endpoint_array[0].tx_packetSize)) {
dbg_ep0(0, "adding null byte");
urb->buffer[urb->actual_length++] = 0;
dbg_ep0(0, "urb: buffer_length: %2d actual_length: %2d packet size: %2d",
urb->buffer_length, urb->actual_length device->bus->endpoint_array[0].tx_packetSize);
}
*/
return 0;
}
/**
* ep0_recv_setup - called to indicate URB has been received
* @urb: pointer to struct urb
*
* Check if this is a setup packet, process the device request, put results
* back into the urb and return zero or non-zero to indicate success (DATA)
* or failure (STALL).
*
*/
int ep0_recv_setup (struct urb *urb)
{
/*struct usb_device_request *request = urb->buffer; */
/*struct usb_device_instance *device = urb->device; */
struct usb_device_request *request;
struct usb_device_instance *device;
int address;
dbg_ep0 (0, "entering ep0_recv_setup()");
if (!urb || !urb->device) {
dbg_ep0 (3, "invalid URB %p", urb);
return -1;
}
request = &urb->device_request;
device = urb->device;
dbg_ep0 (3, "urb: %p device: %p", urb, urb->device);
/*dbg_ep0(2, "- - - - - - - - - -"); */
dbg_ep0 (2,
"bmRequestType:%02x bRequest:%02x wValue:%04x wIndex:%04x wLength:%04x %s",
request->bmRequestType, request->bRequest,
le16_to_cpu (request->wValue), le16_to_cpu (request->wIndex),
le16_to_cpu (request->wLength),
USBD_DEVICE_REQUESTS (request->bRequest));
/* handle USB Standard Request (c.f. USB Spec table 9-2) */
if ((request->bmRequestType & USB_REQ_TYPE_MASK) != 0) {
dbg_ep0 (1, "non standard request: %x",
request->bmRequestType & USB_REQ_TYPE_MASK);
return -1; /* Stall here */
}
switch (device->device_state) {
case STATE_CREATED:
case STATE_ATTACHED:
case STATE_POWERED:
/* It actually is important to allow requests in these states,
* Windows will request descriptors before assigning an
* address to the client.
*/
/*dbg_ep0 (1, "request %s not allowed in this state: %s", */
/* USBD_DEVICE_REQUESTS(request->bRequest), */
/* usbd_device_states[device->device_state]); */
/*return -1; */
break;
case STATE_INIT:
case STATE_DEFAULT:
switch (request->bRequest) {
case USB_REQ_GET_STATUS:
case USB_REQ_GET_INTERFACE:
case USB_REQ_SYNCH_FRAME: /* XXX should never see this (?) */
case USB_REQ_CLEAR_FEATURE:
case USB_REQ_SET_FEATURE:
case USB_REQ_SET_DESCRIPTOR:
/* case USB_REQ_SET_CONFIGURATION: */
case USB_REQ_SET_INTERFACE:
dbg_ep0 (1,
"request %s not allowed in DEFAULT state: %s",
USBD_DEVICE_REQUESTS (request->bRequest),
usbd_device_states[device->device_state]);
return -1;
case USB_REQ_SET_CONFIGURATION:
case USB_REQ_SET_ADDRESS:
case USB_REQ_GET_DESCRIPTOR:
case USB_REQ_GET_CONFIGURATION:
break;
}
case STATE_ADDRESSED:
case STATE_CONFIGURED:
break;
case STATE_UNKNOWN:
dbg_ep0 (1, "request %s not allowed in UNKNOWN state: %s",
USBD_DEVICE_REQUESTS (request->bRequest),
usbd_device_states[device->device_state]);
return -1;
}
/* handle all requests that return data (direction bit set on bm RequestType) */
if ((request->bmRequestType & USB_REQ_DIRECTION_MASK)) {
dbg_ep0 (3, "Device-to-Host");
switch (request->bRequest) {
case USB_REQ_GET_STATUS:
return ep0_get_status (device, urb, request->wIndex,
request->bmRequestType &
USB_REQ_RECIPIENT_MASK);
case USB_REQ_GET_DESCRIPTOR:
return ep0_get_descriptor (device, urb,
le16_to_cpu (request->wLength),
le16_to_cpu (request->wValue) >> 8,
le16_to_cpu (request->wValue) & 0xff);
case USB_REQ_GET_CONFIGURATION:
return ep0_get_one (device, urb,
device->configuration);
case USB_REQ_GET_INTERFACE:
return ep0_get_one (device, urb, device->alternate);
case USB_REQ_SYNCH_FRAME: /* XXX should never see this (?) */
return -1;
case USB_REQ_CLEAR_FEATURE:
case USB_REQ_SET_FEATURE:
case USB_REQ_SET_ADDRESS:
case USB_REQ_SET_DESCRIPTOR:
case USB_REQ_SET_CONFIGURATION:
case USB_REQ_SET_INTERFACE:
return -1;
}
}
/* handle the requests that do not return data */
else {
/*dbg_ep0(3, "Host-to-Device"); */
switch (request->bRequest) {
case USB_REQ_CLEAR_FEATURE:
case USB_REQ_SET_FEATURE:
dbg_ep0 (0, "Host-to-Device");
switch (request->
bmRequestType & USB_REQ_RECIPIENT_MASK) {
case USB_REQ_RECIPIENT_DEVICE:
/* XXX DEVICE_REMOTE_WAKEUP or TEST_MODE would be added here */
/* XXX fall through for now as we do not support either */
case USB_REQ_RECIPIENT_INTERFACE:
case USB_REQ_RECIPIENT_OTHER:
dbg_ep0 (0, "request %s not",
USBD_DEVICE_REQUESTS (request->bRequest));
default:
return -1;
case USB_REQ_RECIPIENT_ENDPOINT:
dbg_ep0 (0, "ENDPOINT: %x", le16_to_cpu (request->wValue));
if (le16_to_cpu (request->wValue) == USB_ENDPOINT_HALT) {
/*return usbd_device_feature (device, le16_to_cpu (request->wIndex), */
/* request->bRequest == USB_REQ_SET_FEATURE); */
/* NEED TO IMPLEMENT THIS!!! */
return -1;
} else {
dbg_ep0 (1, "request %s bad wValue: %04x",
USBD_DEVICE_REQUESTS
(request->bRequest),
le16_to_cpu (request->wValue));
return -1;
}
}
case USB_REQ_SET_ADDRESS:
/* check if this is a re-address, reset first if it is (this shouldn't be possible) */
if (device->device_state != STATE_DEFAULT) {
dbg_ep0 (1, "set_address: %02x state: %s",
le16_to_cpu (request->wValue),
usbd_device_states[device->device_state]);
return -1;
}
address = le16_to_cpu (request->wValue);
if ((address & 0x7f) != address) {
dbg_ep0 (1, "invalid address %04x %04x",
address, address & 0x7f);
return -1;
}
device->address = address;
/*dbg_ep0(2, "address: %d %d %d", */
/* request->wValue, le16_to_cpu(request->wValue), device->address); */
serial_printf ("DEVICE_ADDRESS_ASSIGNED.. event?\n");
return 0;
case USB_REQ_SET_DESCRIPTOR: /* XXX should we support this? */
dbg_ep0 (0, "set descriptor: NOT SUPPORTED");
return -1;
case USB_REQ_SET_CONFIGURATION:
/* c.f. 9.4.7 - the top half of wValue is reserved */
/* */
if ((device->configuration =
le16_to_cpu (request->wValue) & 0x7f) != 0) {
/* c.f. 9.4.7 - zero is the default or addressed state, in our case this */
/* is the same is configuration zero */
device->configuration = 0; /* TBR - ?????? */
}
/* reset interface and alternate settings */
device->interface = device->alternate = 0;
/*dbg_ep0(2, "set configuration: %d", device->configuration); */
/*serial_printf("DEVICE_CONFIGURED.. event?\n"); */
return 0;
case USB_REQ_SET_INTERFACE:
device->interface = le16_to_cpu (request->wIndex);
device->alternate = le16_to_cpu (request->wValue);
/*dbg_ep0(2, "set interface: %d alternate: %d", device->interface, device->alternate); */
serial_printf ("DEVICE_SET_INTERFACE.. event?\n");
return 0;
case USB_REQ_GET_STATUS:
case USB_REQ_GET_DESCRIPTOR:
case USB_REQ_GET_CONFIGURATION:
case USB_REQ_GET_INTERFACE:
case USB_REQ_SYNCH_FRAME: /* XXX should never see this (?) */
return -1;
}
}
return -1;
}
#endif
File diff suppressed because it is too large. Load diff
+647
View File
@@ -0,0 +1,647 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* 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>
#ifdef CONFIG_USB_TTY
#include <circbuf.h>
#include <devices.h>
#include "usbtty.h"
#if 0
#define TTYDBG(fmt,args...) serial_printf("[%s] %s %d: "fmt, __FILE__,__FUNCTION__,__LINE__,##args)
#else
#define TTYDBG(fmt,args...) do{}while(0)
#endif
#if 0
#define TTYERR(fmt,args...) serial_printf("ERROR![%s] %s %d: "fmt, __FILE__,__FUNCTION__,__LINE__,##args)
#else
#define TTYERR(fmt,args...) do{}while(0)
#endif
/*
* Buffers to hold input and output data
*/
#define USBTTY_BUFFER_SIZE 256
static circbuf_t usbtty_input;
static circbuf_t usbtty_output;
/*
* Instance variables
*/
static device_t usbttydev;
static struct usb_device_instance device_instance[1];
static struct usb_bus_instance bus_instance[1];
static struct usb_configuration_instance config_instance[NUM_CONFIGS];
static struct usb_interface_instance interface_instance[NUM_INTERFACES];
static struct usb_alternate_instance alternate_instance[NUM_INTERFACES];
static struct usb_endpoint_instance endpoint_instance[NUM_ENDPOINTS+1]; /* one extra for control endpoint */
/*
* Static allocation of urbs
*/
#define RECV_ENDPOINT 1
#define TX_ENDPOINT 2
/*
* Global flag
*/
int usbtty_configured_flag = 0;
/*
* Descriptors
*/
static u8 wstrLang[4] = {4,USB_DT_STRING,0x9,0x4};
static u8 wstrManufacturer[2 + 2*(sizeof(CONFIG_USBD_MANUFACTURER)-1)];
static u8 wstrProduct[2 + 2*(sizeof(CONFIG_USBD_PRODUCT_NAME)-1)];
static u8 wstrSerial[2 + 2*(sizeof(CONFIG_USBD_SERIAL_NUMBER)-1)];
static u8 wstrConfiguration[2 + 2*(sizeof(CONFIG_USBD_CONFIGURATION_STR)-1)];
static u8 wstrInterface[2 + 2*(sizeof(CONFIG_USBD_INTERFACE_STR)-1)];
static struct usb_string_descriptor *usbtty_string_table[] = {
(struct usb_string_descriptor*)wstrLang,
(struct usb_string_descriptor*)wstrManufacturer,
(struct usb_string_descriptor*)wstrProduct,
(struct usb_string_descriptor*)wstrSerial,
(struct usb_string_descriptor*)wstrConfiguration,
(struct usb_string_descriptor*)wstrInterface
};
extern struct usb_string_descriptor **usb_strings; /* defined and used by omap1510_ep0.c */
static struct usb_device_descriptor device_descriptor = {
bLength: sizeof(struct usb_device_descriptor),
bDescriptorType: USB_DT_DEVICE,
bcdUSB: USB_BCD_VERSION,
bDeviceClass: USBTTY_DEVICE_CLASS,
bDeviceSubClass: USBTTY_DEVICE_SUBCLASS,
bDeviceProtocol: USBTTY_DEVICE_PROTOCOL,
bMaxPacketSize0: EP0_MAX_PACKET_SIZE,
idVendor: CONFIG_USBD_VENDORID,
idProduct: CONFIG_USBD_PRODUCTID,
bcdDevice: USBTTY_BCD_DEVICE,
iManufacturer: STR_MANUFACTURER,
iProduct: STR_PRODUCT,
iSerialNumber: STR_SERIAL,
bNumConfigurations: NUM_CONFIGS
};
static struct usb_configuration_descriptor config_descriptors[NUM_CONFIGS] = {
{
bLength: sizeof(struct usb_configuration_descriptor),
bDescriptorType: USB_DT_CONFIG,
wTotalLength: (sizeof(struct usb_configuration_descriptor)*NUM_CONFIGS) +
(sizeof(struct usb_interface_descriptor)*NUM_INTERFACES) +
(sizeof(struct usb_endpoint_descriptor)*NUM_ENDPOINTS),
bNumInterfaces: NUM_INTERFACES,
bConfigurationValue: 1,
iConfiguration: STR_CONFIG,
bmAttributes: BMATTRIBUTE_SELF_POWERED | BMATTRIBUTE_RESERVED,
bMaxPower: USBTTY_MAXPOWER
},
};
static struct usb_interface_descriptor interface_descriptors[NUM_INTERFACES] = {
{
bLength: sizeof(struct usb_interface_descriptor),
bDescriptorType: USB_DT_INTERFACE,
bInterfaceNumber: 0,
bAlternateSetting: 0,
bNumEndpoints: NUM_ENDPOINTS,
bInterfaceClass: USBTTY_INTERFACE_CLASS,
bInterfaceSubClass: USBTTY_INTERFACE_SUBCLASS,
bInterfaceProtocol: USBTTY_INTERFACE_PROTOCOL,
iInterface: STR_INTERFACE
},
};
static struct usb_endpoint_descriptor ep_descriptors[NUM_ENDPOINTS] = {
{
bLength: sizeof(struct usb_endpoint_descriptor),
bDescriptorType: USB_DT_ENDPOINT,
bEndpointAddress: CONFIG_USBD_SERIAL_OUT_ENDPOINT | USB_DIR_OUT,
bmAttributes: USB_ENDPOINT_XFER_BULK,
wMaxPacketSize: CONFIG_USBD_SERIAL_OUT_PKTSIZE,
bInterval: 0
},
{
bLength: sizeof(struct usb_endpoint_descriptor),
bDescriptorType: USB_DT_ENDPOINT,
bEndpointAddress: CONFIG_USBD_SERIAL_IN_ENDPOINT | USB_DIR_IN,
bmAttributes: USB_ENDPOINT_XFER_BULK,
wMaxPacketSize: CONFIG_USBD_SERIAL_IN_PKTSIZE,
bInterval: 0
},
{
bLength: sizeof(struct usb_endpoint_descriptor),
bDescriptorType: USB_DT_ENDPOINT,
bEndpointAddress: CONFIG_USBD_SERIAL_INT_ENDPOINT | USB_DIR_IN,
bmAttributes: USB_ENDPOINT_XFER_INT,
wMaxPacketSize: CONFIG_USBD_SERIAL_INT_PKTSIZE,
bInterval: 0
},
};
static struct usb_endpoint_descriptor *ep_descriptor_ptrs[NUM_ENDPOINTS] = {
&(ep_descriptors[0]),
&(ep_descriptors[1]),
&(ep_descriptors[2]),
};
/* utility function for converting char* to wide string used by USB */
static void str2wide (char *str, u16 * wide)
{
int i;
for (i = 0; i < strlen (str) && str[i]; i++)
wide[i] = (u16) str[i];
}
/*
* Prototypes
*/
static void usbtty_init_strings (void);
static void usbtty_init_instances (void);
static void usbtty_init_endpoints (void);
static void usbtty_event_handler (struct usb_device_instance *device,
usb_device_event_t event, int data);
static int usbtty_configured (void);
static int write_buffer (circbuf_t * buf);
static int fill_buffer (circbuf_t * buf);
void usbtty_poll (void);
static void pretend_interrupts (void);
/*
* Test whether a character is in the RX buffer
*/
int usbtty_tstc (void)
{
usbtty_poll ();
return (usbtty_input.size > 0);
}
/*
* Read a single byte from the usb client port. Returns 1 on success, 0
* otherwise. When the function is succesfull, the character read is
* written into its argument c.
*/
int usbtty_getc (void)
{
char c;
while (usbtty_input.size <= 0) {
usbtty_poll ();
}
buf_pop (&usbtty_input, &c, 1);
return c;
}
/*
* Output a single byte to the usb client port.
*/
void usbtty_putc (const char c)
{
buf_push (&usbtty_output, &c, 1);
/* If \n, also do \r */
if (c == '\n')
buf_push (&usbtty_output, "\r", 1);
/* Poll at end to handle new data... */
if ((usbtty_output.size + 2) >= usbtty_output.totalsize) {
usbtty_poll ();
}
}
/* usbtty_puts() helper function for finding the next '\n' in a string */
static int next_nl_pos (const char *s)
{
int i;
for (i = 0; s[i] != '\0'; i++) {
if (s[i] == '\n')
return i;
}
return i;
}
/*
* Output a string to the usb client port.
*/
static void __usbtty_puts (const char *str, int len)
{
int maxlen = usbtty_output.totalsize;
int space, n;
/* break str into chunks < buffer size, if needed */
while (len > 0) {
space = maxlen - usbtty_output.size;
/* Empty buffer here, if needed, to ensure space... */
if (space <= 0) {
write_buffer (&usbtty_output);
space = maxlen - usbtty_output.size;
if (space <= 0) {
space = len; /* allow old data to be overwritten. */
}
}
n = MIN (space, MIN (len, maxlen));
buf_push (&usbtty_output, str, n);
str += n;
len -= n;
}
}
void usbtty_puts (const char *str)
{
int n;
int len = strlen (str);
/* add '\r' for each '\n' */
while (len > 0) {
n = next_nl_pos (str);
if (str[n] == '\n') {
__usbtty_puts (str, n + 1);
__usbtty_puts ("\r", 1);
str += (n + 1);
len -= (n + 1);
} else {
/* No \n found. All done. */
__usbtty_puts (str, n);
break;
}
}
/* Poll at end to handle new data... */
usbtty_poll ();
}
/*
* Initialize the usb client port.
*
*/
int drv_usbtty_init (void)
{
int rc;
/* prepare buffers... */
buf_init (&usbtty_input, USBTTY_BUFFER_SIZE);
buf_init (&usbtty_output, USBTTY_BUFFER_SIZE);
/* Now, set up USB controller and infrastructure */
udc_init (); /* Basic USB initialization */
usbtty_init_strings ();
usbtty_init_instances ();
udc_startup_events (device_instance); /* Enable our device, initialize udc pointers */
udc_connect (); /* Enable pullup for host detection */
usbtty_init_endpoints ();
/* Device initialization */
memset (&usbttydev, 0, sizeof (usbttydev));
strcpy (usbttydev.name, "usbtty");
usbttydev.ext = 0; /* No extensions */
usbttydev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_OUTPUT;
usbttydev.tstc = usbtty_tstc; /* 'tstc' function */
usbttydev.getc = usbtty_getc; /* 'getc' function */
usbttydev.putc = usbtty_putc; /* 'putc' function */
usbttydev.puts = usbtty_puts; /* 'puts' function */
rc = device_register (&usbttydev);
return (rc == 0) ? 1 : rc;
}
static void usbtty_init_strings (void)
{
struct usb_string_descriptor *string;
string = (struct usb_string_descriptor *) wstrManufacturer;
string->bLength = sizeof (wstrManufacturer);
string->bDescriptorType = USB_DT_STRING;
str2wide (CONFIG_USBD_MANUFACTURER, string->wData);
string = (struct usb_string_descriptor *) wstrProduct;
string->bLength = sizeof (wstrProduct);
string->bDescriptorType = USB_DT_STRING;
str2wide (CONFIG_USBD_PRODUCT_NAME, string->wData);
string = (struct usb_string_descriptor *) wstrSerial;
string->bLength = sizeof (wstrSerial);
string->bDescriptorType = USB_DT_STRING;
str2wide (CONFIG_USBD_SERIAL_NUMBER, string->wData);
string = (struct usb_string_descriptor *) wstrConfiguration;
string->bLength = sizeof (wstrConfiguration);
string->bDescriptorType = USB_DT_STRING;
str2wide (CONFIG_USBD_CONFIGURATION_STR, string->wData);
string = (struct usb_string_descriptor *) wstrInterface;
string->bLength = sizeof (wstrInterface);
string->bDescriptorType = USB_DT_STRING;
str2wide (CONFIG_USBD_INTERFACE_STR, string->wData);
/* Now, initialize the string table for ep0 handling */
usb_strings = usbtty_string_table;
}
static void usbtty_init_instances (void)
{
int i;
/* initialize device instance */
memset (device_instance, 0, sizeof (struct usb_device_instance));
device_instance->device_state = STATE_INIT;
device_instance->device_descriptor = &device_descriptor;
device_instance->event = usbtty_event_handler;
device_instance->bus = bus_instance;
device_instance->configurations = NUM_CONFIGS;
device_instance->configuration_instance_array = config_instance;
/* initialize bus instance */
memset (bus_instance, 0, sizeof (struct usb_bus_instance));
bus_instance->device = device_instance;
bus_instance->endpoint_array = endpoint_instance;
bus_instance->max_endpoints = 1;
bus_instance->maxpacketsize = 64;
bus_instance->serial_number_str = CONFIG_USBD_SERIAL_NUMBER;
/* configuration instance */
memset (config_instance, 0,
sizeof (struct usb_configuration_instance));
config_instance->interfaces = NUM_INTERFACES;
config_instance->configuration_descriptor = config_descriptors;
config_instance->interface_instance_array = interface_instance;
/* interface instance */
memset (interface_instance, 0,
sizeof (struct usb_interface_instance));
interface_instance->alternates = 1;
interface_instance->alternates_instance_array = alternate_instance;
/* alternates instance */
memset (alternate_instance, 0,
sizeof (struct usb_alternate_instance));
alternate_instance->interface_descriptor = interface_descriptors;
alternate_instance->endpoints = NUM_ENDPOINTS;
alternate_instance->endpoints_descriptor_array = ep_descriptor_ptrs;
/* endpoint instances */
memset (&endpoint_instance[0], 0,
sizeof (struct usb_endpoint_instance));
endpoint_instance[0].endpoint_address = 0;
endpoint_instance[0].rcv_packetSize = EP0_MAX_PACKET_SIZE;
endpoint_instance[0].rcv_attributes = USB_ENDPOINT_XFER_CONTROL;
endpoint_instance[0].tx_packetSize = EP0_MAX_PACKET_SIZE;
endpoint_instance[0].tx_attributes = USB_ENDPOINT_XFER_CONTROL;
udc_setup_ep (device_instance, 0, &endpoint_instance[0]);
for (i = 1; i <= NUM_ENDPOINTS; i++) {
memset (&endpoint_instance[i], 0,
sizeof (struct usb_endpoint_instance));
endpoint_instance[i].endpoint_address =
ep_descriptors[i - 1].bEndpointAddress;
endpoint_instance[i].rcv_packetSize =
ep_descriptors[i - 1].wMaxPacketSize;
endpoint_instance[i].rcv_attributes =
ep_descriptors[i - 1].bmAttributes;
endpoint_instance[i].tx_packetSize =
ep_descriptors[i - 1].wMaxPacketSize;
endpoint_instance[i].tx_attributes =
ep_descriptors[i - 1].bmAttributes;
urb_link_init (&endpoint_instance[i].rcv);
urb_link_init (&endpoint_instance[i].rdy);
urb_link_init (&endpoint_instance[i].tx);
urb_link_init (&endpoint_instance[i].done);
if (endpoint_instance[i].endpoint_address & USB_DIR_IN)
endpoint_instance[i].tx_urb =
usbd_alloc_urb (device_instance,
&endpoint_instance[i]);
else
endpoint_instance[i].rcv_urb =
usbd_alloc_urb (device_instance,
&endpoint_instance[i]);
}
}
static void usbtty_init_endpoints (void)
{
int i;
bus_instance->max_endpoints = NUM_ENDPOINTS + 1;
for (i = 0; i <= NUM_ENDPOINTS; i++) {
udc_setup_ep (device_instance, i, &endpoint_instance[i]);
}
}
/*********************************************************************************/
static struct urb *next_urb (struct usb_device_instance *device,
struct usb_endpoint_instance *endpoint)
{
struct urb *current_urb = NULL;
int space;
/* If there's a queue, then we should add to the last urb */
if (!endpoint->tx_queue) {
current_urb = endpoint->tx_urb;
} else {
/* Last urb from tx chain */
current_urb =
p2surround (struct urb, link, endpoint->tx.prev);
}
/* Make sure this one has enough room */
space = current_urb->buffer_length - current_urb->actual_length;
if (space > 0) {
return current_urb;
} else { /* No space here */
/* First look at done list */
current_urb = first_urb_detached (&endpoint->done);
if (!current_urb) {
current_urb = usbd_alloc_urb (device, endpoint);
}
urb_append (&endpoint->tx, current_urb);
endpoint->tx_queue++;
}
return current_urb;
}
static int write_buffer (circbuf_t * buf)
{
if (!usbtty_configured ()) {
return 0;
}
if (buf->size) {
struct usb_endpoint_instance *endpoint =
&endpoint_instance[TX_ENDPOINT];
struct urb *current_urb = NULL;
char *dest;
int space_avail;
int popnum, popped;
int total = 0;
/* Break buffer into urb sized pieces, and link each to the endpoint */
while (buf->size > 0) {
current_urb = next_urb (device_instance, endpoint);
if (!current_urb) {
TTYERR ("current_urb is NULL, buf->size %d\n",
buf->size);
return total;
}
dest = current_urb->buffer +
current_urb->actual_length;
space_avail =
current_urb->buffer_length -
current_urb->actual_length;
popnum = MIN (space_avail, buf->size);
if (popnum == 0)
break;
popped = buf_pop (buf, dest, popnum);
if (popped == 0)
break;
current_urb->actual_length += popped;
total += popped;
/* If endpoint->last == 0, then transfers have not started on this endpoint */
if (endpoint->last == 0) {
udc_endpoint_write (endpoint);
}
} /* end while */
return total;
} /* end if tx_urb */
return 0;
}
static int fill_buffer (circbuf_t * buf)
{
struct usb_endpoint_instance *endpoint =
&endpoint_instance[RECV_ENDPOINT];
if (endpoint->rcv_urb && endpoint->rcv_urb->actual_length) {
unsigned int nb = endpoint->rcv_urb->actual_length;
char *src = (char *) endpoint->rcv_urb->buffer;
buf_push (buf, src, nb);
endpoint->rcv_urb->actual_length = 0;
return nb;
}
return 0;
}
static int usbtty_configured (void)
{
return usbtty_configured_flag;
}
/*********************************************************************************/
static void usbtty_event_handler (struct usb_device_instance *device,
usb_device_event_t event, int data)
{
switch (event) {
case DEVICE_RESET:
case DEVICE_BUS_INACTIVE:
usbtty_configured_flag = 0;
break;
case DEVICE_CONFIGURED:
usbtty_configured_flag = 1;
break;
case DEVICE_ADDRESS_ASSIGNED:
usbtty_init_endpoints ();
default:
break;
}
}
/*********************************************************************************/
/*
* Since interrupt handling has not yet been implemented, we use this function
* to handle polling. This is called by the tstc,getc,putc,puts routines to
* update the USB state.
*/
void usbtty_poll (void)
{
/* New interrupts? */
pretend_interrupts ();
/* Write any output data to host buffer (do this before checking interrupts to avoid missing one) */
if (usbtty_configured ()) {
write_buffer (&usbtty_output);
}
/* New interrupts? */
pretend_interrupts ();
/* Check for new data from host.. (do this after checking interrupts to get latest data) */
if (usbtty_configured ()) {
fill_buffer (&usbtty_input);
}
/* New interrupts? */
pretend_interrupts ();
}
static void pretend_interrupts (void)
{
/* Loop while we have interrupts.
* If we don't do this, the input chain
* polling delay is likely to miss
* host requests.
*/
while (inw (UDC_IRQ_SRC) & ~UDC_SOF_Flg) {
/* Handle any new IRQs */
omap1510_udc_irq ();
omap1510_udc_noniso_irq ();
}
}
#endif
+64
View File
@@ -0,0 +1,64 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* 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 __USB_TTY_H__
#define __USB_TTY_H__
#include "usbdcore.h"
#include "usbdcore_omap1510.h"
#define NUM_CONFIGS 1
#define NUM_INTERFACES 1
#define NUM_ENDPOINTS 3
#define EP0_MAX_PACKET_SIZE 64
#define CONFIG_USBD_CONFIGURATION_STR "TTY via USB"
#define CONFIG_USBD_INTERFACE_STR "Simple Serial Data Interface - Bulk Mode"
#define CONFIG_USBD_SERIAL_OUT_ENDPOINT 2
#define CONFIG_USBD_SERIAL_OUT_PKTSIZE 64
#define CONFIG_USBD_SERIAL_IN_ENDPOINT 1
#define CONFIG_USBD_SERIAL_IN_PKTSIZE 64
#define CONFIG_USBD_SERIAL_INT_ENDPOINT 5
#define CONFIG_USBD_SERIAL_INT_PKTSIZE 16
#define USBTTY_DEVICE_CLASS COMMUNICATIONS_DEVICE_CLASS
#define USBTTY_DEVICE_SUBCLASS COMMUNICATIONS_NO_SUBCLASS
#define USBTTY_DEVICE_PROTOCOL COMMUNICATIONS_NO_PROTOCOL
#define USBTTY_INTERFACE_CLASS 0xFF /* Vendor Specific */
#define USBTTY_INTERFACE_SUBCLASS 0x02
#define USBTTY_INTERFACE_PROTOCOL 0x01
#define USBTTY_BCD_DEVICE 0x0
#define USBTTY_MAXPOWER 0x0
#define STR_MANUFACTURER 1
#define STR_PRODUCT 2
#define STR_SERIAL 3
#define STR_CONFIG 4
#define STR_INTERFACE 5
#endif
+2 -1
View File
@@ -89,7 +89,8 @@ fat_register_device(block_dev_desc_t *dev_desc, int part_no)
part_offset=0;
}
else {
#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)
disk_partition_t info;
if(!get_partition_info(dev_desc, part_no, &info)) {
part_offset = info.start;
+40
View File
@@ -0,0 +1,40 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* 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 __CIRCBUF_H__
#define __CIRCBUF_H__
typedef struct circbuf {
unsigned int size; /* current number of bytes held */
unsigned int totalsize; /* number of bytes allocated */
char *top; /* pointer to current buffer start */
char *tail; /* pointer to space for next element */
char *data; /* all data */
char *end; /* end of data buffer */
} circbuf_t;
int buf_init (circbuf_t * buf, unsigned int size);
int buf_free (circbuf_t * buf);
int buf_pop (circbuf_t * buf, char *dest, unsigned int len);
int buf_push (circbuf_t * buf, const char *src, unsigned int len);
#endif
+1
View File
@@ -466,6 +466,7 @@
CFG_CMD_JFFS2 | \
CFG_CMD_KGDB | \
CFG_CMD_NAND | \
CFG_CMD_NFS | \
CFG_CMD_MMC | \
CFG_CMD_MII | \
CFG_CMD_PCI | \
+1
View File
@@ -476,6 +476,7 @@
CFG_CMD_JFFS2 | \
CFG_CMD_KGDB | \
CFG_CMD_NAND | \
CFG_CMD_NFS | \
CFG_CMD_MMC | \
CFG_CMD_MII | \
CFG_CMD_PCI | \
+54 -3
View File
@@ -1,5 +1,5 @@
/*
* (C) Copyright 2003
* (C) Copyright 2003-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
@@ -81,11 +81,30 @@
#endif
/* Partitions */
#define CONFIG_MAC_PARTITION
#define CONFIG_DOS_PARTITION
/* USB */
#if 1
#define CONFIG_USB_OHCI
#define ADD_USB_CMD CFG_CMD_USB | CFG_CMD_FAT
#define CONFIG_DOS_PARTITION
#define CONFIG_USB_STORAGE
#else
#define ADD_USB_CMD 0
#endif
/*
* Supported commands
*/
#define CONFIG_COMMANDS (CONFIG_CMD_DFL | ADD_PCI_CMD | \
CFG_CMD_I2C | CFG_CMD_EEPROM)
#define CONFIG_COMMANDS (CONFIG_CMD_DFL | \
CFG_CMD_EEPROM | \
CFG_CMD_FAT | \
CFG_CMD_I2C | \
CFG_CMD_IDE | \
ADD_PCI_CMD | \
ADD_USB_CMD)
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>
@@ -282,4 +301,36 @@
#define CFG_RESET_ADDRESS 0xff000000
/*-----------------------------------------------------------------------
* IDE/ATA stuff Supports IDE harddisk
*-----------------------------------------------------------------------
*/
#undef CONFIG_IDE_8xx_PCCARD /* Use IDE with PC Card Adapter */
#undef CONFIG_IDE_8xx_DIRECT /* Direct IDE not supported */
#undef CONFIG_IDE_LED /* LED for ide not supported */
#define CONFIG_IDE_RESET /* reset for ide supported */
#define CONFIG_IDE_PREINIT
#define CFG_IDE_MAXBUS 1 /* max. 1 IDE bus */
#define CFG_IDE_MAXDEVICE 1 /* max. 1 drive per IDE bus */
#define CFG_ATA_IDE0_OFFSET 0x0000
#define CFG_ATA_BASE_ADDR MPC5XXX_ATA
/* Offset for data I/O */
#define CFG_ATA_DATA_OFFSET (0x0060)
/* Offset for normal register accesses */
#define CFG_ATA_REG_OFFSET (CFG_ATA_DATA_OFFSET)
/* Offset for alternate registers */
#define CFG_ATA_ALT_OFFSET (0x005c)
/* Interval between registers */
#define CFG_ATA_STRIDE 4
#endif /* __CONFIG_H */
+177
View File
@@ -0,0 +1,177 @@
/*
* (C) Copyright 2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef __CONFIG_H
#define __CONFIG_H
/*
* If we are developing, we might want to start armboot from ram
* so we MUST NOT initialize critical regs like mem-timing ...
*/
#define CONFIG_INIT_CRITICAL /* undef for developing */
/*
* High Level Configuration Options
* (easy to change)
*/
#define CONFIG_ARM925T 1 /* This is an arm925t CPU */
#define CONFIG_OMAP 1 /* in a TI OMAP core */
#define CONFIG_OMAP1510 1 /* which is in a 1510 (helen) */
#define CONFIG_OMAP_SX1 1 /* a SX1 Board */
/* input clock of PLL */
#define CONFIG_SYS_CLK_FREQ 12000000 /* the SX1 has 12MHz input clock */
#undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ stuff */
#define CONFIG_MISC_INIT_R
#define CONFIG_CMDLINE_TAG 1 /* enable passing of ATAGs */
#define CONFIG_SETUP_MEMORY_TAGS 1
#define CONFIG_INITRD_TAG 1
/*
* Size of malloc() pool
*/
#define CFG_MALLOC_LEN (CFG_ENV_SIZE + 128*1024)
#define CFG_GBL_DATA_SIZE 128 /* size in bytes reserved for initial data */
/*
* Hardware drivers
*/
/*
* NS16550 Configuration
*/
#define CFG_NS16550
#define CFG_NS16550_SERIAL
#define CFG_NS16550_REG_SIZE (-4)
#define CFG_NS16550_CLK (CONFIG_SYS_CLK_FREQ) /* can be 12M/32Khz or 48Mhz */
#define CFG_NS16550_COM1 0xfffb0000 /* uart1, bluetooth uart on helen */
/*
* select serial console configuration
*/
#define CONFIG_SERIAL1 1 /* we use SERIAL 1 on SX1 */
/*
* USB device configuration
*/
#define CONFIG_USB_DEVICE 1
#define CONFIG_USB_TTY 1
#define CONFIG_USBD_VENDORID 0x1234
#define CONFIG_USBD_PRODUCTID 0x5678
#define CONFIG_USBD_MANUFACTURER "Siemens"
#define CONFIG_USBD_PRODUCT_NAME "SX1"
#define CONFIG_USBD_SERIAL_NUMBER "000000000001"
/*
* I2C configuration
*/
#define CONFIG_HARD_I2C
#define CFG_I2C_SPEED 100000
#define CFG_I2C_SLAVE 1
#define CONFIG_DRIVER_OMAP1510_I2C
#define CONFIG_ENV_OVERWRITE
#define CONFIG_ENV_OVERWRITE
#define CONFIG_CONS_INDEX 1
#define CONFIG_BAUDRATE 115200
#define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
#define CONFIG_COMMANDS (( CONFIG_CMD_DFL | \
CFG_CMD_I2C ) & \
~CFG_CMD_NET)
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>
#include <configs/omap1510.h>
#define CONFIG_BOOTDELAY 3
#define CONFIG_BOOTARGS "mem=16M console=ttyS0,115200n8 root=/dev/mtdblock3 rw"
/*
* Miscellaneous configurable options
*/
#define CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "SX1# " /* Monitor Command Prompt */
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
#define CFG_MAXARGS 16 /* max number of command args */
#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */
#define CFG_MEMTEST_START 0x10000000 /* memtest works on */
#define CFG_MEMTEST_END 0x12000000 /* 32 MB in DRAM */
#undef CFG_CLKS_IN_HZ /* everything, incl board info, in Hz */
#define CFG_LOAD_ADDR 0x10000000 /* default load address */
/* The 1510 has 3 timers, they can be driven by the RefClk (12Mhz) or by DPLL1.
* This time is further subdivided by a local divisor.
*/
#define CFG_TIMERBASE 0xFFFEC500 /* use timer 1 */
#define CFG_PVT 7 /* 2^(pvt+1), divide by 256 */
#define CFG_HZ ((CONFIG_SYS_CLK_FREQ)/(2 << CFG_PVT))
/*-----------------------------------------------------------------------
* Stack sizes
*
* The stack sizes are set up in start.S using the settings below
*/
#define CONFIG_STACKSIZE (128*1024) /* regular stack */
#ifdef CONFIG_USE_IRQ
#define CONFIG_STACKSIZE_IRQ (4*1024) /* IRQ stack */
#define CONFIG_STACKSIZE_FIQ (4*1024) /* FIQ stack */
#endif
/*-----------------------------------------------------------------------
* Physical Memory Map
*/
#define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */
#define PHYS_SDRAM_1 0x10000000 /* SDRAM Bank #1 */
#define PHYS_SDRAM_1_SIZE 0x02000000 /* 32 MB */
#define PHYS_FLASH_1 0x00000000 /* Flash Bank #1 */
#define PHYS_FLASH_2 0x04000000 /* Flash Bank #2 */
#define CFG_FLASH_BASE PHYS_FLASH_1
/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */
#define CFG_MAX_FLASH_SECT (128) /* max number of sectors on one chip */
#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x020000) /* addr of environment */
/* timeout values are in ticks */
#define CFG_FLASH_ERASE_TOUT (20*CFG_HZ) /* Timeout for Flash Erase */
#define CFG_FLASH_WRITE_TOUT (20*CFG_HZ) /* Timeout for Flash Write */
#define CFG_ENV_IS_IN_FLASH 1
#define CFG_ENV_SIZE 0x20000 /* Total Size of Environment Sector */
#define CFG_ENV_OFFSET 0x20000 /* environment starts here */
#endif /* __CONFIG_H */
+3 -1
View File
@@ -85,6 +85,8 @@ extern void out32(unsigned int, unsigned long);
/*-----------------------------------------------------------------------
* Initial RAM & stack pointer (placed in internal SRAM)
*----------------------------------------------------------------------*/
#define CFG_TEMP_STACK_OCM 1
#define CFG_OCM_DATA_ADDR CFG_ISRAM_BASE
#define CFG_INIT_RAM_ADDR CFG_ISRAM_BASE /* Initial RAM address */
#define CFG_INIT_RAM_END 0x2000 /* End of used area in RAM */
#define CFG_GBL_DATA_SIZE 128 /* num bytes initial data */
@@ -160,7 +162,7 @@ extern void out32(unsigned int, unsigned long);
#define CONFIG_BOOTARGS "root=/dev/hda1 "
#define CONFIG_BOOTCOMMAND "bootm ffc00000" /* autoboot command */
#define CONFIG_BOOTDELAY -1 /* disable autoboot */
#define CONFIG_BOOTDELAY 5 /* disable autoboot */
#define CONFIG_BAUDRATE 9600
#define CONFIG_LOADS_ECHO 1 /* echo on for serial download */
+454
View File
@@ -0,0 +1,454 @@
/*
* (C) Copyright 2001
* 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
*/
/* ------------------------------------------------------------------------- */
/*
* board/config.h - configuration options, board specific
*/
#ifndef __CONFIG_H
#define __CONFIG_H
/*
* High Level Configuration Options
* (easy to change)
*/
#define CONFIG_MPC824X 1
/* #define CONFIG_MPC8240 1 */
#define CONFIG_MPC8245 1
#define CONFIG_EXALION 1
#if defined (CONFIG_MPC8240)
/* #warning ---------- eXalion with MPC8240 --------------- */
#elif defined (CONFIG_MPC8245)
/* #warning ++++++++++ eXalion with MPC8245 +++++++++++++++ */
#elif defined (CONFIG_MPC8245) && defined (CONFIG_MPC8245)
#error #### Both types of MPC824x defined (CONFIG_8240 and CONFIG_8245)
#else
#error #### Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240)
#endif
/* older kernels need clock in MHz newer in Hz */
/* #define CONFIG_CLOCKS_IN_MHZ 1 */ /* clocks passsed to Linux in MHz */
#undef CONFIG_CLOCKS_IN_MHZ
#define CONFIG_BOOTDELAY 10
/*#define CONFIG_DRAM_SPEED 66 */ /* MHz */
#define CONFIG_COMMANDS ( CONFIG_CMD_DFL | \
CFG_CMD_FLASH | \
CFG_CMD_SDRAM | \
CFG_CMD_I2C | \
CFG_CMD_IDE | \
CFG_CMD_FAT | \
CFG_CMD_ENV | \
CFG_CMD_PCI )
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>
/*-----------------------------------------------------------------------
* Miscellaneous configurable options
*/
#define CFG_LONGHELP 1 /* undef to save memory */
#define CFG_PROMPT "=> " /* Monitor Command Prompt */
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
#define CFG_MAXARGS 8 /* max number of command args */
#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */
#define CFG_LOAD_ADDR 0x00100000 /* default load address */
#define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
#define CONFIG_MISC_INIT_R 1
/*-----------------------------------------------------------------------
* Start addresses for the final memory configuration
* (Set up by the startup code)
* Please note that CFG_SDRAM_BASE _must_ start at 0
*/
#define CFG_SDRAM_BASE 0x00000000
#define CFG_MAX_RAM_SIZE 0x10000000 /* 1 GBytes - initdram() will */
/* return real value. */
#define CFG_RESET_ADDRESS 0xFFF00100
#undef CFG_RAMBOOT
#define CFG_MONITOR_LEN (256 << 10) /* Reserve 256 kB for Monitor */
#define CFG_MONITOR_BASE TEXT_BASE
/*-----------------------------------------------------------------------
* Definitions for initial stack pointer and data area
*/
#define CFG_INIT_DATA_SIZE 128
#define CFG_INIT_RAM_ADDR 0x40000000
#define CFG_INIT_RAM_END 0x1000
#define CFG_INIT_DATA_OFFSET (CFG_INIT_RAM_END - CFG_INIT_DATA_SIZE)
#define CFG_GBL_DATA_SIZE 256 /* size in bytes reserved for initial data */
#define CFG_GBL_DATA_OFFSET (CFG_INIT_RAM_END - CFG_GBL_DATA_SIZE)
#define CFG_INIT_SP_OFFSET CFG_GBL_DATA_OFFSET
#if defined (CONFIG_MPC8240)
#define CFG_FLASH_BASE 0xFFE00000
#define CFG_FLASH_SIZE (2 * 1024 * 1024) /* onboard 2MByte flash */
#elif defined (CONFIG_MPC8245)
#define CFG_FLASH_BASE 0xFFC00000
#define CFG_FLASH_SIZE (4 * 1024 * 1024) /* onboard 4MByte flash */
#else
#error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240)
#endif
#define CFG_ENV_IS_IN_FLASH 1
#define CFG_ENV_SECT_SIZE 0x20000 /* Size of one Flash sector */
#define CFG_ENV_SIZE CFG_ENV_SECT_SIZE /* Use one Flash sector for enviroment */
#define CFG_ENV_ADDR 0xFFFC0000
#define CFG_ENV_OFFSET 0 /* starting right at the beginning */
#define CFG_MALLOC_LEN (128 * 1024) /* Reserve 128 kB for malloc() */
#define CFG_ALT_MEMTEST 1 /* use real memory test */
#define CFG_MEMTEST_START 0x00004000 /* memtest works on */
#define CFG_MEMTEST_END 0x02000000 /* 0 ... 32 MB in DRAM */
#define CFG_EUMB_ADDR 0xFC000000
/* #define CFG_ISA_MEM 0xFD000000 */
#define CFG_ISA_IO 0xFE000000
/*-----------------------------------------------------------------------
* FLASH organization
*/
#define CFG_MAX_FLASH_BANKS 1 /* Max number of flash banks */
#define CFG_MAX_FLASH_SECT 64 /* Max number of sectors per flash */
#define CFG_FLASH_ERASE_TOUT 120000 /* Timeout for Flash Erase (in ms) */
#define CFG_FLASH_WRITE_TOUT 500 /* Timeout for Flash Write (in ms) */
#define FLASH_BASE0_PRELIM CFG_FLASH_BASE
#define FLASH_BASE1_PRELIM 0
/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
#define CFG_FLASH_CFI 1 /* Flash is CFI conformant */
#define CFG_FLASH_CFI_DRIVER 1 /* Use the common driver */
#define CFG_MAX_FLASH_SECT 64 /* max number of sectors on one chip */
#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
#define CFG_FLASH_INCREMENT 0 /* there is only one bank */
#define CFG_FLASH_PROTECTION 1 /* use hardware protection */
#define CFG_FLASH_USE_BUFFER_WRITE 1 /* use buffered writes (20x faster) */
/*-----------------------------------------------------------------------
* PCI stuff
*/
#define CONFIG_PCI 1 /* include pci support */
#undef CONFIG_PCI_PNP
#define CONFIG_NET_MULTI 1 /* Multi ethernet cards support */
#define CONFIG_EEPRO100 1
#define PCI_ENET0_MEMADDR 0x80000000 /* Intel 82559ER */
#define PCI_ENET0_IOADDR 0x80000000
#define PCI_ENET1_MEMADDR 0x81000000 /* Intel 82559ER */
#define PCI_ENET1_IOADDR 0x81000000
#define PCI_ENET2_MEMADDR 0x82000000 /* Broadcom BCM569xx */
#define PCI_ENET2_IOADDR 0x82000000
#define PCI_ENET3_MEMADDR 0x83000000 /* Broadcom BCM56xx */
#define PCI_ENET3_IOADDR 0x83000000
/*-----------------------------------------------------------------------
* NS16550 Configuration
*/
#define CFG_NS16550 1
#define CFG_NS16550_SERIAL 1
#define CONFIG_CONS_INDEX 1
#define CONFIG_BAUDRATE 38400
#define CFG_NS16550_REG_SIZE 1
#if (CONFIG_CONS_INDEX == 1)
#define CFG_NS16550_CLK 1843200 /* COM1 only ! */
#else
#define CFG_NS16550_CLK ({ extern ulong get_bus_freq (ulong); get_bus_freq (0); })
#endif
#define CFG_NS16550_COM1 (CFG_ISA_IO + 0x3F8)
#define CFG_NS16550_COM2 (CFG_EUMB_ADDR + 0x4500)
#define CFG_NS16550_COM3 (CFG_EUMB_ADDR + 0x4600)
/*-----------------------------------------------------------------------
* select i2c support configuration
*
* Supported configurations are {none, software, hardware} drivers.
* If the software driver is chosen, there are some additional
* configuration items that the driver uses to drive the port pins.
*/
#define CONFIG_HARD_I2C 1 /* To enable I2C support */
#undef CONFIG_SOFT_I2C /* I2C bit-banged */
#define CFG_I2C_SPEED 400000 /* I2C speed and slave address */
#define CFG_I2C_SLAVE 0x7F
/*-----------------------------------------------------------------------
* Low Level Configuration Settings
* (address mappings, register initial values, etc.)
* You should know what you are doing if you make changes here.
*/
#define CFG_HZ 1000
#define CONFIG_SYS_CLK_FREQ 33333333 /* external frequency to pll */
#define CONFIG_PLL_PCI_TO_MEM_MULTIPLIER 2 /* for MPC8240 only */
/*#define CONFIG_133MHZ_DRAM 1 */ /* For 133 MHZ DRAM only !!!!!!!!!!! */
#if defined (CONFIG_MPC8245)
/* Bit-field values for PMCR2. */
#if defined (CONFIG_133MHZ_DRAM)
#define CFG_DLL_EXTEND 0x80 /* use DLL extended range - 133MHz only */
#define CFG_PCI_HOLD_DEL 0x20 /* delay and hold timing - 133MHz only */
#endif
/* Bit-field values for MIOCR1. */
#if !defined (CONFIG_133MHZ_DRAM)
#define CFG_DLL_MAX_DELAY 0x04 /* longer DLL delay line - 66MHz only */
#endif
/* Bit-field values for MIOCR2. */
#define CFG_SDRAM_DSCD 0x20 /* SDRAM data in sample clock delay */
/* - note bottom 3 bits MUST be 0 */
#endif
/* Bit-field values for MCCR1. */
#define CFG_ROMNAL 7 /*rom/flash next access time */
#define CFG_ROMFAL 11 /*rom/flash access time */
/* Bit-field values for MCCR2. */
#define CFG_TSWAIT 0x5 /* Transaction Start Wait States timer */
#if defined (CONFIG_133MHZ_DRAM)
#define CFG_REFINT 1300 /* no of clock cycles between CBR */
#else /* refresh cycles */
#define CFG_REFINT 750
#endif
/* Burst To Precharge. Bits of this value go to MCCR3 and MCCR4. */
#if defined (CONFIG_133MHZ_DRAM)
#define CFG_BSTOPRE 1023
#else
#define CFG_BSTOPRE 250
#endif
/* Bit-field values for MCCR3. */
/* the following are for SDRAM only */
#if defined (CONFIG_133MHZ_DRAM)
#define CFG_REFREC 9 /* Refresh to activate interval */
#else
#define CFG_REFREC 5 /* Refresh to activate interval */
#endif
#if defined (CONFIG_MPC8240)
#define CFG_RDLAT 2 /* data latency from read command */
#endif
/* Bit-field values for MCCR4. */
#if defined (CONFIG_133MHZ_DRAM)
#define CFG_PRETOACT 3 /* Precharge to activate interval */
#define CFG_ACTTOPRE 7 /* Activate to Precharge interval */
#define CFG_ACTORW 5 /* Activate to R/W */
#define CFG_SDMODE_CAS_LAT 3 /* SDMODE CAS latency */
#else
#if 0
#define CFG_PRETOACT 2 /* Precharge to activate interval */
#define CFG_ACTTOPRE 3 /* Activate to Precharge interval */
#define CFG_ACTORW 3 /* Activate to R/W */
#define CFG_SDMODE_CAS_LAT 2 /* SDMODE CAS latency */
#endif
#define CFG_PRETOACT 2 /* Precharge to activate interval */
#define CFG_ACTTOPRE 5 /* Activate to Precharge interval */
#define CFG_ACTORW 3 /* Activate to R/W */
#define CFG_SDMODE_CAS_LAT 3 /* SDMODE CAS latency */
#endif
#define CFG_SDMODE_WRAP 0 /* SDMODE wrap type */
#define CFG_SDMODE_BURSTLEN 2 /* SDMODE Burst length 2=4, 3=8 */
#define CFG_REGDIMM 0
#if defined (CONFIG_MPC8240)
#define CFG_REGISTERD_TYPE_BUFFER 0
#elif defined (CONFIG_MPC8245)
#define CFG_REGISTERD_TYPE_BUFFER 1
#define CFG_EXTROM 0
#else
#error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240)
#endif
/*-----------------------------------------------------------------------
memory bank settings
* only bits 20-29 are actually used from these vales to set the
* start/end address the upper two bits will be 0, and the lower 20
* bits will be set to 0x00000 for a start address, or 0xfffff for an
* end address
*/
#define CFG_BANK0_START 0x00000000
#define CFG_BANK0_END (CFG_MAX_RAM_SIZE - 1)
#define CFG_BANK0_ENABLE 1
#define CFG_BANK1_START 0x3ff00000
#define CFG_BANK1_END 0x3fffffff
#define CFG_BANK1_ENABLE 0
#define CFG_BANK2_START 0x3ff00000
#define CFG_BANK2_END 0x3fffffff
#define CFG_BANK2_ENABLE 0
#define CFG_BANK3_START 0x3ff00000
#define CFG_BANK3_END 0x3fffffff
#define CFG_BANK3_ENABLE 0
#define CFG_BANK4_START 0x00000000
#define CFG_BANK4_END 0x00000000
#define CFG_BANK4_ENABLE 0
#define CFG_BANK5_START 0x00000000
#define CFG_BANK5_END 0x00000000
#define CFG_BANK5_ENABLE 0
#define CFG_BANK6_START 0x00000000
#define CFG_BANK6_END 0x00000000
#define CFG_BANK6_ENABLE 0
#define CFG_BANK7_START 0x00000000
#define CFG_BANK7_END 0x00000000
#define CFG_BANK7_ENABLE 0
/*-----------------------------------------------------------------------
* Memory bank enable bitmask, specifying which of the banks defined above
are actually present. MSB is for bank #7, LSB is for bank #0.
*/
#define CFG_BANK_ENABLE 0x01
#if defined (CONFIG_MPC8240)
#define CFG_ODCR 0xDF /* configures line driver impedances, */
/* see 8240 book for bit definitions */
#elif defined (CONFIG_MPC8245)
#if defined (CONFIG_133MHZ_DRAM)
#define CFG_ODCR 0xFE /* configures line driver impedances - 133MHz */
#else
#define CFG_ODCR 0xDE /* configures line driver impedances - 66MHz */
#endif
#else
#error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240)
#endif
#define CFG_PGMAX 0x32 /* how long the 8240 retains the */
/* currently accessed page in memory */
/* see 8240 book for details */
/*-----------------------------------------------------------------------
* Block Address Translation (BAT) register settings.
*/
/* SDRAM 0 - 256MB */
#define CFG_IBAT0L (CFG_SDRAM_BASE | BATL_PP_10 | BATL_MEMCOHERENCE)
#define CFG_IBAT0U (CFG_SDRAM_BASE | BATU_BL_256M | BATU_VS | BATU_VP)
/* stack in DCACHE @ 1GB (no backing mem) */
#define CFG_IBAT1L (CFG_INIT_RAM_ADDR | BATL_PP_10 | BATL_MEMCOHERENCE)
#define CFG_IBAT1U (CFG_INIT_RAM_ADDR | BATU_BL_128K | BATU_VS | BATU_VP)
/* PCI memory */
#define CFG_IBAT2L (0x80000000 | BATL_PP_10 | BATL_CACHEINHIBIT)
#define CFG_IBAT2U (0x80000000 | BATU_BL_256M | BATU_VS | BATU_VP)
/* Flash, config addrs, etc */
#define CFG_IBAT3L (0xF0000000 | BATL_PP_10 | BATL_CACHEINHIBIT)
#define CFG_IBAT3U (0xF0000000 | BATU_BL_256M | BATU_VS | BATU_VP)
#define CFG_DBAT0L CFG_IBAT0L
#define CFG_DBAT0U CFG_IBAT0U
#define CFG_DBAT1L CFG_IBAT1L
#define CFG_DBAT1U CFG_IBAT1U
#define CFG_DBAT2L CFG_IBAT2L
#define CFG_DBAT2U CFG_IBAT2U
#define CFG_DBAT3L CFG_IBAT3L
#define CFG_DBAT3U CFG_IBAT3U
/*-----------------------------------------------------------------------
* Cache Configuration
*/
#define CFG_CACHELINE_SIZE 32
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
# define CFG_CACHELINE_SHIFT 5 /* log base 2 of the above value */
#endif
/*-----------------------------------------------------------------------
* Internal Definitions
*
* Boot Flags
*/
#define BOOTFLAG_COLD 0x01 /* Normal Power-On: Boot from FLASH */
#define BOOTFLAG_WARM 0x02 /* Software reboot */
/* values according to the manual */
#define CONFIG_DRAM_50MHZ 1
#define CONFIG_SDRAM_50MHZ
#undef NR_8259_INTS
#define NR_8259_INTS 1
/*-----------------------------------------------------------------------
* IDE/ATA stuff
*/
#define CFG_IDE_MAXBUS 1 /* max. 2 IDE busses */
#define CFG_IDE_MAXDEVICE (CFG_IDE_MAXBUS*1) /* max. 2 drives per IDE bus */
#define CFG_ATA_BASE_ADDR CFG_ISA_IO /* base address */
#define CFG_ATA_IDE0_OFFSET 0x01F0 /* ide0 offste */
#define CFG_ATA_IDE1_OFFSET 0x0170 /* ide1 offset */
#define CFG_ATA_DATA_OFFSET 0 /* data reg offset */
#define CFG_ATA_REG_OFFSET 0 /* reg offset */
#define CFG_ATA_ALT_OFFSET 0x200 /* alternate register offset */
#define CONFIG_ATAPI
#undef CONFIG_IDE_8xx_DIRECT /* no pcmcia interface required */
#undef CONFIG_IDE_LED /* no led for ide supported */
#undef CONFIG_IDE_RESET /* reset for ide supported... */
#undef CONFIG_IDE_RESET_ROUTINE /* with a special reset function */
/*-----------------------------------------------------------------------
* DISK Partition support
*/
#define CONFIG_DOS_PARTITION
/*-----------------------------------------------------------------------
* For booting Linux, the board info and command line data
* have to be in the first 8 MB of memory, since this is
* the maximum mapped by the Linux kernel during initialization.
*/
#define CFG_BOOTMAPSZ (8 << 20) /* Initial Memory map for Linux */
#endif /* __CONFIG_H */
+3 -1
View File
@@ -85,7 +85,8 @@
CFG_CMD_ASKENV | \
CFG_CMD_DHCP | \
CFG_CMD_ELF | \
CFG_CMD_JFFS2 )
CFG_CMD_JFFS2 | \
CFG_CMD_PING )
#include <cmd_confdefs.h>
/*
@@ -143,6 +144,7 @@
#define CONFIG_INCA_IP_SWITCH
#define CONFIG_NET_MULTI
#define CONFIG_INCA_IP_SWITCH_AMDIX
#define CFG_JFFS2_FIRST_BANK 1
#define CFG_JFFS2_NUM_BANKS 1
+211
View File
@@ -0,0 +1,211 @@
/*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
* Markus Pietrek <mpietrek@fsforth.de>
*
* Configuation settings for the NetSilicon NS9750 DevBoard
*
* 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 __CONFIG_H
#define __CONFIG_H
/*
* If we are developing, we might want to start armboot from ram
* so we MUST NOT initialize critical regs like mem-timing ...
*/
#define CONFIG_INIT_CRITICAL /* undef for developing */
/*
* High Level Configuration Options
* (easy to change)
*/
#define CONFIG_ARM926EJS 1 /* This is an ARM926EJS Core */
#define CONFIG_NS9750 1 /* in an NetSilicon NS9750 SoC */
#define CONFIG_NS9750DEV 1 /* on an NetSilicon NS9750 DevBoard */
/* input clock of PLL */
#define CONFIG_SYS_CLK_FREQ 324403200 /* Don't use PLL. SW11-4 off */
#define CPU_CLK_FREQ (CONFIG_SYS_CLK_FREQ/2)
#define AHB_CLK_FREQ (CONFIG_SYS_CLK_FREQ/4)
#define BBUS_CLK_FREQ (CONFIG_SYS_CLK_FREQ/8)
#undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ stuff */
/*@TODO #define CONFIG_STATUS_LED*/
#define CONFIG_USE_IRQ
/*
* Size of malloc() pool
*/
#define CFG_MALLOC_LEN (CFG_ENV_SIZE + 128*1024)
#define CFG_GBL_DATA_SIZE 128 /* size in bytes reserved for initial
* data */
/*
* Hardware drivers
*/
#define CFG_NS9750_UART 1 /* use on-chip UART */
#define CONFIG_DRIVER_NS9750_ETHERNET 1 /* use on-chip ethernet */
/*
* select serial console configuration
*/
#define CONFIG_CONS_INDEX 1 /* Port B */
/* allow to overwrite serial and ethaddr */
#define CONFIG_ENV_OVERWRITE
#define CONFIG_BAUDRATE 38400
/***********************************************************
* Command definition
***********************************************************/
#if 0 /* @TODO */
#define CONFIG_COMMANDS \
(CONFIG_CMD_DFL | \
CFG_CMD_CACHE | \
/*CFG_CMD_NAND |*/ \
/*CFG_CMD_EEPROM |*/ \
/*CFG_CMD_I2C |*/ \
/*CFG_CMD_USB |*/ \
CFG_CMD_REGINFO | \
CFG_CMD_DATE | \
CFG_CMD_ELF)
#else
#define CONFIG_COMMANDS \
(CONFIG_CMD_BDI | \
CFG_CMD_NET | \
CFG_CMD_PING | \
CFG_CMD_CONSOLE | \
CFG_CMD_LOADB | \
CFG_CMD_LOADS | \
CFG_CMD_MEMORY)
#endif
/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>
#define CONFIG_BOOTDELAY 3
/*#define CONFIG_BOOTARGS "root=ramfs devfs=mount console=ttySA0,9600" */
#define CONFIG_ETHADDR 00:04:f3:ff:ff:fb /*@TODO unset */
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 192.168.42.30
#define CONFIG_SERVERIP 192.168.42.1
/*#define CONFIG_BOOTFILE "elinos-lart" */
/*#define CONFIG_BOOTCOMMAND "tftp; bootm" */
#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CONFIG_KGDB_BAUDRATE 115200 /* speed to run kgdb serial port */
/* what's this ? it's not used anywhere */
#define CONFIG_KGDB_SER_INDEX 1 /* which serial port to use */
#endif
/*
* Miscellaneous configurable options
*/
#define CFG_LONGHELP /* undef to save memory */
#define CFG_PROMPT "NS9750DEV # " /* Monitor Command Prompt */
#define CFG_CBSIZE 256 /* Console I/O Buffer Size */
#define CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
#define CFG_MAXARGS 16 /* max number of command args */
#define CFG_BARGSIZE CFG_CBSIZE /* Boot Argument Buffer Size */
#define CFG_MEMTEST_START 0x00000000 /* memtest works on */
#define CFG_MEMTEST_END 0x00780000 /* 7,5 MB in DRAM */ /* @TODO */
#undef CFG_CLKS_IN_HZ /* everything, incl board info, in Hz */
#define CFG_LOAD_ADDR 0x00600000 /* default load address */ /* @TODO */
#define CFG_HZ (CPU_CLK_FREQ/64)
/* valid baudrates */
#define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
#define NS9750_ETH_PHY_ADDRESS (0x0000)
/*-----------------------------------------------------------------------
* Stack sizes
*
* The stack sizes are set up in start.S using the settings below
*/
#define CONFIG_STACKSIZE (128*1024) /* regular stack */
#ifdef CONFIG_USE_IRQ
#define CONFIG_STACKSIZE_IRQ (4*1024) /* IRQ stack */
#define CONFIG_STACKSIZE_FIQ (4*1024) /* FIQ stack */
#endif
/*-----------------------------------------------------------------------
* Physical Memory Map
*/
/* TODO */
#define CONFIG_NR_DRAM_BANKS 2 /* we have 1 bank of DRAM */
#define PHYS_SDRAM_1 0x00000000 /* SDRAM Bank #1 */
#define PHYS_SDRAM_1_SIZE 0x00800000 /* 8 MB */
#define PHYS_SDRAM_2 0x10000000 /* SDRAM Bank #1 */
#define PHYS_SDRAM_2_SIZE 0x00800000 /* 8 MB */
#define PHYS_FLASH_1 0x50000000 /* Flash Bank #1 */
#define CFG_FLASH_BASE PHYS_FLASH_1
/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
/* @TODO*/
#define CONFIG_AMD_LV400 1 /* uncomment this if you have a LV400 flash */
#if 0
#define CONFIG_AMD_LV800 1 /* uncomment this if you have a LV800 flash */
#endif
#define CFG_MAX_FLASH_BANKS 1 /* max number of memory banks */
#ifdef CONFIG_AMD_LV800
#define PHYS_FLASH_SIZE 0x00100000 /* 1MB */
#define CFG_MAX_FLASH_SECT (19) /* max number of sectors on one chip */
#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x0F0000) /* addr of environment */
#endif
#ifdef CONFIG_AMD_LV400
#define PHYS_FLASH_SIZE 0x00080000 /* 512KB */
#define CFG_MAX_FLASH_SECT (11) /* max number of sectors on one chip */
#define CFG_ENV_ADDR (CFG_FLASH_BASE + 0x070000) /* addr of environment */
#endif
/* timeout values are in ticks */
#define CFG_FLASH_ERASE_TOUT (5*CFG_HZ) /* Timeout for Flash Erase */
#define CFG_FLASH_WRITE_TOUT (5*CFG_HZ) /* Timeout for Flash Write */
/* @TODO */
/*#define CFG_ENV_IS_IN_FLASH 1*/
#define CFG_ENV_IS_NOWHERE
#define CFG_ENV_SIZE 0x10000 /* Total Size of Environment Sector */
#ifdef CONFIG_STATUS_LED
extern void __led_init(led_id_t mask, int state);
extern void __led_toggle(led_id_t mask);
extern void __led_set(led_id_t mask, int state);
#endif /* CONFIG_STATUS_LED */
#endif /* __CONFIG_H */
+93 -1
View File
@@ -179,7 +179,7 @@
#define USB_OTG_CTRL 0xFFFB040C
#define USB_TRANSCEIVER_CTRL 0xFFFE1064
#define PULL_DWN_CTRL_4 0xFFFE10AC
#define PULL_DWN_CTRL_4 0xFFFE10AC
#define PU_PD_SEL_0 0xFFFE10B4
#define PU_PD_SEL_1 0xFFFE10B8
#define PU_PD_SEL_2 0xFFFE10BC
@@ -221,6 +221,89 @@
#define OMAP_LCD_CONTROL TI925_LCD_CONTROL
/* I2C Registers */
#define I2C_BASE 0xfffb3800
#define I2C_REV (I2C_BASE + 0x00)
#define I2C_IE (I2C_BASE + 0x04)
#define I2C_STAT (I2C_BASE + 0x08)
#define I2C_IV (I2C_BASE + 0x0c)
#define I2C_BUF (I2C_BASE + 0x14)
#define I2C_CNT (I2C_BASE + 0x18)
#define I2C_DATA (I2C_BASE + 0x1c)
#define I2C_CON (I2C_BASE + 0x24)
#define I2C_OA (I2C_BASE + 0x28)
#define I2C_SA (I2C_BASE + 0x2c)
#define I2C_PSC (I2C_BASE + 0x30)
#define I2C_SCLL (I2C_BASE + 0x34)
#define I2C_SCLH (I2C_BASE + 0x38)
#define I2C_SYSTEST (I2C_BASE + 0x3c)
/* I2C masks */
/* I2C Interrupt Enable Register (I2C_IE): */
#define I2C_IE_XRDY_IE (1 << 4) /* Transmit data ready interrupt enable */
#define I2C_IE_RRDY_IE (1 << 3) /* Receive data ready interrupt enable */
#define I2C_IE_ARDY_IE (1 << 2) /* Register access ready interrupt enable */
#define I2C_IE_NACK_IE (1 << 1) /* No acknowledgment interrupt enable */
#define I2C_IE_AL_IE (1 << 0) /* Arbitration lost interrupt enable */
/* I2C Status Register (I2C_STAT): */
#define I2C_STAT_SBD (1 << 15) /* Single byte data */
#define I2C_STAT_BB (1 << 12) /* Bus busy */
#define I2C_STAT_ROVR (1 << 11) /* Receive overrun */
#define I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
#define I2C_STAT_AAS (1 << 9) /* Address as slave */
#define I2C_STAT_AD0 (1 << 8) /* Address zero */
#define I2C_STAT_XRDY (1 << 4) /* Transmit data ready */
#define I2C_STAT_RRDY (1 << 3) /* Receive data ready */
#define I2C_STAT_ARDY (1 << 2) /* Register access ready */
#define I2C_STAT_NACK (1 << 1) /* No acknowledgment interrupt enable */
#define I2C_STAT_AL (1 << 0) /* Arbitration lost interrupt enable */
/* I2C Interrupt Vector Register (I2C_IV): */
/* I2C Interrupt Code Register (I2C_INTCODE): */
#define I2C_INTCODE_MASK 7
#define I2C_INTCODE_NONE 0
#define I2C_INTCODE_AL 1 /* Arbitration lost */
#define I2C_INTCODE_NAK 2 /* No acknowledgement/general call */
#define I2C_INTCODE_ARDY 3 /* Register access ready */
#define I2C_INTCODE_RRDY 4 /* Rcv data ready */
#define I2C_INTCODE_XRDY 5 /* Xmit data ready */
/* I2C Buffer Configuration Register (I2C_BUF): */
#define I2C_BUF_RDMA_EN (1 << 15) /* Receive DMA channel enable */
#define I2C_BUF_XDMA_EN (1 << 7) /* Transmit DMA channel enable */
/* I2C Configuration Register (I2C_CON): */
#define I2C_CON_EN (1 << 15) /* I2C module enable */
#define I2C_CON_BE (1 << 14) /* Big endian mode */
#define I2C_CON_STB (1 << 11) /* Start byte mode (master mode only) */
#define I2C_CON_MST (1 << 10) /* Master/slave mode */
#define I2C_CON_TRX (1 << 9) /* Transmitter/receiver mode (master mode only) */
#define I2C_CON_XA (1 << 8) /* Expand address */
#define I2C_CON_RM (1 << 2) /* Repeat mode (master mode only) */
#define I2C_CON_STP (1 << 1) /* Stop condition (master mode only) */
#define I2C_CON_STT (1 << 0) /* Start condition (master mode only) */
/* I2C System Test Register (I2C_SYSTEST): */
#define I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */
#define I2C_SYSTEST_FREE (1 << 14) /* Free running mode (on breakpoint) */
#define I2C_SYSTEST_TMODE_MASK (3 << 12) /* Test mode select */
#define I2C_SYSTEST_TMODE_SHIFT (12) /* Test mode select */
#define I2C_SYSTEST_SCL_I (1 << 3) /* SCL line sense input value */
#define I2C_SYSTEST_SCL_O (1 << 2) /* SCL line drive output value */
#define I2C_SYSTEST_SDA_I (1 << 1) /* SDA line sense input value */
#define I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive output value */
/*
* MMC/SD Host Controller Registers
*/
@@ -696,3 +779,12 @@ int cpu_type(void);
#define IRQ_LEVEL_INT 1
#define IRQ_EDGE_INT 0
/* Macros to access registers */
#define outb(v,p) *(volatile u8 *) (p) = v
#define outw(v,p) *(volatile u16 *) (p) = v
#define outl(v,p) *(volatile u32 *) (p) = v
#define inb(p) *(volatile u8 *) (p)
#define inw(p) *(volatile u16 *) (p)
#define inl(p) *(volatile u32 *) (p)
+3
View File
@@ -105,5 +105,8 @@ int drv_video_init (void);
#ifdef CONFIG_KEYBOARD
int drv_keyboard_init (void);
#endif
#ifdef CONFIG_USB_TTY
int drv_usbtty_init (void);
#endif
#endif /* _DEVICES_H_ */
+25
View File
@@ -89,7 +89,9 @@
#define MPC5XXX_ICTL (CFG_MBAR + 0x0500)
#define MPC5XXX_GPT (CFG_MBAR + 0x0600)
#define MPC5XXX_GPIO (CFG_MBAR + 0x0b00)
#define MPC5XXX_WU_GPIO (CFG_MBAR + 0x0c00)
#define MPC5XXX_PCI (CFG_MBAR + 0x0d00)
#define MPC5XXX_USB (CFG_MBAR + 0x1000)
#define MPC5XXX_SDMA (CFG_MBAR + 0x1200)
#define MPC5XXX_XLBARB (CFG_MBAR + 0x1f00)
@@ -107,6 +109,7 @@
#endif
#define MPC5XXX_FEC (CFG_MBAR + 0x3000)
#define MPC5XXX_ATA (CFG_MBAR + 0x3A00)
#define MPC5XXX_I2C1 (CFG_MBAR + 0x3D00)
#define MPC5XXX_I2C2 (CFG_MBAR + 0x3D40)
@@ -132,6 +135,7 @@
#define MPC5XXX_CDM_JTAGID (MPC5XXX_CDM + 0x0000)
#define MPC5XXX_CDM_PORCFG (MPC5XXX_CDM + 0x0004)
#define MPC5XXX_CDM_CFG (MPC5XXX_CDM + 0x000c)
#define MPC5XXX_CDM_48_FDC (MPC5XXX_CDM + 0x0010)
#define MPC5XXX_CDM_SRESET (MPC5XXX_CDM + 0x0020)
/* Local Plus Bus interface */
@@ -161,6 +165,12 @@
/* GPIO registers */
#define MPC5XXX_GPS_PORT_CONFIG (MPC5XXX_GPIO + 0x0000)
/* WakeUp GPIO registers */
#define MPC5XXX_WU_GPIO_ENABLE (MPC5XXX_WU_GPIO + 0x0000)
#define MPC5XXX_WU_GPIO_ODE (MPC5XXX_WU_GPIO + 0x0004)
#define MPC5XXX_WU_GPIO_DIR (MPC5XXX_WU_GPIO + 0x0008)
#define MPC5XXX_WU_GPIO_DATA (MPC5XXX_WU_GPIO + 0x000c)
/* PCI registers */
#define MPC5XXX_PCI_CMD (MPC5XXX_PCI + 0x04)
#define MPC5XXX_PCI_CFG (MPC5XXX_PCI + 0x0c)
@@ -207,6 +217,12 @@
#define MPC5XXX_GPT0_ENABLE (MPC5XXX_GPT + 0x0)
#define MPC5XXX_GPT0_COUNTER (MPC5XXX_GPT + 0x4)
/* ATA registers */
#define MPC5XXX_ATA_HOST_CONFIG (MPC5XXX_ATA + 0x0000)
#define MPC5XXX_ATA_PIO1 (MPC5XXX_ATA + 0x0008)
#define MPC5XXX_ATA_PIO2 (MPC5XXX_ATA + 0x000C)
#define MPC5XXX_ATA_SHARE_COUNT (MPC5XXX_ATA + 0x002C)
/* I2Cn control register bits */
#define I2C_EN 0x80
#define I2C_IEN 0x40
@@ -285,6 +301,15 @@
#define PSC_MODE_ONE_STOP 0x07
#define PSC_MODE_TWO_STOP 0x0f
/* ATA config fields */
#define MPC5xxx_ATA_HOSTCONF_SMR 0x80000000UL /* State machine
reset */
#define MPC5xxx_ATA_HOSTCONF_FR 0x40000000UL /* FIFO Reset */
#define MPC5xxx_ATA_HOSTCONF_IE 0x02000000UL /* Enable interrupt
in PIO */
#define MPC5xxx_ATA_HOSTCONF_IORDY 0x01000000UL /* Drive supports
IORDY protocol */
#ifndef __ASSEMBLY__
struct mpc5xxx_psc {
volatile u8 mode; /* PSC + 0x00 */
+125
View File
@@ -0,0 +1,125 @@
/***********************************************************************
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
*
* $Id: ns9750_bbus.h,v 1.1 2004/02/16 10:37:20 mpietrek Exp $
* @Author: Markus Pietrek
* @Descr: Definitions for BBus usage
* @References: [1] NS9750 Hardware Reference Manual/December 2003 Chap. 10
*
* 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 FS_NS9750_BBUS_H
#define FS_NS9750_BBUS_H
#define NS9750_BBUS_MODULE_BASE (0x90600000)
#define get_bbus_reg_addr(c) \
((volatile unsigned int *)(NS9750_BBUS_MODULE_BASE+(unsigned int) (c)))
/* We have support for 50 GPIO pins */
#define get_gpio_cfg_reg_addr(pin) \
get_bbus_reg_addr( NS9750_BBUS_GPIO_CFG_BASE + (((pin) >> 3) * 4) )
/* To Read/Modify/Write a pin configuration register, use it like
set_gpio_cfg_reg_val( 12, NS9750_GPIO_CFG_FUNC_GPIO|NS9750_GPIO_CFG_OUTPUT );
They should be wrapped by cli()/sti() */
#define set_gpio_cfg_reg_val(pin,cfg) \
*get_gpio_cfg_reg_addr(pin)=(*get_gpio_cfg_reg_addr((pin)) & \
~NS9750_GPIO_CFG_MASK((pin))) |\
NS9750_GPIO_CFG_VAL((pin),(cfg));
#define NS9750_GPIO_CFG_MASK(pin) (NS9750_GPIO_CFG_VAL(pin, \
NS9750_GPIO_CFG_MA))
#define NS9750_GPIO_CFG_VAL(pin,cfg) ((cfg) << (((pin) % 8) * 4))
#define NS9750_GPIO_CFG_MA (0x0F)
#define NS9750_GPIO_CFG_INPUT (0x00)
#define NS9750_GPIO_CFG_OUTPUT (0x08)
#define NS9750_GPIO_CFG_FUNC_GPIO (0x03)
#define NS9750_GPIO_CFG_FUNC_2 (0x02)
#define NS9750_GPIO_CFG_FUNC_1 (0x01)
#define NS9750_GPIO_CFG_FUNC_0 (0x00)
/* the register addresses */
#define NS9750_BBUS_MASTER_RESET (0x00)
#define NS9750_BBUS_GPIO_CFG_BASE (0x10)
#define NS9750_BBUS_GPIO_CTRL_BASE (0x30)
#define NS9750_BBUS_GPIO_STAT_BASE (0x40)
#define NS9750_BBUS_MONITOR (0x50)
#define NS9750_BBUS_DMA_INT_STAT (0x60)
#define NS9750_BBUS_DMA_INT_ENABLE (0x64)
#define NS9750_BBUS_USB_CFG (0x70)
#define NS9750_BBUS_ENDIAN_CFG (0x80)
#define NS9750_BBUS_ARM_WAKE_UP (0x90)
/* register bit fields */
#define NS9750_BBUS_MASTER_RESET_UTIL (0x00000100)
#define NS9750_BBUS_MASTER_RESET_I2C (0x00000080)
#define NS9750_BBUS_MASTER_RESET_1284 (0x00000040)
#define NS9750_BBUS_MASTER_RESET_SER4 (0x00000020)
#define NS9750_BBUS_MASTER_RESET_SER3 (0x00000010)
#define NS9750_BBUS_MASTER_RESET_SER2 (0x00000008)
#define NS9750_BBUS_MASTER_RESET_SER1 (0x00000004)
#define NS9750_BBUS_MASTER_RESET_USB (0x00000002)
#define NS9750_BBUS_MASTER_RESET_DMA (0x00000001)
/* BS9750_BBUS_DMA_INT_BINT* are valid for *DMA_INT_STAT and *DMA_INT_ENABLE */
#define NS9750_BBUS_DMA_INT_BINT16 (0x00010000)
#define NS9750_BBUS_DMA_INT_BINT15 (0x00008000)
#define NS9750_BBUS_DMA_INT_BINT14 (0x00004000)
#define NS9750_BBUS_DMA_INT_BINT13 (0x00002000)
#define NS9750_BBUS_DMA_INT_BINT12 (0x00001000)
#define NS9750_BBUS_DMA_INT_BINT11 (0x00000800)
#define NS9750_BBUS_DMA_INT_BINT10 (0x00000400)
#define NS9750_BBUS_DMA_INT_BINT9 (0x00000200)
#define NS9750_BBUS_DMA_INT_BINT8 (0x00000100)
#define NS9750_BBUS_DMA_INT_BINT7 (0x00000080)
#define NS9750_BBUS_DMA_INT_BINT6 (0x00000040)
#define NS9750_BBUS_DMA_INT_BINT5 (0x00000020)
#define NS9750_BBUS_DMA_INT_BINT4 (0x00000010)
#define NS9750_BBUS_DMA_INT_BINT3 (0x00000008)
#define NS9750_BBUS_DMA_INT_BINT2 (0x00000004)
#define NS9750_BBUS_DMA_INT_BINT1 (0x00000002)
#define NS9750_BBUS_DMA_INT_BINT0 (0x00000001)
#define NS9750_BBUS_USB_CFG_OUTEN (0x00000008)
#define NS9750_BBUS_USB_CFG_SPEED (0x00000004)
#define NS9750_BBUS_USB_CFG_CFG_MA (0x00000003)
#define NS9750_BBUS_USB_CFG_CFG_HOST_SOFT (0x00000003)
#define NS9750_BBUS_USB_CFG_CFG_DEVICE (0x00000002)
#define NS9750_BBUS_USB_CFG_CFG_HOST (0x00000001)
#define NS9750_BBUS_USB_CFG_CFG_DIS (0x00000000)
#define NS9750_BBUS_ENDIAN_CFG_AHBM (0x00001000)
#define NS9750_BBUS_ENDIAN_CFG_I2C (0x00000080)
#define NS9750_BBUS_ENDIAN_CFG_IEEE1284 (0x00000040)
#define NS9750_BBUS_ENDIAN_CFG_SER4 (0x00000020)
#define NS9750_BBUS_ENDIAN_CFG_SER3 (0x00000010)
#define NS9750_BBUS_ENDIAN_CFG_SER2 (0x00000008)
#define NS9750_BBUS_ENDIAN_CFG_SER1 (0x00000004)
#define NS9750_BBUS_ENDIAN_CFG_USB (0x00000002)
#define NS9750_BBUS_ENDIAN_CFG_DMA (0x00000001)
#endif /* FS_NS9750_BBUS_H */
+526
View File
@@ -0,0 +1,526 @@
/***********************************************************************
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
*
* $Id: ns9750_eth.h,v 1.2 2004/02/24 13:25:39 mpietrek Exp $
* @Author: Markus Pietrek
* @References: [1] NS9750 Hardware Reference, December 2003
* [2] Intel LXT971 Datasheet #249414 Rev. 02
* [3] NS7520 Linux Ethernet Driver
*
* 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 FS_NS9750_ETH_H
#define FS_NS9750_ETH_H
#ifdef CONFIG_DRIVER_NS9750_ETHERNET
#define NS9750_ETH_MODULE_BASE (0xA0600000)
#define get_eth_reg_addr(c) \
((volatile unsigned int*) ( NS9750_ETH_MODULE_BASE+(unsigned int) (c)))
#define NS9750_ETH_EGCR1 (0x0000)
#define NS9750_ETH_EGCR2 (0x0004)
#define NS9750_ETH_EGSR (0x0008)
#define NS9750_ETH_FIFORX (0x000C)
#define NS9750_ETH_FIFOTX (0x0010)
#define NS9750_ETH_FIFOTXS (0x0014)
#define NS9750_ETH_ETSR (0x0018)
#define NS9750_ETH_ERSR (0x001C)
#define NS9750_ETH_MAC1 (0x0400)
#define NS9750_ETH_MAC2 (0x0404)
#define NS9750_ETH_IPGT (0x0408)
#define NS9750_ETH_IPGR (0x040C)
#define NS9750_ETH_CLRT (0x0410)
#define NS9750_ETH_MAXF (0x0414)
#define NS9750_ETH_SUPP (0x0418)
#define NS9750_ETH_TEST (0x041C)
#define NS9750_ETH_MCFG (0x0420)
#define NS9750_ETH_MCMD (0x0424)
#define NS9750_ETH_MADR (0x0428)
#define NS9750_ETH_MWTD (0x042C)
#define NS9750_ETH_MRDD (0x0430)
#define NS9750_ETH_MIND (0x0434)
#define NS9750_ETH_SA1 (0x0440)
#define NS9750_ETH_SA2 (0x0444)
#define NS9750_ETH_SA3 (0x0448)
#define NS9750_ETH_SAFR (0x0500)
#define NS9750_ETH_HT1 (0x0504)
#define NS9750_ETH_HT2 (0x0508)
#define NS9750_ETH_STAT_BASE (0x0680)
#define NS9750_ETH_RXAPTR (0x0A00)
#define NS9750_ETH_RXBPTR (0x0A04)
#define NS9750_ETH_RXCPTR (0x0A08)
#define NS9750_ETH_RXDPTR (0x0A0C)
#define NS9750_ETH_EINTR (0x0A10)
#define NS9750_ETH_EINTREN (0x0A14)
#define NS9750_ETH_TXPTR (0x0A18)
#define NS9750_ETH_TXRPTR (0x0A1C)
#define NS9750_ETH_TXERBD (0x0A20)
#define NS9750_ETH_TXSPTR (0x0A24)
#define NS9750_ETH_RXAOFF (0x0A28)
#define NS9750_ETH_RXBOFF (0x0A2C)
#define NS9750_ETH_RXCOFF (0x0A30)
#define NS9750_ETH_RXDOFF (0x0A34)
#define NS9750_ETH_TXOFF (0x0A38)
#define NS9750_ETH_RXFREE (0x0A3C)
#define NS9750_ETH_TXBD (0x1000)
/* register bit fields */
#define NS9750_ETH_EGCR1_ERX (0x80000000)
#define NS9750_ETH_EGCR1_ERXDMA (0x40000000)
#define NS9750_ETH_EGCR1_ERXSHT (0x10000000)
#define NS9750_ETH_EGCR1_ERXSIZ (0x08000000)
#define NS9750_ETH_EGCR1_ETXSIZ (0x04000000)
#define NS9750_ETH_EGCR1_ETXDIAG (0x02000000)
#define NS9750_ETH_EGCR1_ERXBAD (0x01000000)
#define NS9750_ETH_EGCR1_ETX (0x00800000)
#define NS9750_ETH_EGCR1_ETXDMA (0x00400000)
#define NS9750_ETH_EGCR1_ETXWM (0x00200000)
#define NS9750_ETH_EGCR1_ERXADV (0x00100000)
#define NS9750_ETH_EGCR1_ERXINIT (0x00080000)
#define NS9750_ETH_EGCR1_PHY_MODE_MA (0x0000C000)
#define NS9750_ETH_EGCR1_PHY_MODE_MII (0x00008000)
#define NS9750_ETH_EGCR1_PHY_MODE_RMII (0x00004000)
#define NS9750_ETH_EGCR1_RXCINV (0x00001000)
#define NS9750_ETH_EGCR1_TXCINV (0x00000800)
#define NS9750_ETH_EGCR1_RXALIGN (0x00000400)
#define NS9750_ETH_EGCR1_MAC_HRST (0x00000200)
#define NS9750_ETH_EGCR1_ITXA (0x00000100)
#define NS9750_ETH_EGCR2_TPTV_MA (0xFFFF0000)
#define NS9750_ETH_EGCR2_TPCF (0x00000040)
#define NS9750_ETH_EGCR2_THPDF (0x00000020)
#define NS9750_ETH_EGCR2_TCLER (0x00000008)
#define NS9750_ETH_EGCR2_AUTOZ (0x00000004)
#define NS9750_ETH_EGCR2_CLRCNT (0x00000002)
#define NS9750_ETH_EGCR2_STEN (0x00000001)
#define NS9750_ETH_EGSR_RXINIT (0x00100000)
#define NS9750_ETH_EGSR_TXFIFONF (0x00080000)
#define NS9750_ETH_EGSR_TXFIFOH (0x00040000)
#define NS9750_ETH_EGSR_TXFIFOE (0x00010000)
#define NS9750_ETH_FIFOTXS_ALL (0x00000055)
#define NS9750_ETH_FIFOTXS_3 (0x000000d5)
#define NS9750_ETH_FIFOTXS_2 (0x00000035)
#define NS9750_ETH_FIFOTXS_1 (0x0000000D)
#define NS9750_ETH_FIFOTXS_0 (0x00000003)
#define NS9750_ETH_ETSR_TXOK (0x00008000)
#define NS9750_ETH_ETSR_TXBR (0x00004000)
#define NS9750_ETH_ETSR_TXMC (0x00002000)
#define NS9750_ETH_ETSR_TXAL (0x00001000)
#define NS9750_ETH_ETSR_TXAED (0x00000800)
#define NS9750_ETH_ETSR_TXAEC (0x00000400)
#define NS9750_ETH_ETSR_TXAUR (0x00000200)
#define NS9750_ETH_ETSR_TXAJ (0x00000100)
#define NS9750_ETH_ETSR_TXDEF (0x00000040)
#define NS9750_ETH_ETSR_TXCRC (0x00000020)
#define NS9750_ETH_ETSR_TXCOLC (0x0000000F)
#define NS9750_ETH_ERSR_RXSIZE_MA (0x0FFF0000)
#define NS9750_ETH_ERSR_RXCE (0x00008000)
#define NS9750_ETH_ERSR_RXDV (0x00004000)
#define NS9750_ETH_ERSR_RXOK (0x00002000)
#define NS9750_ETH_ERSR_RXBR (0x00001000)
#define NS9750_ETH_ERSR_RXMC (0x00000800)
#define NS9750_ETH_ERSR_RXCRC (0x00000400)
#define NS9750_ETH_ERSR_RXDR (0x00000200)
#define NS9750_ETH_ERSR_RXCV (0x00000100)
#define NS9750_ETH_ERSR_RXSHT (0x00000040)
#define NS9750_ETH_MAC1_SRST (0x00008000)
#define NS9750_ETH_MAC1_SIMMRST (0x00004000)
#define NS9750_ETH_MAC1_RPEMCSR (0x00000800)
#define NS9750_ETH_MAC1_RPERFUN (0x00000400)
#define NS9750_ETH_MAC1_RPEMCST (0x00000200)
#define NS9750_ETH_MAC1_RPETFUN (0x00000100)
#define NS9750_ETH_MAC1_LOOPBK (0x00000010)
#define NS9750_ETH_MAC1_TXFLOW (0x00000008)
#define NS9750_ETH_MAC1_RXFLOW (0x00000004)
#define NS9750_ETH_MAC1_PALLRX (0x00000002)
#define NS9750_ETH_MAC1_RXEN (0x00000001)
#define NS9750_ETH_MAC2_EDEFER (0x00004000)
#define NS9750_ETH_MAC2_BACKP (0x00002000)
#define NS9750_ETH_MAC2_NOBO (0x00001000)
#define NS9750_ETH_MAC2_LONGP (0x00000200)
#define NS9750_ETH_MAC2_PUREP (0x00000100)
#define NS9750_ETH_MAC2_AUTOP (0x00000080)
#define NS9750_ETH_MAC2_VLANP (0x00000040)
#define NS9750_ETH_MAC2_PADEN (0x00000020)
#define NS9750_ETH_MAC2_CRCEN (0x00000010)
#define NS9750_ETH_MAC2_DELCRC (0x00000008)
#define NS9750_ETH_MAC2_HUGE (0x00000004)
#define NS9750_ETH_MAC2_FLENC (0x00000002)
#define NS9750_ETH_MAC2_FULLD (0x00000001)
#define NS9750_ETH_IPGT_MA (0x0000007F)
#define NS9750_ETH_IPGR_IPGR1 (0x00007F00)
#define NS9750_ETH_IPGR_IPGR2 (0x0000007F)
#define NS9750_ETH_CLRT_CWIN (0x00003F00)
#define NS9750_ETH_CLRT_RETX (0x0000000F)
#define NS9750_ETH_MAXF_MAXF (0x0000FFFF)
#define NS9750_ETH_SUPP_RPERMII (0x00008000)
#define NS9750_ETH_SUPP_SPEED (0x00000080)
#define NS9750_ETH_TEST_TBACK (0x00000004)
#define NS9750_ETH_TEST_TPAUSE (0x00000002)
#define NS9750_ETH_TEST_SPQ (0x00000001)
#define NS9750_ETH_MCFG_RMIIM (0x00008000)
#define NS9750_ETH_MCFG_CLKS_MA (0x0000001C)
#define NS9750_ETH_MCFG_CLKS_4 (0x00000004)
#define NS9750_ETH_MCFG_CLKS_6 (0x00000008)
#define NS9750_ETH_MCFG_CLKS_8 (0x0000000C)
#define NS9750_ETH_MCFG_CLKS_10 (0x00000010)
#define NS9750_ETH_MCFG_CLKS_20 (0x00000014)
#define NS9750_ETH_MCFG_CLKS_30 (0x00000018)
#define NS9750_ETH_MCFG_CLKS_40 (0x0000001C)
#define NS9750_ETH_MCFG_SPRE (0x00000002)
#define NS9750_ETH_MCFG_SCANI (0x00000001)
#define NS9750_ETH_MCMD_SCAN (0x00000002)
#define NS9750_ETH_MCMD_READ (0x00000001)
#define NS9750_ETH_MADR_DADR_MA (0x00001F00)
#define NS9750_ETH_MADR_RADR_MA (0x0000001F)
#define NS9750_ETH_MWTD_MA (0x0000FFFF)
#define NS9750_ETH_MRRD_MA (0x0000FFFF)
#define NS9750_ETH_MIND_MIILF (0x00000008)
#define NS9750_ETH_MIND_NVALID (0x00000004)
#define NS9750_ETH_MIND_SCAN (0x00000002)
#define NS9750_ETH_MIND_BUSY (0x00000001)
#define NS9750_ETH_SA1_OCTET1_MA (0x0000FF00)
#define NS9750_ETH_SA1_OCTET2_MA (0x000000FF)
#define NS9750_ETH_SA2_OCTET3_MA (0x0000FF00)
#define NS9750_ETH_SA2_OCTET4_MA (0x000000FF)
#define NS9750_ETH_SA3_OCTET5_MA (0x0000FF00)
#define NS9750_ETH_SA3_OCTET6_MA (0x000000FF)
#define NS9750_ETH_SAFR_PRO (0x00000008)
#define NS9750_ETH_SAFR_PRM (0x00000004)
#define NS9750_ETH_SAFR_PRA (0x00000002)
#define NS9750_ETH_SAFR_BROAD (0x00000001)
#define NS9750_ETH_HT1_MA (0x0000FFFF)
#define NS9750_ETH_HT2_MA (0x0000FFFF)
/* also valid for EINTREN */
#define NS9750_ETH_EINTR_RXOVL_DATA (0x02000000)
#define NS9750_ETH_EINTR_RXOVL_STAT (0x01000000)
#define NS9750_ETH_EINTR_RXBUFC (0x00800000)
#define NS9750_ETH_EINTR_RXDONEA (0x00400000)
#define NS9750_ETH_EINTR_RXDONEB (0x00200000)
#define NS9750_ETH_EINTR_RXDONEC (0x00100000)
#define NS9750_ETH_EINTR_RXDONED (0x00080000)
#define NS9750_ETH_EINTR_RXNOBUF (0x00040000)
#define NS9750_ETH_EINTR_RXBUFFUL (0x00020000)
#define NS9750_ETH_EINTR_RXBR (0x00010000)
#define NS9750_ETH_EINTR_STOVFL (0x00000040)
#define NS9750_ETH_EINTR_TXPAUSE (0x00000020)
#define NS9750_ETH_EINTR_TXBUFC (0x00000010)
#define NS9750_ETH_EINTR_TXBUFNR (0x00000008)
#define NS9750_ETH_EINTR_TXDONE (0x00000004)
#define NS9750_ETH_EINTR_TXERR (0x00000002)
#define NS9750_ETH_EINTR_TXIDLE (0x00000001)
#define NS9750_ETH_EINTR_RX_MA \
(NS9750_ETH_EINTR_RXOVL_DATA | \
NS9750_ETH_EINTR_RXOVL_STAT | \
NS9750_ETH_EINTR_RXBUFC | \
NS9750_ETH_EINTR_RXDONEA | \
NS9750_ETH_EINTR_RXDONEB | \
NS9750_ETH_EINTR_RXDONEC | \
NS9750_ETH_EINTR_RXDONED | \
NS9750_ETH_EINTR_RXNOBUF | \
NS9750_ETH_EINTR_RXBUFFUL | \
NS9750_ETH_EINTR_RXBR )
#define NS9750_ETH_EINTR_TX_MA \
(NS9750_ETH_EINTR_TXPAUSE | \
NS9750_ETH_EINTR_TXBUFC | \
NS9750_ETH_EINTR_TXBUFNR | \
NS9750_ETH_EINTR_TXDONE | \
NS9750_ETH_EINTR_TXERR | \
NS9750_ETH_EINTR_TXIDLE)
/* for TXPTR, TXRPTR, TXERBD and TXSPTR */
#define NS9750_ETH_TXPTR_MA (0x000000FF)
/* for RXAOFF, RXBOFF, RXCOFF and RXDOFF */
#define NS9750_ETH_RXOFF_MA (0x000007FF)
#define NS9750_ETH_TXOFF_MA (0x000003FF)
#define NS9750_ETH_RXFREE_D (0x00000008)
#define NS9750_ETH_RXFREE_C (0x00000004)
#define NS9750_ETH_RXFREE_B (0x00000002)
#define NS9750_ETH_RXFREE_A (0x00000001)
/* PHY definitions (LXT971A) [2] */
#define PHY_COMMON_CTRL (0x00)
#define PHY_COMMON_STAT (0x01)
#define PHY_COMMON_ID1 (0x02)
#define PHY_COMMON_ID2 (0x03)
#define PHY_COMMON_AUTO_ADV (0x04)
#define PHY_COMMON_AUTO_LNKB (0x05)
#define PHY_COMMON_AUTO_EXP (0x06)
#define PHY_COMMON_AUTO_NEXT (0x07)
#define PHY_COMMON_AUTO_LNKN (0x08)
#define PHY_LXT971_PORT_CFG (0x10)
#define PHY_LXT971_STAT2 (0x11)
#define PHY_LXT971_INT_ENABLE (0x12)
#define PHY_LXT971_INT_STATUS (0x13)
#define PHY_LXT971_LED_CFG (0x14)
#define PHY_LXT971_DIG_CFG (0x1A)
#define PHY_LXT971_TX_CTRL (0x1E)
/* CTRL PHY Control Register Bit Fields */
#define PHY_COMMON_CTRL_RESET (0x8000)
#define PHY_COMMON_CTRL_LOOPBACK (0x4000)
#define PHY_COMMON_CTRL_SPD_MA (0x2040)
#define PHY_COMMON_CTRL_SPD_10 (0x0000)
#define PHY_COMMON_CTRL_SPD_100 (0x2000)
#define PHY_COMMON_CTRL_SPD_1000 (0x0040)
#define PHY_COMMON_CTRL_SPD_RES (0x2040)
#define PHY_COMMON_CTRL_AUTO_NEG (0x1000)
#define PHY_COMMON_CTRL_POWER_DN (0x0800)
#define PHY_COMMON_CTRL_ISOLATE (0x0400)
#define PHY_COMMON_CTRL_RES_AUTO (0x0200)
#define PHY_COMMON_CTRL_DUPLEX (0x0100)
#define PHY_COMMON_CTRL_COL_TEST (0x0080)
#define PHY_COMMON_CTRL_RES1 (0x003F)
/* STAT Status Register Bit Fields */
#define PHY_COMMON_STAT_100BT4 (0x8000)
#define PHY_COMMON_STAT_100BXFD (0x4000)
#define PHY_COMMON_STAT_100BXHD (0x2000)
#define PHY_COMMON_STAT_10BTFD (0x1000)
#define PHY_COMMON_STAT_10BTHD (0x0800)
#define PHY_COMMON_STAT_100BT2FD (0x0400)
#define PHY_COMMON_STAT_100BT2HD (0x0200)
#define PHY_COMMON_STAT_EXT_STAT (0x0100)
#define PHY_COMMON_STAT_RES1 (0x0080)
#define PHY_COMMON_STAT_MF_PSUP (0x0040)
#define PHY_COMMON_STAT_AN_COMP (0x0020)
#define PHY_COMMON_STAT_RMT_FLT (0x0010)
#define PHY_COMMON_STAT_AN_CAP (0x0008)
#define PHY_COMMON_STAT_LNK_STAT (0x0004)
#define PHY_COMMON_STAT_JAB_DTCT (0x0002)
#define PHY_COMMON_STAT_EXT_CAP (0x0001)
/* AUTO_ADV Auto-neg Advert Register Bit Fields */
#define PHY_COMMON_AUTO_ADV_NP (0x8000)
#define PHY_COMMON_AUTO_ADV_RES1 (0x4000)
#define PHY_COMMON_AUTO_ADV_RMT_FLT (0x2000)
#define PHY_COMMON_AUTO_ADV_RES2 (0x1000)
#define PHY_COMMON_AUTO_ADV_AS_PAUSE (0x0800)
#define PHY_COMMON_AUTO_ADV_PAUSE (0x0400)
#define PHY_COMMON_AUTO_ADV_100BT4 (0x0200)
#define PHY_COMMON_AUTO_ADV_100BTXFD (0x0100)
#define PHY_COMMON_AUTO_ADV_100BTX (0x0080)
#define PHY_COMMON_AUTO_ADV_10BTFD (0x0040)
#define PHY_COMMON_AUTO_ADV_10BT (0x0020)
#define PHY_COMMON_AUTO_ADV_SEL_FLD_MA (0x001F)
#define PHY_COMMON_AUTO_ADV_802_9 (0x0002)
#define PHY_COMMON_AUTO_ADV_802_3 (0x0001)
/* AUTO_LNKB Auto-neg Link Ability Register Bit Fields */
#define PHY_COMMON_AUTO_LNKB_NP (0x8000)
#define PHY_COMMON_AUTO_LNKB_ACK (0x4000)
#define PHY_COMMON_AUTO_LNKB_RMT_FLT (0x2000)
#define PHY_COMMON_AUTO_LNKB_RES2 (0x1000)
#define PHY_COMMON_AUTO_LNKB_AS_PAUSE (0x0800)
#define PHY_COMMON_AUTO_LNKB_PAUSE (0x0400)
#define PHY_COMMON_AUTO_LNKB_100BT4 (0x0200)
#define PHY_COMMON_AUTO_LNKB_100BTXFD (0x0100)
#define PHY_COMMON_AUTO_LNKB_100BTX (0x0080)
#define PHY_COMMON_AUTO_LNKB_10BTFD (0x0040)
#define PHY_COMMON_AUTO_LNKB_10BT (0x0020)
#define PHY_COMMON_AUTO_LNKB_SEL_FLD_MA (0x001F)
#define PHY_COMMON_AUTO_LNKB_802_9 (0x0002)
#define PHY_COMMON_AUTO_LNKB_802_3 (0x0001)
/* AUTO_EXP Auto-neg Expansion Register Bit Fields */
#define PHY_COMMON_AUTO_EXP_RES1 (0xFFC0)
#define PHY_COMMON_AUTO_EXP_BASE_PAGE (0x0020)
#define PHY_COMMON_AUTO_EXP_PAR_DT_FLT (0x0010)
#define PHY_COMMON_AUTO_EXP_LNK_NP_CAP (0x0008)
#define PHY_COMMON_AUTO_EXP_NP_CAP (0x0004)
#define PHY_COMMON_AUTO_EXP_PAGE_REC (0x0002)
#define PHY_COMMON_AUTO_EXP_LNK_AN_CAP (0x0001)
/* AUTO_NEXT Aut-neg Next Page Tx Register Bit Fields */
#define PHY_COMMON_AUTO_NEXT_NP (0x8000)
#define PHY_COMMON_AUTO_NEXT_RES1 (0x4000)
#define PHY_COMMON_AUTO_NEXT_MSG_PAGE (0x2000)
#define PHY_COMMON_AUTO_NEXT_ACK_2 (0x1000)
#define PHY_COMMON_AUTO_NEXT_TOGGLE (0x0800)
#define PHY_COMMON_AUTO_NEXT_MSG (0x07FF)
/* AUTO_LNKN Auto-neg Link Partner Rx Reg Bit Fields */
#define PHY_COMMON_AUTO_LNKN_NP (0x8000)
#define PHY_COMMON_AUTO_LNKN_ACK (0x4000)
#define PHY_COMMON_AUTO_LNKN_MSG_PAGE (0x2000)
#define PHY_COMMON_AUTO_LNKN_ACK_2 (0x1000)
#define PHY_COMMON_AUTO_LNKN_TOGGLE (0x0800)
#define PHY_COMMON_AUTO_LNKN_MSG (0x07FF)
/* PORT_CFG Port Configuration Register Bit Fields */
#define PHY_LXT971_PORT_CFG_RES1 (0x8000)
#define PHY_LXT971_PORT_CFG_FORCE_LNK (0x4000)
#define PHY_LXT971_PORT_CFG_TX_DISABLE (0x2000)
#define PHY_LXT971_PORT_CFG_BYPASS_SCR (0x1000)
#define PHY_LXT971_PORT_CFG_RES2 (0x0800)
#define PHY_LXT971_PORT_CFG_JABBER (0x0400)
#define PHY_LXT971_PORT_CFG_SQE (0x0200)
#define PHY_LXT971_PORT_CFG_TP_LOOPBACK (0x0100)
#define PHY_LXT971_PORT_CFG_CRS_SEL (0x0080)
#define PHY_LXT971_PORT_CFG_SLEEP_MODE (0x0040)
#define PHY_LXT971_PORT_CFG_PRE_EN (0x0020)
#define PHY_LXT971_PORT_CFG_SLEEP_T_MA (0x0018)
#define PHY_LXT971_PORT_CFG_SLEEP_T_104 (0x0010)
#define PHY_LXT971_PORT_CFG_SLEEP_T_200 (0x0001)
#define PHY_LXT971_PORT_CFG_SLEEP_T_304 (0x0000)
#define PHY_LXT971_PORT_CFG_FLT_CODE_EN (0x0004)
#define PHY_LXT971_PORT_CFG_ALT_NP (0x0002)
#define PHY_LXT971_PORT_CFG_FIBER_SEL (0x0001)
/* STAT2 Status Register #2 Bit Fields */
#define PHY_LXT971_STAT2_RES1 (0x8000)
#define PHY_LXT971_STAT2_100BTX (0x4000)
#define PHY_LXT971_STAT2_TX_STATUS (0x2000)
#define PHY_LXT971_STAT2_RX_STATUS (0x1000)
#define PHY_LXT971_STAT2_COL_STATUS (0x0800)
#define PHY_LXT971_STAT2_LINK (0x0400)
#define PHY_LXT971_STAT2_DUPLEX_MODE (0x0200)
#define PHY_LXT971_STAT2_AUTO_NEG (0x0100)
#define PHY_LXT971_STAT2_AUTO_NEG_COMP (0x0080)
#define PHY_LXT971_STAT2_RES2 (0x0040)
#define PHY_LXT971_STAT2_POLARITY (0x0020)
#define PHY_LXT971_STAT2_PAUSE (0x0010)
#define PHY_LXT971_STAT2_ERROR (0x0008)
#define PHY_LXT971_STAT2_RES3 (0x0007)
/* INT_ENABLE Interrupt Enable Register Bit Fields */
#define PHY_LXT971_INT_ENABLE_RES1 (0xFF00)
#define PHY_LXT971_INT_ENABLE_ANMSK (0x0080)
#define PHY_LXT971_INT_ENABLE_SPEEDMSK (0x0040)
#define PHY_LXT971_INT_ENABLE_DUPLEXMSK (0x0020)
#define PHY_LXT971_INT_ENABLE_LINKMSK (0x0010)
#define PHY_LXT971_INT_ENABLE_RES2 (0x000C)
#define PHY_LXT971_INT_ENABLE_INTEN (0x0002)
#define PHY_LXT971_INT_ENABLE_TINT (0x0001)
/* INT_STATUS Interrupt Status Register Bit Fields */
#define PHY_LXT971_INT_STATUS_RES1 (0xFF00)
#define PHY_LXT971_INT_STATUS_ANDONE (0x0080)
#define PHY_LXT971_INT_STATUS_SPEEDCHG (0x0040)
#define PHY_LXT971_INT_STATUS_DUPLEXCHG (0x0020)
#define PHY_LXT971_INT_STATUS_LINKCHG (0x0010)
#define PHY_LXT971_INT_STATUS_RES2 (0x0008)
#define PHY_LXT971_INT_STATUS_MDINT (0x0004)
#define PHY_LXT971_INT_STATUS_RES3 (0x0003)
/* LED_CFG Interrupt LED Configuration Register Bit Fields */
#define PHY_LXT971_LED_CFG_SHIFT_LED1 (0x000C)
#define PHY_LXT971_LED_CFG_SHIFT_LED2 (0x0008)
#define PHY_LXT971_LED_CFG_SHIFT_LED3 (0x0004)
#define PHY_LXT971_LED_CFG_LEDFREQ_MA (0x000C)
#define PHY_LXT971_LED_CFG_LEDFREQ_RES (0x000C)
#define PHY_LXT971_LED_CFG_LEDFREQ_100 (0x0008)
#define PHY_LXT971_LED_CFG_LEDFREQ_60 (0x0004)
#define PHY_LXT971_LED_CFG_LEDFREQ_30 (0x0000)
#define PHY_LXT971_LED_CFG_PULSE_STR (0x0002)
#define PHY_LXT971_LED_CFG_RES1 (0x0001)
/* only one of these values must be shifted for each SHIFT_LED? */
#define PHY_LXT971_LED_CFG_UNUSED1 (0x000F)
#define PHY_LXT971_LED_CFG_DUPLEX_COL (0x000E)
#define PHY_LXT971_LED_CFG_LINK_ACT (0x000D)
#define PHY_LXT971_LED_CFG_LINK_RX (0x000C)
#define PHY_LXT971_LED_CFG_TEST_BLK_SLW (0x000B)
#define PHY_LXT971_LED_CFG_TEST_BLK_FST (0x000A)
#define PHY_LXT971_LED_CFG_TEST_OFF (0x0009)
#define PHY_LXT971_LED_CFG_TEST_ON (0x0008)
#define PHY_LXT971_LED_CFG_RX_OR_TX (0x0007)
#define PHY_LXT971_LED_CFG_UNUSED2 (0x0006)
#define PHY_LXT971_LED_CFG_DUPLEX (0x0005)
#define PHY_LXT971_LED_CFG_LINK (0x0004)
#define PHY_LXT971_LED_CFG_COLLISION (0x0003)
#define PHY_LXT971_LED_CFG_RECEIVE (0x0002)
#define PHY_LXT971_LED_CFG_TRANSMIT (0x0001)
#define PHY_LXT971_LED_CFG_SPEED (0x0000)
/* DIG_CFG Digitial Configuration Register Bit Fields */
#define PHY_LXT971_DIG_CFG_RES1 (0xF000)
#define PHY_LXT971_DIG_CFG_MII_DRIVE (0x0800)
#define PHY_LXT971_DIG_CFG_RES2 (0x0400)
#define PHY_LXT971_DIG_CFG_SHOW_SYMBOL (0x0200)
#define PHY_LXT971_DIG_CFG_RES3 (0x01FF)
#define PHY_LXT971_MDIO_MAX_CLK (8000000)
/* TX_CTRL Transmit Control Register Bit Fields
documentation is buggy for this register, therefore setting not included */
typedef enum
{
PHY_NONE = 0x0000, /* no PHY detected yet */
PHY_LXT971A = 0x0013
} PhyType;
#define PHY_MDIO_MAX_CLK (2500000)
#ifndef NS9750_ETH_PHY_ADDRESS
# define NS9750_ETH_PHY_ADDRESS (0x0001) /* suitable for UNC20 */
#endif /* NETARM_ETH_PHY_ADDRESS */
#endif /* CONFIG_DRIVER_NS9750_ETHERNET */
#endif /* FS_NS9750_ETH_H */
+172
View File
@@ -0,0 +1,172 @@
/***********************************************************************
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
*
* $Id: ns9750_mem.h,v 1.1 2004/02/16 10:37:20 mpietrek Exp $
* @Author: Markus Pietrek
* @Descr: Definitions for Memory Control Module
* @References: [1] NS9750 Hardware Reference Manual/December 2003 Chap. 5
*
* 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 FS_NS9750_MEM_H
#define FS_NS9750_SYS_H
#define NS9750_MEM_MODULE_BASE (0xA0700000)
#define get_mem_reg_addr(c) \
((volatile unsigned int *)(NS9750_MEM_MODULE_BASE+(unsigned int) (c)))
/* the register addresses */
#define NS9750_MEM_CTRL (0x0000)
#define NS9750_MEM_STATUS (0x0004)
#define NS9750_MEM_CFG (0x0008)
#define NS9750_MEM_DYN_CTRL (0x0020)
#define NS9750_MEM_DYN_REFRESH (0x0024)
#define NS9750_MEM_DYN_READ_CFG (0x0028)
#define NS9750_MEM_DYN_TRP (0x0030)
#define NS9750_MEM_DYN_TRAS (0x0034)
#define NS9750_MEM_DYN_TSREX (0x0038)
#define NS9750_MEM_DYN_TAPR (0x003C)
#define NS9750_MEM_DYN_TDAL (0x0040)
#define NS9750_MEM_DYN_TWR (0x0044)
#define NS9750_MEM_DYN_TRC (0x0048)
#define NS9750_MEM_DYN_TRFC (0x004C)
#define NS9750_MEM_DYN_TXSR (0x0050)
#define NS9750_MEM_DYN_TRRD (0x0054)
#define NS9750_MEM_DYN_TMRD (0x0058)
#define NS9750_MEM_STAT_EXT_WAIT (0x0080)
#define NS9750_MEM_DYN_CFG_BASE (0x0100)
#define NS9750_MEM_DYN_RAS_CAS_BASE (0x0104)
#define NS9750_MEM_STAT_CFG_BASE (0x0200)
#define NS9750_MEM_STAT_WAIT_WEN_BASE (0x0204)
#define NS9750_MEM_STAT_WAIT_OEN_BASE (0x0208)
#define NS9750_MEM_STAT_WAIT_RD_BASE (0x020C)
#define NS9750_MEM_STAT_WAIT_PAGE_BASE (0x0210)
#define NS9750_MEM_STAT_WAIR_WR_BASE (0x0214)
#define NS9750_MEM_STAT_WAIT_TURN_BASE (0x0218)
/* the vectored register addresses */
#define NS9750_MEM_DYN_CFG(c) (NS9750_MEM_DYN_CFG_BASE + (c)*0x20)
#define NS9750_MEM_DYN_RAS_CAS(c) (NS9750_MEM_DYN_RAS_CAS_BASE + (c)*0x20)
#define NS9750_MEM_STAT_CFG(c) (NS9750_MEM_STAT_CFG_BASE + (c)*0x20)
#define NS9750_MEM_STAT_WAIT_WEN(c) (NS9750_MEM_STAT_WAIT_WEN_BASE+(c)*0x20)
#define NS9750_MEM_STAT_WAIT_OEN(c) (NS9750_MEM_STAT_WAIT_OEN_BASE+(c)*0x20)
#define NS9750_MEM_STAT_RD(c) (NS9750_MEM_STAT_WAIT_RD_BASE+(c)*0x20)
#define NS9750_MEM_STAT_PAGE(c) (NS9750_MEM_STAT_WAIT_PAGE_BASE+(c)*0x20)
#define NS9750_MEM_STAT_WR(c) (NS9750_MEM_STAT_WAIT_WR_BASE+(c)*0x20)
#define NS9750_MEM_STAT_TURN(c) (NS9750_MEM_STAT_WAIT_TURN_BASE+(c)*0x20)
/* register bit fields */
#define NS9750_MEM_CTRL_L (0x00000004)
#define NS9750_MEM_CTRL_M (0x00000002)
#define NS9750_MEM_CTRL_E (0x00000001)
#define NS9750_MEM_STAT_SA (0x00000004)
#define NS9750_MEM_STAT_S (0x00000002)
#define NS9750_MEM_STAT_B (0x00000001)
#define NS9750_MEM_CFG_CLK (0x00000010)
#define NS9750_MEM_CFG_N (0x00000001)
#define NS9750_MEM_DYN_CTRL_NRP (0x00004000)
#define NS9750_MEM_DYN_CTRL_DP (0x00002000)
#define NS9750_MEM_DYN_CTRL_I_MA (0x00000180)
#define NS9750_MEM_DYN_CTRL_I_NORMAL (0x00000000)
#define NS9750_MEM_DYN_CTRL_I_MODE (0x00000080)
#define NS9750_MEM_DYN_CTRL_I_PALL (0x00000100)
#define NS9750_MEM_DYN_CTRL_I_NOP (0x00000180)
#define NS9750_MEM_DYN_CTRL_SR (0x00000002)
#define NS9750_MEM_DYN_CTRL_CE (0x00000001)
#define NS9750_MEM_DYN_REFRESH_MA (0x000007FF)
#define NS9750_MEM_DYN_READ_CFG_MA (0x00000003)
#define NS9750_MEM_DYN_READ_CFG_DELAY0 (0x00000001)
#define NS9750_MEM_DYN_READ_CFG_DELAY1 (0x00000002)
#define NS9750_MEM_DYN_READ_CFG_DELAY2 (0x00000003)
#define NS9750_MEM_DYN_TRP_MA (0x0000000F)
#define NS9750_MEM_DYN_TRAS_MA (0x0000000F)
#define NS9750_MEM_DYN_TSREX_MA (0x0000000F)
#define NS9750_MEM_DYN_TAPR_MA (0x0000000F)
#define NS9750_MEM_DYN_TDAL_MA (0x0000000F)
#define NS9750_MEM_DYN_TWR_MA (0x0000000F)
#define NS9750_MEM_DYN_TRC_MA (0x0000001F)
#define NS9750_MEM_DYN_TRFC_MA (0x0000001F)
#define NS9750_MEM_DYN_TXSR_MA (0x0000001F)
#define NS9750_MEM_DYN_TRRD_MA (0x0000000F)
#define NS9750_MEM_DYN_TMRD_MA (0x0000000F)
#define NS9750_MEM_STAT_EXTW_WAIT_MA (0x0000003F)
#define NS9750_MEM_DYN_CFG_P (0x00100000)
#define NS9750_MEM_DYN_CFG_BDMC (0x00080000)
#define NS9750_MEM_DYN_CFG_AM (0x00004000)
#define NS9750_MEM_DYN_CFG_AM_MA (0x00001F80)
#define NS9750_MEM_DYN_CFG_MD (0x00000018)
#define NS9750_MEM_DYN_RAS_CAS_CAS_MA (0x00000300)
#define NS9750_MEM_DYN_RAS_CAS_CAS_1 (0x00000100)
#define NS9750_MEM_DYN_RAS_CAS_CAS_2 (0x00000200)
#define NS9750_MEM_DYN_RAS_CAS_CAS_3 (0x00000300)
#define NS9750_MEM_DYN_RAS_CAS_RAS_MA (0x00000003)
#define NS9750_MEM_DYN_RAS_CAS_RAS_1 (0x00000001)
#define NS9750_MEM_DYN_RAS_CAS_RAS_2 (0x00000002)
#define NS9750_MEM_DYN_RAS_CAS_RAS_3 (0x00000003)
#define NS9750_MEM_STAT_CFG_PSMC (0x00100000)
#define NS9750_MEM_STAT_CFG_BSMC (0x00080000)
#define NS9750_MEM_STAT_CFG_EW (0x00000100)
#define NS9750_MEM_STAT_CFG_PB (0x00000080)
#define NS9750_MEM_STAT_CFG_PC (0x00000040)
#define NS9750_MEM_STAT_CFG_PM (0x00000008)
#define NS9750_MEM_STAT_CFG_MW_MA (0x00000003)
#define NS9750_MEM_STAT_CFG_MW_8 (0x00000000)
#define NS9750_MEM_STAT_CFG_MW_16 (0x00000001)
#define NS9750_MEM_STAT_CFG_MW_32 (0x00000002)
#define NS9750_MEM_STAT_WAIT_WEN_MA (0x0000000F)
#define NS9750_MEM_STAT_WAIT_OEN_MA (0x0000000F)
#define NS9750_MEM_STAT_WAIT_RD_MA (0x0000001F)
#define NS9750_MEM_STAT_WAIT_PAGE_MA (0x0000001F)
#define NS9750_MEM_STAT_WAIT_WR_MA (0x0000001F)
#define NS9750_MEM_STAT_WAIT_TURN_MA (0x0000000F)
#endif /* FS_NS9750_MEM_H */
+202
View File
@@ -0,0 +1,202 @@
/***********************************************************************
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
*
* $Id: ns9750_ser.h,v 1.1 2004/02/16 10:37:20 mpietrek Exp $
* @Author: Markus Pietrek
* @References: [1] NS9750 Hardware Reference, December 2003
*
* 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 FS_NS9750_SER_H
#define FS_NS9750_SER_H
#define NS9750_SER_MODULE_BASE (0x90200000)
#define get_ser_reg_addr(c) \
((volatile unsigned int *)(NS9750_SER_MODULE_BASE+(unsigned int) (c)))
#define get_ser_reg_addr_channel(reg,chan) \
get_ser_reg_addr((reg)+(((chan)<2)?0:0x00100000)+(((chan)&1)?0x40:0))
/* the register addresses */
#define NS9750_SER_CTRL_A (0x00)
#define NS9750_SER_CTRL_B (0x04)
#define NS9750_SER_STAT_A (0x08)
#define NS9750_SER_BITRATE (0x0C)
#define NS9750_SER_FIFO (0x10)
#define NS9750_SER_RX_BUF_TIMER (0x14)
#define NS9750_SER_RX_CHAR_TIMER (0x18)
#define NS9750_SER_RX_MATCH (0x1C)
#define NS9750_SER_RX_MATCH_MASK (0x20)
#define NS9750_SER_FLOW_CTRL (0x34)
#define NS9750_SER_FLOW_CTRL_FORCE (0x38)
/* register bit fields */
/* control A register */
#define NS9750_SER_CTRL_A_CE (0x80000000)
#define NS9750_SER_CTRL_A_BRK (0x40000000)
#define NS9750_SER_CTRL_A_STICKP (0x20000000)
#define NS9750_SER_CTRL_A_EPS (0x10000000)
#define NS9750_SER_CTRL_A_PE (0x08000000)
#define NS9750_SER_CTRL_A_STOP (0x04000000)
#define NS9750_SER_CTRL_A_WLS_MA (0x03000000)
#define NS9750_SER_CTRL_A_WLS_5 (0x00000000)
#define NS9750_SER_CTRL_A_WLS_6 (0x01000000)
#define NS9750_SER_CTRL_A_WLS_7 (0x02000000)
#define NS9750_SER_CTRL_A_WLS_8 (0x03000000)
#define NS9750_SER_CTRL_A_CTSTX (0x00800000)
#define NS9750_SER_CTRL_A_RTSRX (0x00400000)
#define NS9750_SER_CTRL_A_RL (0x00200000)
#define NS9750_SER_CTRL_A_LL (0x00100000)
#define NS9750_SER_CTRL_A_RES (0x000CF000)
#define NS9750_SER_CTRL_A_DTR (0x00020000)
#define NS9750_SER_CTRL_A_RTS (0x00010000)
#define NS9750_SER_CTRL_A_RIE_MA (0x00000E00)
#define NS9750_SER_CTRL_A_ERXDMA (0x00000100)
#define NS9750_SER_CTRL_A_RIC_MA (0x000000E0)
#define NS9750_SER_CTRL_A_TIC_MA (0x0000001E)
#define NS9750_SER_CTRL_A_ETXDMA (0x00000001)
/* control B register */
#define NS9750_SER_CTRL_B_RDM1 (0x80000000)
#define NS9750_SER_CTRL_B_RDM2 (0x40000000)
#define NS9750_SER_CTRL_B_RDM3 (0x20000000)
#define NS9750_SER_CTRL_B_RDM4 (0x10000000)
#define NS9750_SER_CTRL_B_RBGT (0x08000000)
#define NS9750_SER_CTRL_B_RCGT (0x04000000)
#define NS9750_SER_CTRL_B_MODE_MA (0x00300000)
#define NS9750_SER_CTRL_B_MODE_UART (0x00000000)
#define NS9750_SER_CTRL_B_MODE_HDLC (0x00100000)
#define NS9750_SER_CTRL_B_MODE_SPI_M (0x00200000)
#define NS9750_SER_CTRL_B_MODE_SPI_S (0x00300000)
#define NS9750_SER_CTRL_B_BITORDR (0x00080000)
#define NS9750_SER_CTRL_B_RES (0x0007703F)
#define NS9750_SER_CTRL_B_RTSTX (0x00008000)
#define NS9750_SER_CTRL_B_ENDEC_MA (0x00000FC0)
/* status A register */
#define NS9750_SER_STAT_A_MATCH1 (0x80000000)
#define NS9750_SER_STAT_A_MATCH2 (0x40000000)
#define NS9750_SER_STAT_A_MATCH3 (0x20000000)
#define NS9750_SER_STAT_A_MATCH4 (0x10000000)
#define NS9750_SER_STAT_A_BGAP (0x08000000)
#define NS9750_SER_STAT_A_CGAP (0x04000000)
#define NS9750_SER_STAT_A_RXFDB_MA (0x00300000)
#define NS9750_SER_STAT_A_RXFDB_FULL (0x00000000)
#define NS9750_SER_STAT_A_RXFDB_1 (0x00100000)
#define NS9750_SER_STAT_A_RXFDB_2 (0x00200000)
#define NS9750_SER_STAT_A_RXFDB_3 (0x00300000)
#define NS9750_SER_STAT_A_DCD (0x00080000)
#define NS9750_SER_STAT_A_RI (0x00040000)
#define NS9750_SER_STAT_A_DSR (0x00020000)
#define NS9750_SER_STAT_A_CTS (0x00010000)
#define NS9750_SER_STAT_A_RBRK (0x00008000)
#define NS9750_SER_STAT_A_RFE (0x00004000)
#define NS9750_SER_STAT_A_RPE (0x00002000)
#define NS9750_SER_STAT_A_ROVER (0x00001000)
#define NS9750_SER_STAT_A_RRDY (0x00000800)
#define NS9750_SER_STAT_A_RHALF (0x00000400)
#define NS9750_SER_STAT_A_RBC (0x00000200)
#define NS9750_SER_STAT_A_RFULL (0x00000100)
#define NS9750_SER_STAT_A_DCDI (0x00000080)
#define NS9750_SER_STAT_A_RII (0x00000040)
#define NS9750_SER_STAT_A_DSRI (0x00000020)
#define NS9750_SER_STAT_A_CTSI (0x00000010)
#define NS9750_SER_STAT_A_TRDY (0x00000008)
#define NS9750_SER_STAT_A_THALF (0x00000004)
#define NS9750_SER_STAT_A_TBC (0x00000002)
#define NS9750_SER_STAT_A_TEMPTY (0x00000001)
#define NS9750_SER_STAT_A_RX_COND_ERR ( NS9750_SER_STAT_A_RFE | \
NS9750_SER_STAT_A_ROVER | \
NS9750_SER_STAT_A_RPE )
#define NS9750_SER_STAT_A_RX_COND_ALL ( NS9750_SER_STAT_A_RX_COND_ERR | \
NS9750_SER_STAT_A_RBRK | \
NS9750_SER_STAT_A_RRDY | \
NS9750_SER_STAT_A_RHALF | \
NS9750_SER_STAT_A_RBC | \
NS9750_SER_STAT_A_DCDI | \
NS9750_SER_STAT_A_RII | \
NS9750_SER_STAT_A_DSRI | \
NS9750_SER_STAT_A_CTSI )
#define NS9750_SER_STAT_A_TX_COND_ALL ( NS9750_SER_STAT_A_TRDY | \
NS9750_SER_STAT_A_THALF | \
NS9750_SER_STAT_A_TBC | \
NS9750_SER_STAT_A_TEMPTY )
/* bit rate register */
#define NS9750_SER_BITRATE_EBIT (0x80000000)
#define NS9750_SER_BITRATE_TMODE (0x40000000)
#define NS9750_SER_BITRATE_RXSRC (0x20000000)
#define NS9750_SER_BITRATE_TXSRC (0x10000000)
#define NS9750_SER_BITRATE_RXEXT (0x08000000)
#define NS9750_SER_BITRATE_TXEXT (0x04000000)
#define NS9750_SER_BITRATE_CLKMUX_MA (0x03000000)
#define NS9750_SER_BITRATE_CLKMUX_XTAL (0x00000000)
#define NS9750_SER_BITRATE_CLKMUX_BCLK (0x01000000)
#define NS9750_SER_BITRATE_CLKMUX_OUT1 (0x02000000)
#define NS9750_SER_BITRATE_CLKMUX_OUT2 (0x03000000)
#define NS9750_SER_BITRATE_TXCINV (0x00800000)
#define NS9750_SER_BITRATE_RXCINV (0x00400000)
#define NS9750_SER_BITRATE_TCDR_MA (0x00180000)
#define NS9750_SER_BITRATE_TCDR_1 (0x00000000)
#define NS9750_SER_BITRATE_TCDR_8 (0x00080000)
#define NS9750_SER_BITRATE_TCDR_16 (0x00100000)
#define NS9750_SER_BITRATE_TCDR_32 (0x00180000)
#define NS9750_SER_BITRATE_RCDR_MA (0x00070000)
#define NS9750_SER_BITRATE_RCDR_1 (0x00000000)
#define NS9750_SER_BITRATE_RCDR_8 (0x00020000)
#define NS9750_SER_BITRATE_RCDR_16 (0x00040000)
#define NS9750_SER_BITRATE_RCDR_32 (0x00060000)
#define NS9750_SER_BITRATE_TICS (0x00010000)
#define NS9750_SER_BITRATE_RICS (0x00008000)
#define NS9750_SER_BITRATE_N_MA (0x00007FFF)
/* receive buffer gap timer */
#define NS9750_SER_RX_BUF_TIMER_TRUN (0x80000000) /* UART and SPI */
#define NS9750_SER_RX_BUF_TIMER_BT_MA (0x0000FFFF) /* UART and SPI */
#define NS9750_SER_RX_BUF_TIMER_MAXLEN_MA (0x0000FFFF) /* HDLC only */
/* receive character gap timer */
#define NS9750_SER_RX_CHAR_TIMER_TRUN (0x80000000)
#define NS9750_SER_RX_CHAR_TIMER_CT_MA (0x000FFFFF)
/* receive match */
#define NS9750_SER_RX_MATCH_RDMB1_MA (0xFF000000)
#define NS9750_SER_RX_MATCH_RDMB2_MA (0x00FF0000)
#define NS9750_SER_RX_MATCH_RDMB3_MA (0x0000FF00)
#define NS9750_SER_RX_MATCH_RDMB4_MA (0x000000FF)
/* receive match mask */
#define NS9750_SER_RX_MATCH_MASK_RDMB1_MA (0xFF000000)
#define NS9750_SER_RX_MATCH_MASK_RDMB2_MA (0x00FF0000)
#define NS9750_SER_RX_MATCH_MASK_RDMB3_MA (0x0000FF00)
#define NS9750_SER_RX_MATCH_MASK_RDMB4_MA (0x000000FF)
#endif /* FS_NS9750_SER_H */
+215
View File
@@ -0,0 +1,215 @@
/***********************************************************************
*
* Copyright (C) 2004 by FS Forth-Systeme GmbH.
* All rights reserved.
*
* $Id: ns9750_sys.h,v 1.1 2004/02/16 10:37:20 mpietrek Exp $
* @Author: Markus Pietrek
* @Descr: Definitions for SYS Control Module
* @References: [1] NS9750 Hardware Reference Manual/December 2003 Chap. 4
*
* 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 FS_NS9750_SYS_H
#define FS_NS9750_SYS_H
#define NS9750_SYS_MODULE_BASE (0xA0900000)
#define get_sys_reg_addr(c) \
((volatile unsigned int *)(NS9750_SYS_MODULE_BASE+(unsigned int) (c)))
/* the register addresses */
#define NS9750_SYS_AHB_GEN (0x0000)
#define NS9750_SYS_BRC_BASE (0x0004)
#define NS9750_SYS_AHB_TIMEOUT (0x0014)
#define NS9750_SYS_AHB_ERROR1 (0x0018)
#define NS9750_SYS_AHB_ERROR2 (0x001C)
#define NS9750_SYS_AHB_MON (0x0020)
#define NS9750_SYS_TIMER_COUNT_BASE (0x0044)
#define NS9750_SYS_TIMER_READ_BASE (0x0084)
#define NS9750_SYS_INT_VEC_ADR_BASE (0x00C4)
#define NS9750_SYS_INT_CFG_BASE (0x0144)
#define NS9750_SYS_ISRADDR (0x0164)
#define NS9750_SYS_INT_STAT_ACTIVE (0x0168)
#define NS9750_SYS_INT_STAT_RAW (0x016C)
#define NS9750_SYS_TIMER_INT_STAT (0x0170)
#define NS9750_SYS_SW_WDOG_CFG (0x0174)
#define NS9750_SYS_SW_WDOG_TIMER (0x0178)
#define NS9750_SYS_CLOCK (0x017C)
#define NS9750_SYS_RESET (0x0180)
#define NS9750_SYS_MISC (0x0184)
#define NS9750_SYS_PLL (0x0188)
#define NS9750_SYS_ACT_INT_STAT (0x018C)
#define NS9750_SYS_TIMER_CTRL_BASE (0x0190)
#define NS9750_SYS_CS_DYN_BASE_BASE (0x01D0)
#define NS9750_SYS_CS_DYN_MASK_BASE (0x01D4)
#define NS9750_SYS_CS_STATIC_BASE_BASE (0x01F0)
#define NS9750_SYS_CS_STATIC_MASK_BASE (0x01F4)
#define NS9750_SYS_GEN_ID (0x0210)
#define NS9750_SYS_EXT_INT_CTRL_BASE (0x0214)
/* the vectored register addresses */
#define NS9750_SYS_TIMER_COUNT(c) (NS9750_SYS_TIMER_COUNT_BASE + (c))
#define NS9750_SYS_TIMER_READ(c) (NS9750_SYS_TIMER_READ_BASE + (c))
#define NS9750_SYS_INT_VEC_ADR(c) (NS9750_SYS_INT_VEC_ADR_BASE + (c))
#define NS9750_SYS_TIMER_CTRL(c) (NS9750_SYS_TIMER_CTRL_BASE + (c))
/* CS_DYN start with 4 */
#define NS9750_SYS_CS_DYN_BASE(c) (NS9750_SYS_CS_DYN_BASE_BASE + ((c)-4)*2)
#define NS9750_SYS_CS_DYN_MASK(c) (NS9750_SYS_CS_DYN_MASK_BASE + ((c)-4)*2)
/* CS_STATIC start with 0 */
#define NS9750_SYS_CS_STATIC_BASE(c) (NS9750_SYS_CS_STATIC_BASE_BASE + (c)*2)
#define NS9750_SYS_CS_STATIC_MASK(c) (NS9750_SYS_CS_STATIC_MASK_BASE + (c)*2)
#define NS9750_SYS_EXT_INT_CTRL(c) (NS9750_SYS_EXT_INT_CTRL + (c))
/* register bit fields */
#define NS9750_SYS_AHB_GEN_EXMAM (0x00000001)
/* need to be n*8bit to BRC channel */
#define NS9750_SYS_BRC_CEB (0x00000080)
#define NS9750_SYS_BRC_BRF_MA (0x00000030)
#define NS9750_SYS_BRC_BRF_100 (0x00000000)
#define NS9750_SYS_BRC_BRF_75 (0x00000010)
#define NS9750_SYS_BRC_BRF_50 (0x00000020)
#define NS9750_SYS_BRC_BRF_25 (0x00000030)
#define NS9750_SYS_AHB_TIMEOUT_BAT_MA (0xFFFF0000)
#define NS9750_SYS_AHB_TIMEOUT_BMT_MA (0x0000FFFF)
#define NS9750_SYS_AHB_ERROR2_ABL (0x00040000)
#define NS9750_SYS_AHB_ERROR2_AER (0x00020000)
#define NS9750_SYS_AHB_ERROR2_ABM (0x00010000)
#define NS9750_SYS_AHB_ERROR2_ABA (0x00008000)
#define NS9750_SYS_AHB_ERROR2_HWRT (0x00004000)
#define NS9750_SYS_AHB_ERROR2_HMID_MA (0x00003C00)
#define NS9750_SYS_AHB_ERROR2_HTPC_MA (0x000003C0)
#define NS9750_SYS_AHB_ERROR2_HSZ_MA (0x00000038)
#define NS9750_SYS_AHB_ERROR2_RR_MA (0x00000007)
#define NS9750_SYS_AHB_MON_EIC (0x00800000)
#define NS9750_SYS_AHB_MON_MBII (0x00400000)
#define NS9750_SYS_AHB_MON_MBL_MA (0x003FFFC0)
#define NS9750_SYS_AHB_MON_MBLDC (0x00000020)
#define NS9750_SYS_AHB_MON_SERDC (0x00000010)
#define NS9750_SYS_AHB_MON_BMTC_MA (0x0000000C)
#define NS9750_SYS_AHB_MON_BMTC_RECORD (0x00000000)
#define NS9750_SYS_AHB_MON_BMTC_GEN_IRQ (0x00000004)
#define NS9750_SYS_AHB_MON_BMTC_GEN_RES (0x00000008)
#define NS9750_SYS_AHB_MON_BATC_MA (0x00000003)
#define NS9750_SYS_AHB_MON_BATC_RECORD (0x00000000)
#define NS9750_SYS_AHB_MON_BATC_GEN_IRQ (0x00000001)
#define NS9750_SYS_AHB_MON_BATC_GEN_RES (0x00000002)
/* need to be n*8bit to Int Level */
#define NS9750_SYS_INT_CFG_IE (0x00000080)
#define NS9750_SYS_INT_CFG_IT (0x00000020)
#define NS9750_SYS_INT_CFG_IAD_MA (0x0000001F)
#define NS9750_SYS_TIMER_INT_STAT_MA (0x0000FFFF)
#define NS9750_SYS_SW_WDOG_CFG_SWWE (0x00000080)
#define NS9750_SYS_SW_WDOG_CFG_SWWI (0x00000020)
#define NS9750_SYS_SW_WDOG_CFG_SWWIC (0x00000010)
#define NS9750_SYS_SW_WDOG_CFG_SWTCS_MA (0x00000007)
#define NS9750_SYS_SW_WDOG_CFG_SWTCS_2 (0x00000000)
#define NS9750_SYS_SW_WDOG_CFG_SWTCS_4 (0x00000001)
#define NS9750_SYS_SW_WDOG_CFG_SWTCS_8 (0x00000002)
#define NS9750_SYS_SW_WDOG_CFG_SWTCS_16 (0x00000003)
#define NS9750_SYS_SW_WDOG_CFG_SWTCS_32 (0x00000004)
#define NS9750_SYS_SW_WDOG_CFG_SWTCS_64 (0x00000005)
#define NS9750_SYS_CLOCK_LPCS_MA (0x00000380)
#define NS9750_SYS_CLOCK_LPCS_1 (0x00000000)
#define NS9750_SYS_CLOCK_LPCS_2 (0x00000080)
#define NS9750_SYS_CLOCK_LPCS_4 (0x00000100)
#define NS9750_SYS_CLOCK_LPCS_8 (0x00000180)
#define NS9750_SYS_CLOCK_LPCS_EXT (0x00000200)
#define NS9750_SYS_CLOCK_BBC (0x00000040)
#define NS9750_SYS_CLOCK_LCC (0x00000020)
#define NS9750_SYS_CLOCK_MCC (0x00000010)
#define NS9750_SYS_CLOCK_PARBC (0x00000008)
#define NS9750_SYS_CLOCK_PC (0x00000004)
#define NS9750_SYS_CLOCK_MACC (0x00000001)
#define NS9750_SYS_RESET_SR (0x80000000)
#define NS9750_SYS_RESET_I2CW (0x00100000)
#define NS9750_SYS_RESET_CSE (0x00080000)
#define NS9750_SYS_RESET_SMWE (0x00040000)
#define NS9750_SYS_RESET_EWE (0x00020000)
#define NS9750_SYS_RESET_PI3WE (0x00010000)
#define NS9750_SYS_RESET_BBT (0x00000040)
#define NS9750_SYS_RESET_LCDC (0x00000020)
#define NS9750_SYS_RESET_MEMC (0x00000010)
#define NS9750_SYS_RESET_PCIAR (0x00000008)
#define NS9750_SYS_RESET_PCIM (0x00000004)
#define NS9750_SYS_RESET_MACM (0x00000001)
#define NS9750_SYS_MISC_REV_MA (0xFF000000)
#define NS9750_SYS_MISC_PCIA (0x00002000)
#define NS9750_SYS_MISC_VDIS (0x00001000)
#define NS9750_SYS_MISC_BMM (0x00000800)
#define NS9750_SYS_MISC_CS1DB (0x00000400)
#define NS9750_SYS_MISC_CS1DW_MA (0x00000300)
#define NS9750_SYS_MISC_MCCM (0x00000080)
#define NS9750_SYS_MISC_PMSS (0x00000040)
#define NS9750_SYS_MISC_CS1P (0x00000020)
#define NS9750_SYS_MISC_ENDM (0x00000008)
#define NS9750_SYS_MISC_MBAR (0x00000004)
#define NS9750_SYS_MISC_IRAM0 (0x00000001)
#define NS9750_SYS_PLL_PLLBS (0x02000000)
#define NS9750_SYS_PLL_PLLFS_MA (0x01800000)
#define NS9750_SYS_PLL_PLLIS_MA (0x00600000)
#define NS9750_SYS_PLL_PLLND_MA (0x001F0000)
#define NS9750_SYS_PLL_PLLSW (0x00008000)
#define NS9750_SYS_PLL_PLLBSSW (0x00000200)
#define NS9750_SYS_PLL_FSEL_MA (0x00000180)
#define NS9750_SYS_PLL_CPCC_MA (0x00000060)
#define NS9750_SYS_PLL_NDSW_MA (0x0000001F)
#define NS9750_SYS_ACT_INT_STAT_MA (0x0000FFFF)
#define NS9750_SYS_TIMER_CTRL_TEN (0x00008000)
#define NS9750_SYS_TIMER_CTRL_INTC (0x00000200)
#define NS9750_SYS_TIMER_CTRL_TLCS_MA (0x000001C0)
#define NS9750_SYS_TIMER_CTRL_TLCS_1 (0x00000000)
#define NS9750_SYS_TIMER_CTRL_TLCS_2 (0x00000040)
#define NS9750_SYS_TIMER_CTRL_TLCS_4 (0x00000080)
#define NS9750_SYS_TIMER_CTRL_TLCS_8 (0x000000C0)
#define NS9750_SYS_TIMER_CTRL_TLCS_16 (0x00000100)
#define NS9750_SYS_TIMER_CTRL_TLCS_32 (0x00000140)
#define NS9750_SYS_TIMER_CTRL_TLCS_64 (0x00000180)
#define NS9750_SYS_TIMER_CTRL_TLCS_EXT (0x000001C0)
#define NS9750_SYS_TIMER_CTRL_TM_MA (0x00000030)
#define NS9750_SYS_TIMER_CTRL_TM_INT (0x00000000)
#define NS9750_SYS_TIMER_CTRL_TM_LOW (0x00000010)
#define NS9750_SYS_TIMER_CTRL_TM_HIGH (0x00000020)
#define NS9750_SYS_TIMER_CTRL_INTS (0x00000008)
#define NS9750_SYS_TIMER_CTRL_UDS (0x00000004)
#define NS9750_SYS_TIMER_CTRL_TSZ (0x00000002)
#define NS9750_SYS_TIMER_CTRL_REN (0x00000001)
#define NS9750_SYS_EXT_INT_CTRL_STS (0x00000008)
#define NS9750_SYS_EXT_INT_CTRL_CLR (0x00000004)
#define NS9750_SYS_EXT_INT_CTRL_PLTY (0x00000002)
#define NS9750_SYS_EXT_INT_CTRL_LVEDG (0x00000001)
#endif /* FS_NS9750_SYS_H */
+671
View File
@@ -0,0 +1,671 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* Based on linux/drivers/usbd/usbd.h
*
* Copyright (c) 2000, 2001, 2002 Lineo
* Copyright (c) 2001 Hewlett Packard
*
* By:
* Stuart Lynne <sl@lineo.com>,
* Tom Rushworth <tbr@lineo.com>,
* Bruce Balden <balden@lineo.com>
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __USBDCORE_H__
#define __USBDCORE_H__
#include <common.h>
#include "usbdescriptors.h"
#define MAX_URBS_QUEUED 5
#if 1
#define usberr(fmt,args...) serial_printf("ERROR: %s(), %d: "fmt"\n",__FUNCTION__,__LINE__,##args)
#else
#define usberr(fmt,args...) do{}while(0)
#endif
#if 0
#define usbdbg(fmt,args...) serial_printf("debug: %s(), %d: "fmt"\n",__FUNCTION__,__LINE__,##args)
#else
#define usbdbg(fmt,args...) do{}while(0)
#endif
#if 0
#define usbinfo(fmt,args...) serial_printf("info: %s(), %d: "fmt"\n",__FUNCTION__,__LINE__,##args)
#else
#define usbinfo(fmt,args...) do{}while(0)
#endif
#ifndef le16_to_cpu
#define le16_to_cpu(x) (x)
#endif
#ifndef inb
#define inb(p) (*(volatile u8*)(p))
#endif
#ifndef outb
#define outb(val,p) (*(volatile u8*)(p) = (val))
#endif
#ifndef inw
#define inw(p) (*(volatile u16*)(p))
#endif
#ifndef outw
#define outw(val,p) (*(volatile u16*)(p) = (val))
#endif
#ifndef inl
#define inl(p) (*(volatile u32*)(p))
#endif
#ifndef outl
#define outl(val,p) (*(volatile u32*)(p) = (val))
#endif
#ifndef insw
#define insw(p,to,len) mmio_insw(p,to,len)
#endif
#ifndef outsw
#define outsw(p,from,len) mmio_outsw(p,from,len)
#endif
#ifndef insb
#define insb(p,to,len) mmio_insb(p,to,len)
#endif
#ifndef mmio_insw
#define mmio_insw(r,b,l) ({ int __i ; \
u16 *__b2; \
__b2 = (u16 *) b; \
for (__i = 0; __i < l; __i++) { \
*(__b2 + __i) = inw(r); \
}; \
})
#endif
#ifndef mmio_outsw
#define mmio_outsw(r,b,l) ({ int __i; \
u16 *__b2; \
__b2 = (u16 *) b; \
for (__i = 0; __i < l; __i++) { \
outw( *(__b2 + __i), r); \
} \
})
#endif
#ifndef mmio_insb
#define mmio_insb(r,b,l) ({ int __i ; \
u8 *__b2; \
__b2 = (u8 *) b; \
for (__i = 0; __i < l; __i++) { \
*(__b2 + __i) = inb(r); \
}; \
})
#endif
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
/*
* Structure member address manipulation macros.
* These are used by client code (code using the urb_link routines), since
* the urb_link structure is embedded in the client data structures.
*
* Note: a macro offsetof equivalent to member_offset is defined in stddef.h
* but this is kept here for the sake of portability.
*
* p2surround returns a pointer to the surrounding structure given
* type of the surrounding structure, the name memb of the structure
* member pointed at by ptr. For example, if you have:
*
* struct foo {
* int x;
* float y;
* char z;
* } thingy;
*
* char *cp = &thingy.z;
*
* then
*
* &thingy == p2surround(struct foo, z, cp)
*
* Clear?
*/
#define _cv_(ptr) ((char*)(void*)(ptr))
#define member_offset(type,memb) (_cv_(&(((type*)0)->memb))-(char*)0)
#define p2surround(type,memb,ptr) ((type*)(void*)(_cv_(ptr)-member_offset(type,memb)))
struct urb;
struct usb_endpoint_instance;
struct usb_interface_instance;
struct usb_configuration_instance;
struct usb_device_instance;
struct usb_bus_instance;
/*
* Device and/or Interface Class codes
*/
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
#define USB_CLASS_AUDIO 1
#define USB_CLASS_COMM 2
#define USB_CLASS_HID 3
#define USB_CLASS_PHYSICAL 5
#define USB_CLASS_PRINTER 7
#define USB_CLASS_MASS_STORAGE 8
#define USB_CLASS_HUB 9
#define USB_CLASS_DATA 10
#define USB_CLASS_APP_SPEC 0xfe
#define USB_CLASS_VENDOR_SPEC 0xff
/*
* USB types
*/
#define USB_TYPE_STANDARD (0x00 << 5)
#define USB_TYPE_CLASS (0x01 << 5)
#define USB_TYPE_VENDOR (0x02 << 5)
#define USB_TYPE_RESERVED (0x03 << 5)
/*
* USB recipients
*/
#define USB_RECIP_DEVICE 0x00
#define USB_RECIP_INTERFACE 0x01
#define USB_RECIP_ENDPOINT 0x02
#define USB_RECIP_OTHER 0x03
/*
* USB directions
*/
#define USB_DIR_OUT 0
#define USB_DIR_IN 0x80
/*
* Descriptor types
*/
#define USB_DT_DEVICE 0x01
#define USB_DT_CONFIG 0x02
#define USB_DT_STRING 0x03
#define USB_DT_INTERFACE 0x04
#define USB_DT_ENDPOINT 0x05
#define USB_DT_HID (USB_TYPE_CLASS | 0x01)
#define USB_DT_REPORT (USB_TYPE_CLASS | 0x02)
#define USB_DT_PHYSICAL (USB_TYPE_CLASS | 0x03)
#define USB_DT_HUB (USB_TYPE_CLASS | 0x09)
/*
* Descriptor sizes per descriptor type
*/
#define USB_DT_DEVICE_SIZE 18
#define USB_DT_CONFIG_SIZE 9
#define USB_DT_INTERFACE_SIZE 9
#define USB_DT_ENDPOINT_SIZE 7
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
#define USB_DT_HUB_NONVAR_SIZE 7
#define USB_DT_HID_SIZE 9
/*
* Endpoints
*/
#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
#define USB_ENDPOINT_DIR_MASK 0x80
#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
#define USB_ENDPOINT_XFER_CONTROL 0
#define USB_ENDPOINT_XFER_ISOC 1
#define USB_ENDPOINT_XFER_BULK 2
#define USB_ENDPOINT_XFER_INT 3
/*
* USB Packet IDs (PIDs)
*/
#define USB_PID_UNDEF_0 0xf0
#define USB_PID_OUT 0xe1
#define USB_PID_ACK 0xd2
#define USB_PID_DATA0 0xc3
#define USB_PID_PING 0xb4 /* USB 2.0 */
#define USB_PID_SOF 0xa5
#define USB_PID_NYET 0x96 /* USB 2.0 */
#define USB_PID_DATA2 0x87 /* USB 2.0 */
#define USB_PID_SPLIT 0x78 /* USB 2.0 */
#define USB_PID_IN 0x69
#define USB_PID_NAK 0x5a
#define USB_PID_DATA1 0x4b
#define USB_PID_PREAMBLE 0x3c /* Token mode */
#define USB_PID_ERR 0x3c /* USB 2.0: handshake mode */
#define USB_PID_SETUP 0x2d
#define USB_PID_STALL 0x1e
#define USB_PID_MDATA 0x0f /* USB 2.0 */
/*
* Standard requests
*/
#define USB_REQ_GET_STATUS 0x00
#define USB_REQ_CLEAR_FEATURE 0x01
#define USB_REQ_SET_FEATURE 0x03
#define USB_REQ_SET_ADDRESS 0x05
#define USB_REQ_GET_DESCRIPTOR 0x06
#define USB_REQ_SET_DESCRIPTOR 0x07
#define USB_REQ_GET_CONFIGURATION 0x08
#define USB_REQ_SET_CONFIGURATION 0x09
#define USB_REQ_GET_INTERFACE 0x0A
#define USB_REQ_SET_INTERFACE 0x0B
#define USB_REQ_SYNCH_FRAME 0x0C
#define USBD_DEVICE_REQUESTS(x) (((unsigned int)x <= USB_REQ_SYNCH_FRAME) ? usbd_device_requests[x] : "UNKNOWN")
/*
* HID requests
*/
#define USB_REQ_GET_REPORT 0x01
#define USB_REQ_GET_IDLE 0x02
#define USB_REQ_GET_PROTOCOL 0x03
#define USB_REQ_SET_REPORT 0x09
#define USB_REQ_SET_IDLE 0x0A
#define USB_REQ_SET_PROTOCOL 0x0B
/*
* USB Spec Release number
*/
#define USB_BCD_VERSION 0x0110
/*
* Device Requests (c.f Table 9-2)
*/
#define USB_REQ_DIRECTION_MASK 0x80
#define USB_REQ_TYPE_MASK 0x60
#define USB_REQ_RECIPIENT_MASK 0x1f
#define USB_REQ_DEVICE2HOST 0x80
#define USB_REQ_HOST2DEVICE 0x00
#define USB_REQ_TYPE_STANDARD 0x00
#define USB_REQ_TYPE_CLASS 0x20
#define USB_REQ_TYPE_VENDOR 0x40
#define USB_REQ_RECIPIENT_DEVICE 0x00
#define USB_REQ_RECIPIENT_INTERFACE 0x01
#define USB_REQ_RECIPIENT_ENDPOINT 0x02
#define USB_REQ_RECIPIENT_OTHER 0x03
/*
* get status bits
*/
#define USB_STATUS_SELFPOWERED 0x01
#define USB_STATUS_REMOTEWAKEUP 0x02
#define USB_STATUS_HALT 0x01
/*
* descriptor types
*/
#define USB_DESCRIPTOR_TYPE_DEVICE 0x01
#define USB_DESCRIPTOR_TYPE_CONFIGURATION 0x02
#define USB_DESCRIPTOR_TYPE_STRING 0x03
#define USB_DESCRIPTOR_TYPE_INTERFACE 0x04
#define USB_DESCRIPTOR_TYPE_ENDPOINT 0x05
#define USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER 0x06
#define USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION 0x07
#define USB_DESCRIPTOR_TYPE_INTERFACE_POWER 0x08
#define USB_DESCRIPTOR_TYPE_HID 0x21
#define USB_DESCRIPTOR_TYPE_REPORT 0x22
#define USBD_DEVICE_DESCRIPTORS(x) (((unsigned int)x <= USB_DESCRIPTOR_TYPE_INTERFACE_POWER) ? \
usbd_device_descriptors[x] : "UNKNOWN")
/*
* standard feature selectors
*/
#define USB_ENDPOINT_HALT 0x00
#define USB_DEVICE_REMOTE_WAKEUP 0x01
#define USB_TEST_MODE 0x02
/* USB Requests
*
*/
struct usb_device_request {
u8 bmRequestType;
u8 bRequest;
u16 wValue;
u16 wIndex;
u16 wLength;
} __attribute__ ((packed));
/* USB Status
*
*/
typedef enum urb_send_status {
SEND_IN_PROGRESS,
SEND_FINISHED_OK,
SEND_FINISHED_ERROR,
RECV_READY,
RECV_OK,
RECV_ERROR
} urb_send_status_t;
/*
* Device State (c.f USB Spec 2.0 Figure 9-1)
*
* What state the usb device is in.
*
* Note the state does not change if the device is suspended, we simply set a
* flag to show that it is suspended.
*
*/
typedef enum usb_device_state {
STATE_INIT, /* just initialized */
STATE_CREATED, /* just created */
STATE_ATTACHED, /* we are attached */
STATE_POWERED, /* we have seen power indication (electrical bus signal) */
STATE_DEFAULT, /* we been reset */
STATE_ADDRESSED, /* we have been addressed (in default configuration) */
STATE_CONFIGURED, /* we have seen a set configuration device command */
STATE_UNKNOWN, /* destroyed */
} usb_device_state_t;
#define USBD_DEVICE_STATE(x) (((unsigned int)x <= STATE_UNKNOWN) ? usbd_device_states[x] : "UNKNOWN")
/*
* Device status
*
* Overall state
*/
typedef enum usb_device_status {
USBD_OPENING, /* we are currently opening */
USBD_OK, /* ok to use */
USBD_SUSPENDED, /* we are currently suspended */
USBD_CLOSING, /* we are currently closing */
} usb_device_status_t;
#define USBD_DEVICE_STATUS(x) (((unsigned int)x <= USBD_CLOSING) ? usbd_device_status[x] : "UNKNOWN")
/*
* Device Events
*
* These are defined in the USB Spec (c.f USB Spec 2.0 Figure 9-1).
*
* There are additional events defined to handle some extra actions we need
* to have handled.
*
*/
typedef enum usb_device_event {
DEVICE_UNKNOWN, /* bi - unknown event */
DEVICE_INIT, /* bi - initialize */
DEVICE_CREATE, /* bi - */
DEVICE_HUB_CONFIGURED, /* bi - bus has been plugged int */
DEVICE_RESET, /* bi - hub has powered our port */
DEVICE_ADDRESS_ASSIGNED, /* ep0 - set address setup received */
DEVICE_CONFIGURED, /* ep0 - set configure setup received */
DEVICE_SET_INTERFACE, /* ep0 - set interface setup received */
DEVICE_SET_FEATURE, /* ep0 - set feature setup received */
DEVICE_CLEAR_FEATURE, /* ep0 - clear feature setup received */
DEVICE_DE_CONFIGURED, /* ep0 - set configure setup received for ?? */
DEVICE_BUS_INACTIVE, /* bi - bus in inactive (no SOF packets) */
DEVICE_BUS_ACTIVITY, /* bi - bus is active again */
DEVICE_POWER_INTERRUPTION, /* bi - hub has depowered our port */
DEVICE_HUB_RESET, /* bi - bus has been unplugged */
DEVICE_DESTROY, /* bi - device instance should be destroyed */
DEVICE_HOTPLUG, /* bi - a hotplug event has occured */
DEVICE_FUNCTION_PRIVATE, /* function - private */
} usb_device_event_t;
typedef struct urb_link {
struct urb_link *next;
struct urb_link *prev;
} urb_link;
/* USB Data structure - for passing data around.
*
* This is used for both sending and receiving data.
*
* The callback function is used to let the function driver know when
* transmitted data has been sent.
*
* The callback function is set by the alloc_recv function when an urb is
* allocated for receiving data for an endpoint and used to call the
* function driver to inform it that data has arrived.
*/
#define URB_BUF_SIZE 128 /* in linux we'd malloc this, but in u-boot we prefer static data */
struct urb {
struct usb_endpoint_instance *endpoint;
struct usb_device_instance *device;
struct usb_device_request device_request; /* contents of received SETUP packet */
struct urb_link link; /* embedded struct for circular doubly linked list of urbs */
u8* buffer;
unsigned int buffer_length;
unsigned int actual_length;
urb_send_status_t status;
int data;
u16 buffer_data[URB_BUF_SIZE]; /* data received (OUT) or being sent (IN) */
};
/* Endpoint configuration
*
* Per endpoint configuration data. Used to track which function driver owns
* an endpoint.
*
*/
struct usb_endpoint_instance {
int endpoint_address; /* logical endpoint address */
/* control */
int status; /* halted */
int state; /* available for use by bus interface driver */
/* receive side */
struct urb_link rcv; /* received urbs */
struct urb_link rdy; /* empty urbs ready to receive */
struct urb *rcv_urb; /* active urb */
int rcv_attributes; /* copy of bmAttributes from endpoint descriptor */
int rcv_packetSize; /* maximum packet size from endpoint descriptor */
int rcv_transferSize; /* maximum transfer size from function driver */
int rcv_queue;
/* transmit side */
struct urb_link tx; /* urbs ready to transmit */
struct urb_link done; /* transmitted urbs */
struct urb *tx_urb; /* active urb */
int tx_attributes; /* copy of bmAttributes from endpoint descriptor */
int tx_packetSize; /* maximum packet size from endpoint descriptor */
int tx_transferSize; /* maximum transfer size from function driver */
int tx_queue;
int sent; /* data already sent */
int last; /* data sent in last packet XXX do we need this */
};
struct usb_alternate_instance {
struct usb_interface_descriptor *interface_descriptor;
int endpoints;
int *endpoint_transfersize_array;
struct usb_endpoint_descriptor **endpoints_descriptor_array;
};
struct usb_interface_instance {
int alternates;
struct usb_alternate_instance *alternates_instance_array;
};
struct usb_configuration_instance {
int interfaces;
struct usb_configuration_descriptor *configuration_descriptor;
struct usb_interface_instance *interface_instance_array;
};
/* USB Device Instance
*
* For each physical bus interface we create a logical device structure. This
* tracks all of the required state to track the USB HOST's view of the device.
*
* Keep track of the device configuration for a real physical bus interface,
* this includes the bus interface, multiple function drivers, the current
* configuration and the current state.
*
* This will show:
* the specific bus interface driver
* the default endpoint 0 driver
* the configured function driver
* device state
* device status
* endpoint list
*/
struct usb_device_instance {
/* generic */
char *name;
struct usb_device_descriptor *device_descriptor; /* per device descriptor */
void (*event) (struct usb_device_instance *device, usb_device_event_t event, int data);
/* bus interface */
struct usb_bus_instance *bus; /* which bus interface driver */
/* configuration descriptors */
int configurations;
struct usb_configuration_instance *configuration_instance_array;
/* device state */
usb_device_state_t device_state; /* current USB Device state */
usb_device_state_t device_previous_state; /* current USB Device state */
u8 address; /* current address (zero is default) */
u8 configuration; /* current show configuration (zero is default) */
u8 interface; /* current interface (zero is default) */
u8 alternate; /* alternate flag */
usb_device_status_t status; /* device status */
int urbs_queued; /* number of submitted urbs */
/* Shouldn't need to make this atomic, all we need is a change indicator */
unsigned long usbd_rxtx_timestamp;
unsigned long usbd_last_rxtx_timestamp;
};
/* Bus Interface configuration structure
*
* This is allocated for each configured instance of a bus interface driver.
*
* The privdata pointer may be used by the bus interface driver to store private
* per instance state information.
*/
struct usb_bus_instance {
struct usb_device_instance *device;
struct usb_endpoint_instance *endpoint_array; /* array of available configured endpoints */
int max_endpoints; /* maximimum number of rx enpoints */
unsigned char maxpacketsize;
unsigned int serial_number;
char *serial_number_str;
void *privdata; /* private data for the bus interface */
};
extern char *usbd_device_events[];
extern char *usbd_device_states[];
extern char *usbd_device_status[];
extern char *usbd_device_requests[];
extern char *usbd_device_descriptors[];
void urb_link_init (urb_link * ul);
void urb_detach (struct urb *urb);
urb_link *first_urb_link (urb_link * hd);
struct urb *first_urb (urb_link * hd);
struct urb *first_urb_detached (urb_link * hd);
void urb_append (urb_link * hd, struct urb *urb);
struct urb *usbd_alloc_urb (struct usb_device_instance *device, struct usb_endpoint_instance *endpoint);
void usbd_dealloc_urb (struct urb *urb);
/*
* usbd_device_event is used by bus interface drivers to tell the higher layers that
* certain events have taken place.
*/
void usbd_device_event_irq (struct usb_device_instance *conf, usb_device_event_t, int);
void usbd_device_event (struct usb_device_instance *conf, usb_device_event_t, int);
/* descriptors
*
* Various ways of finding descriptors based on the current device and any
* possible configuration / interface / endpoint for it.
*/
struct usb_configuration_descriptor *usbd_device_configuration_descriptor (struct usb_device_instance *, int, int);
struct usb_function_instance *usbd_device_function_instance (struct usb_device_instance *, unsigned int);
struct usb_interface_instance *usbd_device_interface_instance (struct usb_device_instance *, int, int, int);
struct usb_alternate_instance *usbd_device_alternate_instance (struct usb_device_instance *, int, int, int, int);
struct usb_interface_descriptor *usbd_device_interface_descriptor (struct usb_device_instance *, int, int, int, int);
struct usb_endpoint_descriptor *usbd_device_endpoint_descriptor_index (struct usb_device_instance *, int, int, int, int, int);
struct usb_class_descriptor *usbd_device_class_descriptor_index (struct usb_device_instance *, int, int, int, int, int);
struct usb_class_report_descriptor *usbd_device_class_report_descriptor_index( struct usb_device_instance *, int , int , int , int , int );
struct usb_endpoint_descriptor *usbd_device_endpoint_descriptor (struct usb_device_instance *, int, int, int, int, int);
int usbd_device_endpoint_transfersize (struct usb_device_instance *, int, int, int, int, int);
struct usb_string_descriptor *usbd_get_string (u8);
struct usb_device_descriptor *usbd_device_device_descriptor (struct usb_device_instance *, int);
int usbd_endpoint_halted (struct usb_device_instance *device, int endpoint);
void usbd_rcv_complete(struct usb_endpoint_instance *endpoint, int len, int urb_bad);
void usbd_tx_complete (struct usb_endpoint_instance *endpoint);
#endif
+39
View File
@@ -0,0 +1,39 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* Based on
* linux/drivers/usbd/ep0.c
*
* Copyright (c) 2000, 2001, 2002 Lineo
* Copyright (c) 2001 Hewlett Packard
*
* By:
* Stuart Lynne <sl@lineo.com>,
* Tom Rushworth <tbr@lineo.com>,
* Bruce Balden <balden@lineo.com>
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __USBDCORE_EP0_H__
#define __USBDCORE_EP0_H__
int ep0_recv_setup (struct urb *urb);
#endif
+183
View File
@@ -0,0 +1,183 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* Based on
* linux/drivers/usb/device/bi/omap.h
* Register definitions for TI OMAP1510 USB bus interface driver
*
* Author: MontaVista Software, Inc.
* source@mvista.com
*
* 2003 (c) MontaVista Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
#ifndef __USBDCORE_OMAP1510_H__
#define __USBDCORE_OMAP1510_H__
/*
* 13.2 MPU Register Map
*/
/* Table 13-1. USB Function Module Registers (endpoint) */
#define UDC_BASE 0xFFFB4000
#define UDC_OFFSET(offset) (UDC_BASE + (offset))
#define UDC_REV UDC_OFFSET(0x0) /* Revision */
#define UDC_EP_NUM UDC_OFFSET(0x4) /* Endpoint selection */
#define UDC_DATA UDC_OFFSET(0x08) /* Data */
#define UDC_CTRL UDC_OFFSET(0x0C) /* Control */
#define UDC_STAT_FLG UDC_OFFSET(0x10) /* Status flag */
#define UDC_RXFSTAT UDC_OFFSET(0x14) /* Receive FIFO status */
#define UDC_SYSCON1 UDC_OFFSET(0x18) /* System configuration 1 */
#define UDC_SYSCON2 UDC_OFFSET(0x1C) /* System configuration 2 */
#define UDC_DEVSTAT UDC_OFFSET(0x20) /* Device status */
#define UDC_SOF UDC_OFFSET(0x24) /* Start of frame */
#define UDC_IRQ_EN UDC_OFFSET(0x28) /* Interrupt enable */
#define UDC_DMA_IRQ_EN UDC_OFFSET(0x2C) /* DMA interrupt enable */
#define UDC_IRQ_SRC UDC_OFFSET(0x30) /* Interrupt source */
#define UDC_EPN_STAT UDC_OFFSET(0x34) /* Endpoint interrupt status */
#define UDC_DMAN_STAT UDC_OFFSET(0x3C) /* DMA endpoint interrupt status */
/* IRQ_EN register fields */
#define UDC_Sof_IE (1 << 7) /* Start-of-frame interrupt enabled */
#define UDC_EPn_RX_IE (1 << 5) /* Receive endpoint interrupt enabled */
#define UDC_EPn_TX_IE (1 << 4) /* Transmit endpoint interrupt enabled */
#define UDC_DS_Chg_IE (1 << 3) /* Device state changed interrupt enabled */
#define UDC_EP0_IE (1 << 0) /* EP0 transaction interrupt enabled */
/* IRQ_SRC register fields */
#define UDC_TXn_Done (1 << 10) /* Transmit DMA channel n done */
#define UDC_RXn_Cnt (1 << 9) /* Receive DMA channel n transactions count */
#define UDC_RXn_EOT (1 << 8) /* Receive DMA channel n end of transfer */
#define UDC_SOF_Flg (1 << 7) /* Start-of-frame interrupt flag */
#define UDC_EPn_RX (1 << 5) /* Endpoint n OUT transaction */
#define UDC_EPn_TX (1 << 4) /* Endpoint n IN transaction */
#define UDC_DS_Chg (1 << 3) /* Device state changed */
#define UDC_Setup (1 << 2) /* Setup transaction */
#define UDC_EP0_RX (1 << 1) /* EP0 OUT transaction */
#define UDC_EP0_TX (1 << 0) /* EP0 IN transaction */
/* DEVSTAT register fields, 14.2.9 */
#define UDC_R_WK_OK (1 << 6) /* Remote wakeup granted */
#define UDC_USB_Reset (1 << 5) /* USB reset signalling is active */
#define UDC_SUS (1 << 4) /* Suspended state */
#define UDC_CFG (1 << 3) /* Configured state */
#define UDC_ADD (1 << 2) /* Addressed state */
#define UDC_DEF (1 << 1) /* Default state */
#define UDC_ATT (1 << 0) /* Attached state */
/* SYSCON1 register fields */
#define UDC_Cfg_Lock (1 << 8) /* Device configuration locked */
#define UDC_Nak_En (1 << 4) /* NAK enable */
#define UDC_Self_Pwr (1 << 2) /* Device is self-powered */
#define UDC_Soff_Dis (1 << 1) /* Shutoff disabled */
#define UDC_Pullup_En (1 << 0) /* External pullup enabled */
/* SYSCON2 register fields */
#define UDC_Rmt_Wkp (1 << 6) /* Remote wakeup */
#define UDC_Stall_Cmd (1 << 5) /* Stall endpoint */
#define UDC_Dev_Cfg (1 << 3) /* Device configured */
#define UDC_Clr_Cfg (1 << 2) /* Clear configured */
/*
* Select and enable endpoints
*/
/* Table 13-1. USB Function Module Registers (endpoint configuration) */
#define UDC_EPBASE UDC_OFFSET(0x80) /* Endpoints base address */
#define UDC_EP0 UDC_EPBASE /* Control endpoint configuration */
#define UDC_EP_RX_BASE UDC_OFFSET(0x84) /* Receive endpoints base address */
#define UDC_EP_RX(endpoint) (UDC_EP_RX_BASE + ((endpoint) - 1) * 4)
#define UDC_EP_TX_BASE UDC_OFFSET(0xC4) /* Transmit endpoints base address */
#define UDC_EP_TX(endpoint) (UDC_EP_TX_BASE + ((endpoint) - 1) * 4)
/* EP_NUM register fields */
#define UDC_Setup_Sel (1 << 6) /* Setup FIFO select */
#define UDC_EP_Sel (1 << 5) /* TX/RX FIFO select */
#define UDC_EP_Dir (1 << 4) /* Endpoint direction */
/* CTRL register fields */
#define UDC_Clr_Halt (1 << 7) /* Clear halt endpoint */
#define UDC_Set_Halt (1 << 6) /* Set halt endpoint */
#define UDC_Set_FIFO_En (1 << 2) /* Set FIFO enable */
#define UDC_Clr_EP (1 << 1) /* Clear endpoint */
#define UDC_Reset_EP (1 << 0) /* Reset endpoint */
/* STAT_FLG register fields */
#define UDC_Miss_In (1 << 14)
#define UDC_Data_Flush (1 << 13)
#define UDC_ISO_Err (1 << 12)
#define UDC_ISO_FIFO_Empty (1 << 9)
#define UDC_ISO_FIFO_Full (1 << 8)
#define UDC_EP_Halted (1 << 6)
#define UDC_STALL (1 << 5)
#define UDC_NAK (1 << 4)
#define UDC_ACK (1 << 3)
#define UDC_FIFO_En (1 << 2)
#define UDC_Non_ISO_FIFO_Empty (1 << 1)
#define UDC_Non_ISO_FIFO_Full (1 << 0)
/* EPn_RX register fields */
#define UDC_EPn_RX_Valid (1 << 15) /* valid */
#define UDC_EPn_RX_Db (1 << 14) /* double-buffer */
#define UDC_EPn_RX_Iso (1 << 11) /* isochronous */
/* EPn_TX register fields */
#define UDC_EPn_TX_Valid (1 << 15) /* valid */
#define UDC_EPn_TX_Db (1 << 14) /* double-buffer */
#define UDC_EPn_TX_Iso (1 << 11) /* isochronous */
#define EP0_PACKETSIZE 0x40
/* physical to logical endpoint mapping
* Physical endpoints are an index into device->bus->endpoint_array.
* Logical endpoints are endpoints 0 to 15 IN and OUT as defined in
* the USB specification.
*
* physical ep logical ep direction endpoint_address
* 0 0 IN and OUT 0x00
* 1 to 15 1 to 15 OUT 0x01 to 0x0f
* 16 to 30 1 to 15 IN 0x81 to 0x8f
*/
#define PHYS_EP_TO_EP_ADDR(ep) (((ep) < 16) ? (ep) : (((ep) - 15) | 0x80))
#define EP_ADDR_TO_PHYS_EP(a) (((a) & 0x80) ? (((a) & ~0x80) + 15) : (a))
/* MOD_CONF_CTRL_0 bits (FIXME: move to board hardware.h ?) */
#define CONF_MOD_USB_W2FC_VBUS_MODE_R (1 << 17)
/* Other registers (may be) related to USB */
#define CLOCK_CTRL (0xFFFE0830)
#define APLL_CTRL (0xFFFE084C)
#define DPLL_CTRL (0xFFFE083C)
#define SOFT_REQ (0xFFFE0834)
#define STATUS_REQ (0xFFFE0840)
/* FUNC_MUX_CTRL_0 bits related to USB */
#define UDC_VBUS_CTRL (1 << 19)
#define UDC_VBUS_MODE (1 << 18)
void omap1510_udc_irq(void);
void omap1510_udc_noniso_irq(void);
/* Higher level functions for abstracting away from specific device */
void udc_endpoint_write(struct usb_endpoint_instance *endpoint);
int udc_init (void);
void udc_enable(struct usb_device_instance *device);
void udc_disable(void);
void udc_connect(void);
void udc_disconnect(void);
void udc_startup_events(struct usb_device_instance *device);
void udc_setup_ep(struct usb_device_instance *device, unsigned int ep, struct usb_endpoint_instance *endpoint);
#endif
+497
View File
@@ -0,0 +1,497 @@
/*
* (C) Copyright 2003
* Gerry Hamel, geh@ti.com, Texas Instruments
*
* Based on
* linux/drivers/usbd/usb-function.h - USB Function
*
* Copyright (c) 2000, 2001, 2002 Lineo
* Copyright (c) 2001 Hewlett Packard
*
* By:
* Stuart Lynne <sl@lineo.com>,
* Tom Rushworth <tbr@lineo.com>,
* Bruce Balden <balden@lineo.com>
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
/* USB Descriptors - Create a complete description of all of the
* function driver capabilities. These map directly to the USB descriptors.
*
* This heirarchy is created by the functions drivers and is passed to the
* usb-device driver when the function driver is registered.
*
* device
* configuration
* interface
* alternate
* class
* class
* alternate
* endpoint
* endpoint
* interface
* alternate
* endpoint
* endpoint
* configuration
* interface
* alternate
* endpoint
* endpoint
*
*
* The configuration structures refer to the USB Configurations that will be
* made available to a USB HOST during the enumeration process.
*
* The USB HOST will select a configuration and optionally an interface with
* the usb set configuration and set interface commands.
*
* The selected interface (or the default interface if not specifically
* selected) will define the list of endpoints that will be used.
*
* The configuration and interfaces are stored in an array that is indexed
* by the specified configuratin or interface number minus one.
*
* A configuration number of zero is used to specify a return to the unconfigured
* state.
*
*/
#ifndef __USBDESCRIPTORS_H__
#define __USBDESCRIPTORS_H__
#include <asm/types.h>
/*
* communications class types
*
* c.f. CDC USB Class Definitions for Communications Devices
* c.f. WMCD USB CDC Subclass Specification for Wireless Mobile Communications Devices
*
*/
#define CLASS_BCD_VERSION 0x0110
/* c.f. CDC 4.1 Table 14 */
#define COMMUNICATIONS_DEVICE_CLASS 0x02
/* c.f. CDC 4.2 Table 15 */
#define COMMUNICATIONS_INTERFACE_CLASS 0x02
/* c.f. CDC 4.3 Table 16 */
#define COMMUNICATIONS_NO_SUBCLASS 0x00
#define COMMUNICATIONS_DLCM_SUBCLASS 0x01
#define COMMUNICATIONS_ACM_SUBCLASS 0x02
#define COMMUNICATIONS_TCM_SUBCLASS 0x03
#define COMMUNICATIONS_MCCM_SUBCLASS 0x04
#define COMMUNICATIONS_CCM_SUBCLASS 0x05
#define COMMUNICATIONS_ENCM_SUBCLASS 0x06
#define COMMUNICATIONS_ANCM_SUBCLASS 0x07
/* c.f. WMCD 5.1 */
#define COMMUNICATIONS_WHCM_SUBCLASS 0x08
#define COMMUNICATIONS_DMM_SUBCLASS 0x09
#define COMMUNICATIONS_MDLM_SUBCLASS 0x0a
#define COMMUNICATIONS_OBEX_SUBCLASS 0x0b
/* c.f. CDC 4.6 Table 18 */
#define DATA_INTERFACE_CLASS 0x0a
/* c.f. CDC 4.7 Table 19 */
#define COMMUNICATIONS_NO_PROTOCOL 0x00
/* c.f. CDC 5.2.3 Table 24 */
#define CS_INTERFACE 0x24
#define CS_ENDPOINT 0x25
/*
* bDescriptorSubtypes
*
* c.f. CDC 5.2.3 Table 25
* c.f. WMCD 5.3 Table 5.3
*/
#define USB_ST_HEADER 0x00
#define USB_ST_CMF 0x01
#define USB_ST_ACMF 0x02
#define USB_ST_DLMF 0x03
#define USB_ST_TRF 0x04
#define USB_ST_TCLF 0x05
#define USB_ST_UF 0x06
#define USB_ST_CSF 0x07
#define USB_ST_TOMF 0x08
#define USB_ST_USBTF 0x09
#define USB_ST_NCT 0x0a
#define USB_ST_PUF 0x0b
#define USB_ST_EUF 0x0c
#define USB_ST_MCMF 0x0d
#define USB_ST_CCMF 0x0e
#define USB_ST_ENF 0x0f
#define USB_ST_ATMNF 0x10
#define USB_ST_WHCM 0x11
#define USB_ST_MDLM 0x12
#define USB_ST_MDLMD 0x13
#define USB_ST_DMM 0x14
#define USB_ST_OBEX 0x15
#define USB_ST_CS 0x16
#define USB_ST_CSD 0x17
#define USB_ST_TCM 0x18
/* endpoint modifiers
* static struct usb_endpoint_description function_default_A_1[] = {
*
* {this_endpoint: 0, attributes: CONTROL, max_size: 8, polling_interval: 0 },
* {this_endpoint: 1, attributes: BULK, max_size: 64, polling_interval: 0, direction: IN},
* {this_endpoint: 2, attributes: BULK, max_size: 64, polling_interval: 0, direction: OUT},
* {this_endpoint: 3, attributes: INTERRUPT, max_size: 8, polling_interval: 0},
*
*
*/
#define OUT 0x00
#define IN 0x80
#define CONTROL 0x00
#define ISOCHRONOUS 0x01
#define BULK 0x02
#define INTERRUPT 0x03
/* configuration modifiers
*/
#define BMATTRIBUTE_RESERVED 0x80
#define BMATTRIBUTE_SELF_POWERED 0x40
/*
* standard usb descriptor structures
*/
struct usb_endpoint_descriptor {
u8 bLength;
u8 bDescriptorType; /* 0x5 */
u8 bEndpointAddress;
u8 bmAttributes;
u16 wMaxPacketSize;
u8 bInterval;
} __attribute__ ((packed));
struct usb_interface_descriptor {
u8 bLength;
u8 bDescriptorType; /* 0x04 */
u8 bInterfaceNumber;
u8 bAlternateSetting;
u8 bNumEndpoints;
u8 bInterfaceClass;
u8 bInterfaceSubClass;
u8 bInterfaceProtocol;
u8 iInterface;
} __attribute__ ((packed));
struct usb_configuration_descriptor {
u8 bLength;
u8 bDescriptorType; /* 0x2 */
u16 wTotalLength;
u8 bNumInterfaces;
u8 bConfigurationValue;
u8 iConfiguration;
u8 bmAttributes;
u8 bMaxPower;
} __attribute__ ((packed));
struct usb_device_descriptor {
u8 bLength;
u8 bDescriptorType; /* 0x01 */
u16 bcdUSB;
u8 bDeviceClass;
u8 bDeviceSubClass;
u8 bDeviceProtocol;
u8 bMaxPacketSize0;
u16 idVendor;
u16 idProduct;
u16 bcdDevice;
u8 iManufacturer;
u8 iProduct;
u8 iSerialNumber;
u8 bNumConfigurations;
} __attribute__ ((packed));
struct usb_string_descriptor {
u8 bLength;
u8 bDescriptorType; /* 0x03 */
u16 wData[0];
} __attribute__ ((packed));
struct usb_generic_descriptor {
u8 bLength;
u8 bDescriptorType;
u8 bDescriptorSubtype;
} __attribute__ ((packed));
/*
* communications class descriptor structures
*
* c.f. CDC 5.2 Table 25c
*/
struct usb_class_function_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype;
} __attribute__ ((packed));
struct usb_class_function_descriptor_generic {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype;
u8 bmCapabilities;
} __attribute__ ((packed));
struct usb_class_header_function_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x00 */
u16 bcdCDC;
} __attribute__ ((packed));
struct usb_class_call_management_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x01 */
u8 bmCapabilities;
u8 bDataInterface;
} __attribute__ ((packed));
struct usb_class_abstract_control_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x02 */
u8 bmCapabilities;
} __attribute__ ((packed));
struct usb_class_direct_line_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x03 */
} __attribute__ ((packed));
struct usb_class_telephone_ringer_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x04 */
u8 bRingerVolSeps;
u8 bNumRingerPatterns;
} __attribute__ ((packed));
struct usb_class_telephone_call_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x05 */
u8 bmCapabilities;
} __attribute__ ((packed));
struct usb_class_union_function_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x06 */
u8 bMasterInterface;
u8 bSlaveInterface0[0];
} __attribute__ ((packed));
struct usb_class_country_selection_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x07 */
u8 iCountryCodeRelDate;
u16 wCountryCode0[0];
} __attribute__ ((packed));
struct usb_class_telephone_operational_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x08 */
u8 bmCapabilities;
} __attribute__ ((packed));
struct usb_class_usb_terminal_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x09 */
u8 bEntityId;
u8 bInterfaceNo;
u8 bOutInterfaceNo;
u8 bmOptions;
u8 bChild0[0];
} __attribute__ ((packed));
struct usb_class_network_channel_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x0a */
u8 bEntityId;
u8 iName;
u8 bChannelIndex;
u8 bPhysicalInterface;
} __attribute__ ((packed));
struct usb_class_protocol_unit_function_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x0b */
u8 bEntityId;
u8 bProtocol;
u8 bChild0[0];
} __attribute__ ((packed));
struct usb_class_extension_unit_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x0c */
u8 bEntityId;
u8 bExtensionCode;
u8 iName;
u8 bChild0[0];
} __attribute__ ((packed));
struct usb_class_multi_channel_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x0d */
u8 bmCapabilities;
} __attribute__ ((packed));
struct usb_class_capi_control_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x0e */
u8 bmCapabilities;
} __attribute__ ((packed));
struct usb_class_ethernet_networking_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x0f */
u8 iMACAddress;
u32 bmEthernetStatistics;
u16 wMaxSegmentSize;
u16 wNumberMCFilters;
u8 bNumberPowerFilters;
} __attribute__ ((packed));
struct usb_class_atm_networking_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x10 */
u8 iEndSystermIdentifier;
u8 bmDataCapabilities;
u8 bmATMDeviceStatistics;
u16 wType2MaxSegmentSize;
u16 wType3MaxSegmentSize;
u16 wMaxVC;
} __attribute__ ((packed));
struct usb_class_mdlm_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x12 */
u16 bcdVersion;
u8 bGUID[16];
} __attribute__ ((packed));
struct usb_class_mdlmd_descriptor {
u8 bFunctionLength;
u8 bDescriptorType;
u8 bDescriptorSubtype; /* 0x13 */
u8 bGuidDescriptorType;
u8 bDetailData[0];
} __attribute__ ((packed));
/*
* HID class descriptor structures
*
* c.f. HID 6.2.1
*/
struct usb_class_hid_descriptor {
u8 bLength;
u8 bDescriptorType;
u16 bcdCDC;
u8 bCountryCode;
u8 bNumDescriptors; /* 0x01 */
u8 bDescriptorType0;
u16 wDescriptorLength0;
/* optional descriptors are not supported. */
} __attribute__((packed));
struct usb_class_report_descriptor {
u8 bLength; /* dummy */
u8 bDescriptorType;
u16 wLength;
u8 bData[0];
} __attribute__((packed));
/*
* descriptor union structures
*/
struct usb_descriptor {
union {
struct usb_generic_descriptor generic;
struct usb_endpoint_descriptor endpoint;
struct usb_interface_descriptor interface;
struct usb_configuration_descriptor configuration;
struct usb_device_descriptor device;
struct usb_string_descriptor string;
} descriptor;
} __attribute__ ((packed));
struct usb_class_descriptor {
union {
struct usb_class_function_descriptor function;
struct usb_class_function_descriptor_generic generic;
struct usb_class_header_function_descriptor header_function;
struct usb_class_call_management_descriptor call_management;
struct usb_class_abstract_control_descriptor abstract_control;
struct usb_class_direct_line_descriptor direct_line;
struct usb_class_telephone_ringer_descriptor telephone_ringer;
struct usb_class_telephone_operational_descriptor telephone_operational;
struct usb_class_telephone_call_descriptor telephone_call;
struct usb_class_union_function_descriptor union_function;
struct usb_class_country_selection_descriptor country_selection;
struct usb_class_usb_terminal_descriptor usb_terminal;
struct usb_class_network_channel_descriptor network_channel;
struct usb_class_extension_unit_descriptor extension_unit;
struct usb_class_multi_channel_descriptor multi_channel;
struct usb_class_capi_control_descriptor capi_control;
struct usb_class_ethernet_networking_descriptor ethernet_networking;
struct usb_class_atm_networking_descriptor atm_networking;
struct usb_class_mdlm_descriptor mobile_direct;
struct usb_class_mdlmd_descriptor mobile_direct_detail;
struct usb_class_hid_descriptor hid;
} descriptor;
} __attribute__ ((packed));
#endif
+9 -2
View File
@@ -12,12 +12,12 @@
*
* 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
* 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
@@ -256,6 +256,13 @@ void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
/* we assume that the kernel is in place */
printf ("\nStarting kernel ...\n\n");
#ifdef CONFIG_USB_DEVICE
{
extern void udc_disconnect (void);
udc_disconnect ();
}
#endif
cleanup_before_linux ();
theKernel (0, bd->bi_arch_number, bd->bi_boot_params);
+1 -1
View File
@@ -343,7 +343,7 @@ void start_i386boot (void)
/* Must happen after interrupts are initialized since
* an irq handler gets installed
*/
#ifdef CONFIG_SERIAL_SOFTWARE_FIFO
#if CONFIG_SERIAL_SOFTWARE_FIFO
serial_buffered_init();
#endif
+1 -1
View File
@@ -577,7 +577,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
*/
timer_init();
#ifdef CONFIG_SERIAL_SOFTWARE_FIFO
#if CONFIG_SERIAL_SOFTWARE_FIFO
serial_buffered_init();
#endif
+1 -1
View File
@@ -874,7 +874,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
/* Must happen after interrupts are initialized since
* an irq handler gets installed
*/
#ifdef CONFIG_SERIAL_SOFTWARE_FIFO
#if CONFIG_SERIAL_SOFTWARE_FIFO
serial_buffered_init();
#endif
+284 -268
View File
@@ -5,12 +5,12 @@
* (See License)
* Copyright 2000 Roland Borde
* Copyright 2000 Paolo Scaffardi
* Copyright 2000-2002 Wolfgang Denk, wd@denx.de
* Copyright 2000-2004 Wolfgang Denk, wd@denx.de
*/
#if 0
#define DEBUG 1 /* general debug */
#define DEBUG_BOOTP_EXT 1 /* Debug received vendor fields */
#define DEBUG 1 /* general debug */
#define DEBUG_BOOTP_EXT 1 /* Debug received vendor fields */
#endif
#ifdef DEBUG_BOOTP_EXT
@@ -24,26 +24,27 @@
#include <net.h>
#include "bootp.h"
#include "tftp.h"
#include "nfs.h"
#ifdef CONFIG_STATUS_LED
#include <status_led.h>
#endif
#define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
#define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
#if (CONFIG_COMMANDS & CFG_CMD_NET)
#define TIMEOUT 5 /* Seconds before trying BOOTP again */
#ifndef CONFIG_NET_RETRY_COUNT
#ifndef CONFIG_NET_RETRY_COUNT
# define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
#else
# define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
# define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
#endif
#define PORT_BOOTPS 67 /* BOOTP server UDP port */
#define PORT_BOOTPC 68 /* BOOTP client UDP port */
#ifndef CONFIG_DHCP_MIN_EXT_LEN /* minimal length of extension list */
#define CONFIG_DHCP_MIN_EXT_LEN 64
#define CONFIG_DHCP_MIN_EXT_LEN 64
#endif
ulong BootpID;
@@ -63,13 +64,13 @@ static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len);
static char *dhcpmsg2str(int type)
{
switch (type) {
case 1: return "DHCPDISCOVER"; break;
case 2: return "DHCPOFFER"; break;
case 3: return "DHCPREQUEST"; break;
case 4: return "DHCPDECLINE"; break;
case 5: return "DHCPACK"; break;
case 6: return "DHCPNACK"; break;
case 7: return "DHCPRELEASE"; break;
case 1: return "DHCPDISCOVER"; break;
case 2: return "DHCPOFFER"; break;
case 3: return "DHCPREQUEST"; break;
case 4: return "DHCPDECLINE"; break;
case 5: return "DHCPACK"; break;
case 6: return "DHCPNACK"; break;
case 7: return "DHCPRELEASE"; break;
default: return "UNKNOWN/INVALID MSG TYPE"; break;
}
}
@@ -144,159 +145,158 @@ static int truncate_sz (const char *name, int maxlen, int curlen)
#if !(CONFIG_COMMANDS & CFG_CMD_DHCP)
static void BootpVendorFieldProcess(u8 *ext)
static void BootpVendorFieldProcess (u8 * ext)
{
int size = *(ext+1) ;
int size = *(ext + 1);
debug_ext ("[BOOTP] Processing extension %d... (%d bytes)\n", *ext, *(ext+1));
debug_ext ("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
*(ext + 1));
NetBootFileSize = 0;
NetBootFileSize = 0;
switch (*ext) {
/* Fixed length fields */
case 1: /* Subnet mask */
switch (*ext) {
/* Fixed length fields */
case 1: /* Subnet mask */
if (NetOurSubnetMask == 0)
NetCopyIP(&NetOurSubnetMask, (IPaddr_t*)(ext+2));
NetCopyIP (&NetOurSubnetMask, (IPaddr_t *) (ext + 2));
break;
case 2: /* Time offset - Not yet supported */
case 2: /* Time offset - Not yet supported */
break;
/* Variable length fields */
case 3: /* Gateways list */
/* Variable length fields */
case 3: /* Gateways list */
if (NetOurGatewayIP == 0) {
NetCopyIP(&NetOurGatewayIP, (IPaddr_t*)(ext+2));
NetCopyIP (&NetOurGatewayIP, (IPaddr_t *) (ext + 2));
}
break;
case 4: /* Time server - Not yet supported */
case 4: /* Time server - Not yet supported */
break;
case 5: /* IEN-116 name server - Not yet supported */
case 5: /* IEN-116 name server - Not yet supported */
break;
case 6:
if (NetOurDNSIP == 0) {
NetCopyIP(&NetOurDNSIP, (IPaddr_t*)(ext+2));
NetCopyIP (&NetOurDNSIP, (IPaddr_t *) (ext + 2));
}
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
if ((NetOurDNS2IP == 0) && (size > 4)) {
NetCopyIP(&NetOurDNS2IP, (IPaddr_t*)(ext+2+4));
NetCopyIP (&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4));
}
#endif
break;
case 7: /* Log server - Not yet supported */
case 7: /* Log server - Not yet supported */
break;
case 8: /* Cookie/Quote server - Not yet supported */
case 8: /* Cookie/Quote server - Not yet supported */
break;
case 9: /* LPR server - Not yet supported */
case 9: /* LPR server - Not yet supported */
break;
case 10: /* Impress server - Not yet supported */
case 10: /* Impress server - Not yet supported */
break;
case 11: /* RPL server - Not yet supported */
case 11: /* RPL server - Not yet supported */
break;
case 12: /* Host name */
case 12: /* Host name */
if (NetOurHostName[0] == 0) {
size = truncate_sz("Host Name", sizeof(NetOurHostName), size);
memcpy(&NetOurHostName, ext+2, size);
NetOurHostName[size] = 0 ;
size = truncate_sz ("Host Name", sizeof (NetOurHostName), size);
memcpy (&NetOurHostName, ext + 2, size);
NetOurHostName[size] = 0;
}
break;
case 13: /* Boot file size */
case 13: /* Boot file size */
if (size == 2)
NetBootFileSize = ntohs(*(ushort*)(ext+2));
NetBootFileSize = ntohs (*(ushort *) (ext + 2));
else if (size == 4)
NetBootFileSize = ntohl(*(ulong*)(ext+2));
NetBootFileSize = ntohl (*(ulong *) (ext + 2));
break;
case 14: /* Merit dump file - Not yet supported */
case 14: /* Merit dump file - Not yet supported */
break;
case 15: /* Domain name - Not yet supported */
case 15: /* Domain name - Not yet supported */
break;
case 16: /* Swap server - Not yet supported */
case 16: /* Swap server - Not yet supported */
break;
case 17: /* Root path */
case 17: /* Root path */
if (NetOurRootPath[0] == 0) {
size = truncate_sz("Root Path", sizeof(NetOurRootPath), size);
memcpy(&NetOurRootPath, ext+2, size);
NetOurRootPath[size] = 0 ;
size = truncate_sz ("Root Path", sizeof (NetOurRootPath), size);
memcpy (&NetOurRootPath, ext + 2, size);
NetOurRootPath[size] = 0;
}
break;
case 18: /* Extension path - Not yet supported */
case 18: /* Extension path - Not yet supported */
/*
* This can be used to send the information of the
* vendor area in another file that the client can
* access via TFTP.
*/
break;
/* IP host layer fields */
case 40: /* NIS Domain name */
/* IP host layer fields */
case 40: /* NIS Domain name */
if (NetOurNISDomain[0] == 0) {
size = truncate_sz ("NIS Domain Name",
sizeof(NetOurNISDomain),
size);
memcpy(&NetOurNISDomain, ext+2, size);
NetOurNISDomain[size] = 0 ;
size = truncate_sz ("NIS Domain Name", sizeof (NetOurNISDomain), size);
memcpy (&NetOurNISDomain, ext + 2, size);
NetOurNISDomain[size] = 0;
}
break;
/* Application layer fields */
case 43: /* Vendor specific info - Not yet supported */
/* Application layer fields */
case 43: /* Vendor specific info - Not yet supported */
/*
* Binary information to exchange specific
* product information.
*/
break;
/* Reserved (custom) fields (128..254) */
}
/* Reserved (custom) fields (128..254) */
}
}
static void BootpVendorProcess(u8 *ext, int size)
static void BootpVendorProcess (u8 * ext, int size)
{
u8 *end = ext + size ;
u8 *end = ext + size;
debug_ext ("[BOOTP] Checking extension (%d bytes)...\n", size);
debug_ext ("[BOOTP] Checking extension (%d bytes)...\n", size);
while ((ext < end) && (*ext != 0xff)) {
if (*ext == 0) {
ext ++ ;
} else {
u8 *opt = ext ;
ext += ext[1] + 2 ;
if (ext <= end)
BootpVendorFieldProcess (opt) ;
while ((ext < end) && (*ext != 0xff)) {
if (*ext == 0) {
ext++;
} else {
u8 *opt = ext;
ext += ext[1] + 2;
if (ext <= end)
BootpVendorFieldProcess (opt);
}
}
}
#ifdef DEBUG_BOOTP_EXT
printf("[BOOTP] Received fields: \n");
if (NetOurSubnetMask) {
puts ("NetOurSubnetMask : ");
print_IPaddr (NetOurSubnetMask);
putc('\n');
}
printf ("[BOOTP] Received fields: \n");
if (NetOurSubnetMask) {
puts ("NetOurSubnetMask : ");
print_IPaddr (NetOurSubnetMask);
putc ('\n');
}
if (NetOurGatewayIP) {
puts ("NetOurGatewayIP : ");
print_IPaddr (NetOurGatewayIP);
putc('\n');
}
if (NetOurGatewayIP) {
puts ("NetOurGatewayIP : ");
print_IPaddr (NetOurGatewayIP);
putc ('\n');
}
if (NetBootFileSize) {
printf("NetBootFileSize : %d\n", NetBootFileSize);
}
if (NetBootFileSize) {
printf ("NetBootFileSize : %d\n", NetBootFileSize);
}
if (NetOurHostName[0]) {
printf("NetOurHostName : %s\n", NetOurHostName);
}
if (NetOurHostName[0]) {
printf ("NetOurHostName : %s\n", NetOurHostName);
}
if (NetOurRootPath[0]) {
printf("NetOurRootPath : %s\n", NetOurRootPath);
}
if (NetOurRootPath[0]) {
printf ("NetOurRootPath : %s\n", NetOurRootPath);
}
if (NetOurNISDomain[0]) {
printf("NetOurNISDomain : %s\n", NetOurNISDomain);
}
if (NetOurNISDomain[0]) {
printf ("NetOurNISDomain : %s\n", NetOurNISDomain);
}
if (NetBootFileSize) {
printf("NetBootFileSize: %d\n", NetBootFileSize);
}
#endif /* DEBUG_BOOTP_EXT */
if (NetBootFileSize) {
printf ("NetBootFileSize: %d\n", NetBootFileSize);
}
#endif /* DEBUG_BOOTP_EXT */
}
/*
* Handle a BOOTP received packet.
*/
@@ -311,11 +311,11 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
bp = (Bootp_t *)pkt;
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
return;
/*
* Got a good BOOTP reply. Copy the data into our variables.
* Got a good BOOTP reply. Copy the data into our variables.
*/
#ifdef CONFIG_STATUS_LED
status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
@@ -331,13 +331,21 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
debug ("Got good BOOTP\n");
if (((s = getenv("autoload")) != NULL) && (*s == 'n')) {
/*
* Just use BOOTP to configure system;
* Do not use TFTP to load the bootfile.
*/
NetState = NETLOOP_SUCCESS;
return;
if ((s = getenv("autoload")) != NULL) {
if (*s == 'n') {
/*
* Just use BOOTP to configure system;
* Do not use TFTP to load the bootfile.
*/
NetState = NETLOOP_SUCCESS;
return;
} else if (strcmp(s, "NFS") == 0) {
/*
* Use NFS to load the bootfile.
*/
NfsStart();
return;
}
}
TftpStart();
@@ -363,179 +371,180 @@ BootpTimeout(void)
* Initialize BOOTP extension fields in the request.
*/
#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP)
static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP)
{
u8 *start = e ;
u8 *cnt;
u8 *start = e;
u8 *cnt;
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
u8 *x;
u8 *x;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SEND_HOSTNAME)
uchar *hostname;
uchar *hostname;
#endif
*e++ = 99; /* RFC1048 Magic Cookie */
*e++ = 130;
*e++ = 83;
*e++ = 99;
*e++ = 99; /* RFC1048 Magic Cookie */
*e++ = 130;
*e++ = 83;
*e++ = 99;
*e++ = 53; /* DHCP Message Type */
*e++ = 1;
*e++ = message_type;
*e++ = 53; /* DHCP Message Type */
*e++ = 1;
*e++ = message_type;
*e++ = 57; /* Maximum DHCP Message Size */
*e++ = 2;
*e++ = (576-312+OPT_SIZE) >> 8;
*e++ = (576-312+OPT_SIZE) & 0xff;
*e++ = 57; /* Maximum DHCP Message Size */
*e++ = 2;
*e++ = (576 - 312 + OPT_SIZE) >> 8;
*e++ = (576 - 312 + OPT_SIZE) & 0xff;
if ( ServerID ) {
int tmp = ntohl(ServerID);
if (ServerID) {
int tmp = ntohl (ServerID);
*e++ = 54; /* ServerID */
*e++ = 4;
*e++ = tmp >> 24;
*e++ = tmp >> 16;
*e++ = tmp >> 8;
*e++ = tmp & 0xff;
}
*e++ = 54; /* ServerID */
*e++ = 4;
*e++ = tmp >> 24;
*e++ = tmp >> 16;
*e++ = tmp >> 8;
*e++ = tmp & 0xff;
}
if ( RequestedIP ) {
int tmp = ntohl(RequestedIP);
*e++ = 50; /* Requested IP */
*e++ = 4;
*e++ = tmp >> 24;
*e++ = tmp >> 16;
*e++ = tmp >> 8;
*e++ = tmp & 0xff;
}
if (RequestedIP) {
int tmp = ntohl (RequestedIP);
*e++ = 50; /* Requested IP */
*e++ = 4;
*e++ = tmp >> 24;
*e++ = tmp >> 16;
*e++ = tmp >> 8;
*e++ = tmp & 0xff;
}
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SEND_HOSTNAME)
if ( (hostname = getenv("hostname")) ) {
int hostnamelen = strlen(hostname);
*e++ = 12; /* Hostname */
*e++ = hostnamelen;
memcpy(e,hostname,hostnamelen);
e += hostnamelen;
}
if ((hostname = getenv ("hostname"))) {
int hostnamelen = strlen (hostname);
*e++ = 12; /* Hostname */
*e++ = hostnamelen;
memcpy (e, hostname, hostnamelen);
e += hostnamelen;
}
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
if ((x = dhcp_vendorex_prep (e)))
return x - start ;
if ((x = dhcp_vendorex_prep (e)))
return x - start;
#endif
*e++ = 55; /* Parameter Request List */
cnt = e++; /* Pointer to count of requested items */
*cnt = 0;
*e++ = 55; /* Parameter Request List */
cnt = e++; /* Pointer to count of requested items */
*cnt = 0;
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
*e++ = 1; /* Subnet Mask */
*cnt += 1;
*e++ = 1; /* Subnet Mask */
*cnt += 1;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
*e++ = 3; /* Router Option */
*cnt += 1;
*e++ = 3; /* Router Option */
*cnt += 1;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
*e++ = 6; /* DNS Server(s) */
*cnt += 1;
*e++ = 6; /* DNS Server(s) */
*cnt += 1;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
*e++ = 12; /* Hostname */
*cnt += 1;
*e++ = 12; /* Hostname */
*cnt += 1;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
*e++ = 13; /* Boot File Size */
*cnt += 1;
*e++ = 13; /* Boot File Size */
*cnt += 1;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
*e++ = 17; /* Boot path */
*cnt += 1;
*e++ = 17; /* Boot path */
*cnt += 1;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
*e++ = 40; /* NIS Domain name request */
*cnt += 1;
*e++ = 40; /* NIS Domain name request */
*cnt += 1;
#endif
*e++ = 255; /* End of the list */
*e++ = 255; /* End of the list */
/* Pad to minimal length */
/* Pad to minimal length */
#ifdef CONFIG_DHCP_MIN_EXT_LEN
while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
*e++ = 0;
while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
*e++ = 0;
#endif
return e - start ;
return e - start;
}
#else /* CFG_CMD_DHCP */
/*
* Warning: no field size check - change CONFIG_BOOTP_MASK at your own risk!
*/
static int BootpExtended (u8 *e)
static int BootpExtended (u8 * e)
{
u8 *start = e ;
u8 *start = e;
*e++ = 99; /* RFC1048 Magic Cookie */
*e++ = 130;
*e++ = 83;
*e++ = 99;
*e++ = 99; /* RFC1048 Magic Cookie */
*e++ = 130;
*e++ = 83;
*e++ = 99;
#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
*e++ = 53; /* DHCP Message Type */
*e++ = 1;
*e++ = DHCP_DISCOVER;
*e++ = 53; /* DHCP Message Type */
*e++ = 1;
*e++ = DHCP_DISCOVER;
*e++ = 57; /* Maximum DHCP Message Size */
*e++ = 2;
*e++ = (576-312+OPT_SIZE) >> 16;
*e++ = (576-312+OPT_SIZE) & 0xff;
#endif /* CFG_CMD_DHCP */
*e++ = 57; /* Maximum DHCP Message Size */
*e++ = 2;
*e++ = (576 - 312 + OPT_SIZE) >> 16;
*e++ = (576 - 312 + OPT_SIZE) & 0xff;
#endif /* CFG_CMD_DHCP */
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
*e++ = 1; /* Subnet mask request */
*e++ = 4;
e += 4;
*e++ = 1; /* Subnet mask request */
*e++ = 4;
e += 4;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
*e++ = 3; /* Default gateway request */
*e++ = 4;
e += 4;
*e++ = 3; /* Default gateway request */
*e++ = 4;
e += 4;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
*e++ = 6; /* Domain Name Server */
*e++ = 4;
e += 4;
*e++ = 6; /* Domain Name Server */
*e++ = 4;
e += 4;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
*e++ = 12; /* Host name request */
*e++ = 32;
e += 32;
*e++ = 12; /* Host name request */
*e++ = 32;
e += 32;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
*e++ = 13; /* Boot file size */
*e++ = 2;
e += 2;
*e++ = 13; /* Boot file size */
*e++ = 2;
e += 2;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
*e++ = 17; /* Boot path */
*e++ = 32;
e += 32;
*e++ = 17; /* Boot path */
*e++ = 32;
e += 32;
#endif
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
*e++ = 40; /* NIS Domain name request */
*e++ = 32;
e += 32;
*e++ = 40; /* NIS Domain name request */
*e++ = 32;
e += 32;
#endif
*e++ = 255; /* End of the list */
*e++ = 255; /* End of the list */
return e - start ;
return e - start;
}
#endif /* CFG_CMD_DHCP */
@@ -670,7 +679,7 @@ BootpRequest (void)
| ((ulong)NetOurEther[4] << 8)
| (ulong)NetOurEther[5];
BootpID += get_timer(0);
BootpID = htonl(BootpID);
BootpID = htonl(BootpID);
NetCopyLong(&bp->bp_id, &BootpID);
/*
@@ -692,64 +701,59 @@ BootpRequest (void)
}
#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
static void DhcpOptionsProcess(uchar *popt)
static void DhcpOptionsProcess (uchar * popt)
{
uchar *end = popt + BOOTP_HDR_SIZE;
int oplen, size;
while ( popt < end && *popt != 0xff ) {
while (popt < end && *popt != 0xff) {
oplen = *(popt + 1);
switch(*popt) {
case 1:
NetCopyIP(&NetOurSubnetMask, (popt+2));
break;
case 3:
NetCopyIP(&NetOurGatewayIP, (popt+2));
break;
case 6:
NetCopyIP(&NetOurDNSIP, (popt+2));
switch (*popt) {
case 1:
NetCopyIP (&NetOurSubnetMask, (popt + 2));
break;
case 3:
NetCopyIP (&NetOurGatewayIP, (popt + 2));
break;
case 6:
NetCopyIP (&NetOurDNSIP, (popt + 2));
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
if ( *(popt+1) > 4 ) {
NetCopyIP(&NetOurDNS2IP, (popt+2+4));
}
if (*(popt + 1) > 4) {
NetCopyIP (&NetOurDNS2IP, (popt + 2 + 4));
}
#endif
break;
case 12:
size = truncate_sz ("Host Name",
sizeof(NetOurHostName),
oplen);
memcpy(&NetOurHostName, popt+2, size);
NetOurHostName[size] = 0 ;
break;
case 15: /* Ignore Domain Name Option */
break;
case 17:
size = truncate_sz ("Root Path",
sizeof(NetOurRootPath),
oplen);
memcpy(&NetOurRootPath, popt+2, size);
NetOurRootPath[size] = 0 ;
break;
case 51:
NetCopyLong (&dhcp_leasetime, (ulong *)(popt + 2));
break;
case 53: /* Ignore Message Type Option */
break;
case 54:
NetCopyIP(&NetDHCPServerIP, (popt+2));
break;
case 58: /* Ignore Renewal Time Option */
break;
case 59: /* Ignore Rebinding Time Option */
break;
default:
break;
case 12:
size = truncate_sz ("Host Name", sizeof (NetOurHostName), oplen);
memcpy (&NetOurHostName, popt + 2, size);
NetOurHostName[size] = 0;
break;
case 15: /* Ignore Domain Name Option */
break;
case 17:
size = truncate_sz ("Root Path", sizeof (NetOurRootPath), oplen);
memcpy (&NetOurRootPath, popt + 2, size);
NetOurRootPath[size] = 0;
break;
case 51:
NetCopyLong (&dhcp_leasetime, (ulong *) (popt + 2));
break;
case 53: /* Ignore Message Type Option */
break;
case 54:
NetCopyIP (&NetDHCPServerIP, (popt + 2));
break;
case 58: /* Ignore Renewal Time Option */
break;
case 59: /* Ignore Rebinding Time Option */
break;
default:
#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
if (dhcp_vendorex_proc(popt))
if (dhcp_vendorex_proc (popt))
break;
#endif
printf("*** Unhandled DHCP Option in OFFER/ACK: %d\n",
*popt);
break;
printf ("*** Unhandled DHCP Option in OFFER/ACK: %d\n", *popt);
break;
}
popt += oplen + 2; /* Process next option */
}
@@ -829,7 +833,7 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
debug ("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
src, dest, len, dhcp_state);
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
return;
debug ("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
@@ -856,7 +860,7 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
DhcpOptionsProcess(&bp->bp_vend[4]);
BootpCopyNetParams(bp); /* Store net params from reply */
BootpCopyNetParams(bp); /* Store net params from reply */
NetSetTimeout(TIMEOUT * CFG_HZ, BootpTimeout);
DhcpSendRequestPkt(bp);
@@ -874,16 +878,28 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
DhcpOptionsProcess(&bp->bp_vend[4]);
BootpCopyNetParams(bp); /* Store net params from reply */
BootpCopyNetParams(bp); /* Store net params from reply */
dhcp_state = BOUND;
printf("DHCP client bound to address ");
print_IPaddr(NetOurIP);
printf("\n");
/* Obey the 'autoload' setting */
if (((s = getenv("autoload")) != NULL) && (*s == 'n')) {
NetState = NETLOOP_SUCCESS;
return;
if ((s = getenv("autoload")) != NULL) {
if (*s == 'n') {
/*
* Just use BOOTP to configure system;
* Do not use TFTP to load the bootfile.
*/
NetState = NETLOOP_SUCCESS;
return;
} else if (strcmp(s, "NFS") == 0) {
/*
* Use NFS to load the bootfile.
*/
NfsStart();
return;
}
}
TftpStart();
return;
+7 -7
View File
@@ -66,6 +66,7 @@ static char nfs_path_buff[2048];
static __inline__ void
store_block (uchar * src, unsigned offset, unsigned len)
{
ulong newsize = offset + len;
#ifdef CFG_DIRECT_FLASH_NFS
int i, rc = 0;
@@ -86,10 +87,12 @@ store_block (uchar * src, unsigned offset, unsigned len)
}
} else
#endif /* CFG_DIRECT_FLASH_NFS */
{
(void)memcpy ((void *)(load_addr + offset), src, len);
}
if (NetBootFileXferSize < (offset+len))
NetBootFileXferSize = newsize;
}
static char*
@@ -539,8 +542,7 @@ nfs_read_reply (uchar *pkt, unsigned len)
printf ("%s\n", __FUNCTION__);
#endif
rlen = (uchar *)&(rpc_pkt.u.reply.data[19]) - (uchar *)&(rpc_pkt.u.reply.id);
memcpy ((uchar *)&rpc_pkt, pkt, rlen);
memcpy ((uchar *)&rpc_pkt, pkt, sizeof(rpc_pkt.u.reply));
if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier ||
@@ -563,7 +565,7 @@ nfs_read_reply (uchar *pkt, unsigned len)
}
rlen = ntohl(rpc_pkt.u.reply.data[18]);
store_block ((uchar *)&(rpc_pkt.u.reply.data[19]), nfs_offset, rlen);
store_block ((uchar *)pkt+sizeof(rpc_pkt.u.reply), nfs_offset, rlen);
return rlen;
}
@@ -613,6 +615,7 @@ NfsHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len)
puts ("*** ERROR: Cannot umount\n");
NetState = NETLOOP_FAIL;
} else {
puts ("\ndone\n");
NetState = NETLOOP_SUCCESS;
}
break;
@@ -658,9 +661,6 @@ NfsHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len)
NfsState = STATE_READLINK_REQ;
NfsSend ();
} else {
puts ("\ndone\n");
printf ("Bytes transferred = %d (%x hex)\n",
nfs_offset, nfs_offset);
NfsState = STATE_UMOUNT_REQ;
NfsSend ();
}
+1 -1
View File
@@ -62,7 +62,7 @@ struct rpc_t {
uint32_t verifier;
uint32_t v2;
uint32_t astatus;
uint32_t data[1];
uint32_t data[19];
} reply;
} u;
};
+16 -1
View File
@@ -1,8 +1,23 @@
/*
* (C) Copyright 2000-2003
* (C) Copyright 2000-2004
* DENX Software Engineering
* Wolfgang Denk, wd@denx.de
* All rights reserved.
*
* 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 <errno.h>