diff options
Diffstat (limited to 'ecos/packages/devs/eth/cf/current')
-rw-r--r-- | ecos/packages/devs/eth/cf/current/ChangeLog | 157 | ||||
-rw-r--r-- | ecos/packages/devs/eth/cf/current/cdl/cf_eth_drivers.cdl | 131 | ||||
-rw-r--r-- | ecos/packages/devs/eth/cf/current/include/devs_eth_cf.inl | 107 | ||||
-rw-r--r-- | ecos/packages/devs/eth/cf/current/src/if_sc_lpe.c | 314 |
4 files changed, 709 insertions, 0 deletions
diff --git a/ecos/packages/devs/eth/cf/current/ChangeLog b/ecos/packages/devs/eth/cf/current/ChangeLog new file mode 100644 index 0000000..9bf061a --- /dev/null +++ b/ecos/packages/devs/eth/cf/current/ChangeLog @@ -0,0 +1,157 @@ +2002-11-04 Gary Thomas <gthomas@ecoscentric.com> + + * src/if_sc_lpe.c (do_delay): Fix problem with overloaded name 'ticks'. + n.b. the FreeBSD stack has this defined for it's own use. + +2002-06-14 Gary Thomas <gary@chez-thomas.org> + + * src/if_sc_lpe.c: + Need to include <pkgconf/io_eth_drivers.h> for proper configuration + of stand-alone (polled) vs. system (interrupt driven) mode. + +2002-05-30 Jonathan Larmour <jlarmour@redhat.com> + + * src/if_sc_lpe.c: Conditionalize use of thread on CYGPKG_KERNEL + not CYGPKG_NET. + +2002-04-12 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: Clean up warnings. + +2001-10-16 Jesper Skov <jskov@redhat.com> + + * include/devs_eth_cf.inl: Added buffer parameters. + +2001-08-25 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c (sc_lpe_card_handler): Rework ESA discovery code. + +2001-08-22 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: + printf() is no longer a part of RedBoot. Thus all programs + must use diag_printf() and related functions instead. + +2001-06-16 Jesper Skov <jskov@redhat.com> + + * src/if_sc_lpe.c: Use generic DP83902A driver, only redefining + the init function to handle card details (which incidently do not + appear to be fully working). + + * include/devs_eth_cf.inl: Device details moved here so the + generic driver can access them. + + * cdl/cf_eth_drivers.cdl: Changes to use generic driver. Allow ESA + to be configured. + Require DP83902A package. + + * src/dp8390.h: Deleted. + +2001-04-13 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c (sc_lpe_card_handler): Work around broken card(s) + which do not have valid ESA in config EPROM. + +2000-09-15 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: Suppress noisy message which seems to sometimes + happen if the card is re-initialized from warm. + +2000-09-14 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: Better recovery for bad devices [stand-alone]. + +2000-09-13 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: Fix handling of receive buffer overflow, + i.e. missed data. [quietly ignored] + + * src/dp8390.h: Update layout of Tx/Rx buffers. + +2000-09-12 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c (sc_lpe_card_handler): Handle case when card + is warm (powered up from boot ROM). + +2000-09-01 Hugo Tyson <hmt@cygnus.co.uk> + + * src/if_sc_lpe.c (sc_lpe_init): Work with new fast net + thread to do all the copying work instead of loading up DSR time. + In detail: + o New "deliver" function in the interface record. It's the same + function as the poll entry; sc_lpe_int(). + o In registering the interrupt handler, use eth_drv_dsr (from the + logical driver) instead of sc_lpe_int. + +2000-08-29 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c (sc_lpe_recv): Better handling if upper layer + had no buffers [this routine called anyway]. + +2000-08-28 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: Better handling of "hot" cards (i.e. one + initialized by a debug environment). + +2000-08-23 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: Add new function to return interrupt vector + used by interface. Also, handle interrupts from interface even + if there is no kernel (CF callback). + +2000-08-03 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: Ensure DSR locked while initializing hardware. + + * cdl/cf_eth_drivers.cdl: Ethernet driver package hierarchy changed. + +2000-07-26 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: Update for new eth_drv interfaces (via *sc). + +2000-07-18 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c (sc_lpe_RxEvent): Handle case where chip gets lost + and keeps returning the same input packet (hardware bug?). + +2000-07-16 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c (sc_lpe_card_handler): Add initialization message and + timeout when running stand-alone. + +2000-07-15 Gary Thomas <gthomas@redhat.com> + + * src/if_sc_lpe.c: CF interrupts are now handled by the slot handler, + not directly in this code. + +2000-07-14 Gary Thomas <gthomas@redhat.com> + + * cdl/cf_eth_drivers.cdl: + * src/if_sc_lpe.c: Support building in eCos and stand-alone modes. + +//=========================================================================== +// ####GPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// 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 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., 51 Franklin Street, +// Fifth Floor, Boston, MA 02110-1301, USA. +// ------------------------------------------- +// ####GPLCOPYRIGHTEND#### +//=========================================================================== + + + diff --git a/ecos/packages/devs/eth/cf/current/cdl/cf_eth_drivers.cdl b/ecos/packages/devs/eth/cf/current/cdl/cf_eth_drivers.cdl new file mode 100644 index 0000000..727f320 --- /dev/null +++ b/ecos/packages/devs/eth/cf/current/cdl/cf_eth_drivers.cdl @@ -0,0 +1,131 @@ +# ==================================================================== +# +# cf_eth_drivers.cdl +# +# Ethernet drivers - device support for PCMCIA (Compact Flash) +# Socket Communications: Low Power Compact Flash Ethernet board +# +# ==================================================================== +## ####ECOSGPLCOPYRIGHTBEGIN#### +## ------------------------------------------- +## This file is part of eCos, the Embedded Configurable Operating System. +## Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +## +## eCos 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 or (at your option) any later +## version. +## +## eCos 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 eCos; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +## +## As a special exception, if other files instantiate templates or use +## macros or inline functions from this file, or you compile this file +## and link it with other works to produce a work based on this file, +## this file does not by itself cause the resulting work to be covered by +## the GNU General Public License. However the source code for this file +## must still be made available in accordance with section (3) of the GNU +## General Public License v2. +## +## This exception does not invalidate any other reasons why a work based +## on this file might be covered by the GNU General Public License. +## ------------------------------------------- +## ####ECOSGPLCOPYRIGHTEND#### +# ==================================================================== +######DESCRIPTIONBEGIN#### +# +# Author(s): gthomas +# Contributors: gthomas, jskov +# Date: 2000-07-07 +# +#####DESCRIPTIONEND#### +# +# ==================================================================== + +cdl_package CYGPKG_DEVS_ETH_CF { + display "PCMCIA (Compact Flash) ethernet drivers" + + parent CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_ETH_DRIVERS + active_if CYGPKG_IO_PCMCIA + requires CYGPKG_DEVS_ETH_NS_DP83902A + + implements CYGHWR_NET_DRIVERS + implements CYGHWR_NET_DRIVER_ETH0 + include_dir cyg/io + description "Ethernet driver for various PCMCIA (Compact Flash) boards." + compile -library=libextras.a if_sc_lpe.c + + # FIXME: This really belongs in the NS DP83902A package + cdl_interface CYGINT_DEVS_ETH_NS_DP83902A_REQUIRED { + display "NS DP83902A ethernet driver required" + } + + define_proc { + puts $::cdl_system_header "/***** ethernet driver proc output start *****/" + puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_NS_DP83902A_INL <cyg/io/devs_eth_cf.inl>" + puts $::cdl_system_header "#define CYGDAT_DEVS_ETH_NS_DP83902A_CFG <pkgconf/devs_eth_cf.h>" + puts $::cdl_system_header "/***** ethernet driver proc output end *****/" + } + + cdl_component CYGPKG_DEVS_ETH_CF_ETH0 { + display "CF ethernet port driver" + flavor bool + default_value 1 + description " + This option includes the ethernet device driver for a + CF card." + + implements CYGINT_DEVS_ETH_NS_DP83902A_REQUIRED + + cdl_option CYGDAT_DEVS_ETH_CF_ETH0_NAME { + display "Device name for the ETH0 ethernet driver" + flavor data + default_value {"\"eth0\""} + description " + This option sets the name of the ethernet device." + } + + cdl_component CYGSEM_DEVS_ETH_CF_ETH0_SET_ESA { + display "Set the ethernet station address" + flavor bool + default_value 0 + description "Enabling this option will allow the ethernet + station address to be forced to the value set by the + configuration. This may be required if the hardware does + not include a serial EEPROM for the ESA." + + cdl_option CYGDAT_DEVS_ETH_CF_ETH0_ESA { + display "The ethernet station address" + flavor data + default_value {"{0x08, 0x88, 0x12, 0x34, 0x56, 0x78}"} + description "The ethernet station address" + } + } + } + + cdl_component CYGPKG_DEVS_ETH_CF_OPTIONS { + display "PCMCIA ethernet driver build options" + flavor none + no_define + + cdl_option CYGPKG_DEVS_ETH_CF_CFLAGS_ADD { + display "Additional compiler flags" + flavor data + no_define + default_value { "-D_KERNEL -D__ECOS" } + description " + This option modifies the set of compiler flags for + building the PCMCIA ethernet driver package. + These flags are used in addition + to the set of global flags." + } + } +} + diff --git a/ecos/packages/devs/eth/cf/current/include/devs_eth_cf.inl b/ecos/packages/devs/eth/cf/current/include/devs_eth_cf.inl new file mode 100644 index 0000000..24a1051 --- /dev/null +++ b/ecos/packages/devs/eth/cf/current/include/devs_eth_cf.inl @@ -0,0 +1,107 @@ +//========================================================================== +// +// devs_eth_cf.inl +// +// CF (PCMCIA) ethernet I/O definitions. +// +//========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// eCos 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 or (at your option) any later +// version. +// +// eCos 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 eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): jskov +// Contributors:jskov +// Date: 2001-06-15 +// Purpose: PCMCIA ethernet defintions +// +//####DESCRIPTIONEND#### +//========================================================================== + +#include <cyg/hal/hal_intr.h> // CYGNUM_HAL_INTERRUPT_ETHR +#include <cyg/hal/hal_if.h> +#include <cyg/infra/cyg_type.h> +#include <cyg/io/pcmcia.h> + +#ifdef __WANT_CONFIG + +#undef CYGHWR_NS_DP83902A_PLF_INT_CLEAR +#define CYGHWR_NS_DP83902A_PLF_INT_CLEAR(_dp_) \ + CYG_MACRO_START \ + struct cf_slot* slot = (struct cf_slot*) (_dp_)->plf_priv; \ + cf_clear_interrupt(slot); \ + CYG_MACRO_END + +#endif // __WANT_CONFIG + +#ifdef __WANT_DEVS + +externC int cyg_sc_lpe_int_vector(struct eth_drv_sc *sc); +externC bool cyg_sc_lpe_init(struct cyg_netdevtab_entry *tab); + +#ifdef CYGPKG_DEVS_ETH_CF_ETH0 + +static dp83902a_priv_data_t dp83902a_eth0_priv_data = { + tx_buf1: 0x40, + tx_buf2: 0x48, + rx_buf_start: 0x50, + rx_buf_end: 0x80, +#ifdef CYGSEM_DEVS_ETH_CF_ETH0_SET_ESA + esa : CYGDAT_DEVS_ETH_CF_ETH0_ESA, + hardwired_esa : true, +#else + hardwired_esa : false, +#endif +}; + +ETH_DRV_SC(dp83902a_sc, + &dp83902a_eth0_priv_data, // Driver specific data + CYGDAT_DEVS_ETH_CF_ETH0_NAME, + dp83902a_start, + dp83902a_stop, + dp83902a_control, + dp83902a_can_send, + dp83902a_send, + dp83902a_recv, + dp83902a_deliver, // "pseudoDSR" called from fast net thread + dp83902a_poll, // poll function, encapsulates ISR and DSR + cyg_sc_lpe_int_vector); + +NETDEVTAB_ENTRY(dp83902a_netdev, + "dp83902a_" CYGDAT_DEVS_ETH_CF_ETH0_NAME, + cyg_sc_lpe_init, + &dp83902a_sc); +#endif // CYGPKG_DEVS_ETH_CF_ETH0 + +#endif // __WANT_DEVS + +// EOF devs_eth_cf.inl diff --git a/ecos/packages/devs/eth/cf/current/src/if_sc_lpe.c b/ecos/packages/devs/eth/cf/current/src/if_sc_lpe.c new file mode 100644 index 0000000..17e9140 --- /dev/null +++ b/ecos/packages/devs/eth/cf/current/src/if_sc_lpe.c @@ -0,0 +1,314 @@ +//========================================================================== +// +// dev/if_sc_lpe.c +// +// Ethernet device driver for Socket Communications Compact Flash card +// +//========================================================================== +// ####ECOSGPLCOPYRIGHTBEGIN#### +// ------------------------------------------- +// This file is part of eCos, the Embedded Configurable Operating System. +// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +// +// eCos 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 or (at your option) any later +// version. +// +// eCos 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 eCos; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// As a special exception, if other files instantiate templates or use +// macros or inline functions from this file, or you compile this file +// and link it with other works to produce a work based on this file, +// this file does not by itself cause the resulting work to be covered by +// the GNU General Public License. However the source code for this file +// must still be made available in accordance with section (3) of the GNU +// General Public License v2. +// +// This exception does not invalidate any other reasons why a work based +// on this file might be covered by the GNU General Public License. +// ------------------------------------------- +// ####ECOSGPLCOPYRIGHTEND#### +//========================================================================== +//#####DESCRIPTIONBEGIN#### +// +// Author(s): gthomas +// Contributors: gthomas, jskov +// Date: 2000-07-07 +// Purpose: +// Description: hardware driver for LPCF+ ethernet +// +// +//####DESCRIPTIONEND#### +// +//========================================================================== + +#include <pkgconf/system.h> +#include <pkgconf/io_eth_drivers.h> + +#include <cyg/infra/cyg_type.h> +#include <cyg/hal/hal_arch.h> +#include <cyg/infra/diag.h> +#include <cyg/hal/drv_api.h> +#include <cyg/io/pcmcia.h> +#include <cyg/io/eth/eth_drv.h> +#include <cyg/io/eth/netdev.h> + +#ifdef CYGPKG_NET +#include <pkgconf/net.h> +#else +#include <cyg/hal/hal_if.h> +#endif + +#include <cyg/io/dp83902a.h> + +#define DP_DATA 0x10 +#define DP_CARD_RESET 0x1f + +#define SC_LPE_MANUF 0x0104 + +#ifdef CYGPKG_KERNEL +#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL +static char sc_lpe_card_handler_stack[STACK_SIZE]; +static cyg_thread sc_lpe_card_handler_thread_data; +static cyg_handle_t sc_lpe_card_handler_thread_handle; +#endif // CYGPKG_KERNEL + +__inline__ static void +do_delay(int _ticks) +{ +#ifdef CYGPKG_KERNEL + cyg_thread_delay(_ticks); +#else + CYGACC_CALL_IF_DELAY_US(10000*_ticks); +#endif +} + +// +// This runs as a separate thread to handle the card. In particular, insertions +// and deletions need to be handled and they take time/coordination, thus the +// separate thread. +// +#ifdef CYGPKG_KERNEL +static void +#else +static int +#endif +sc_lpe_card_handler(cyg_addrword_t param) +{ + struct eth_drv_sc *sc = (struct eth_drv_sc *)param; + dp83902a_priv_data_t *dp = (dp83902a_priv_data_t*)sc->driver_private; + struct cf_slot *slot; + struct cf_cftable cftable; + struct cf_config config; + int i, len, ptr, cor = 0; + unsigned char buf[256], *cp; + cyg_uint8* base; + unsigned char *vers_product, *vers_manuf, *vers_revision, *vers_date; +#ifndef CYGPKG_KERNEL + int tries = 0; +#endif + bool first = true; + + slot = (struct cf_slot*)dp->plf_priv; + cyg_drv_dsr_lock(); + while (true) { + cyg_drv_dsr_unlock(); // Give DSRs a chance to run (card insertion) + cyg_drv_dsr_lock(); + if ((slot->state == CF_SLOT_STATE_Inserted) || + ((slot->state == CF_SLOT_STATE_Ready) && first)) { + first = false; + if (slot->state != CF_SLOT_STATE_Ready) { + cf_change_state(slot, CF_SLOT_STATE_Ready); + } + if (slot->state != CF_SLOT_STATE_Ready) { + diag_printf("CF card won't go ready!\n"); +#ifndef CYGPKG_KERNEL + return false; +#else + continue; +#endif + } + len = sizeof(buf); + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_MANFID, buf, &len, &ptr)) { + if (*(short *)&buf[2] != SC_LPE_MANUF) { + diag_printf("Not a SC LPE, sorry\n"); + continue; + } + } + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_VERS_1, buf, &len, &ptr)) { + // Find individual strings + cp = &buf[4]; + vers_product = cp; + while (*cp++) ; // Skip to nul + vers_manuf = cp; + while (*cp++) ; // Skip to nul + vers_revision = cp; + while (*cp++) ; // Skip to nul + vers_date = cp; +#ifndef CYGPKG_KERNEL + if (tries != 0) diag_printf("\n"); + diag_printf("%s: %s %s %s\n", vers_manuf, vers_product, vers_revision, vers_date); +#endif + } + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_CONFIG, buf, &len, &ptr)) { + if (cf_parse_config(buf, len, &config)) { + cor = config.base; + } + } + if (!cor) { +// diag_printf("Couldn't find COR pointer!\n"); + continue; + } + + ptr = 0; + if (cf_get_CIS(slot, CF_CISTPL_CFTABLE_ENTRY, buf, &len, &ptr)) { + if (cf_parse_cftable(buf, len, &cftable)) { + cyg_uint8 tmp; + // Initialize dp83902a IO details + dp->base = base = (cyg_uint8*)&slot->io[cftable.io_space.base[0]]; + dp->data = base + DP_DATA; + dp->interrupt = slot->int_num; + cf_set_COR(slot, cor, cftable.cor); + // Reset card (read issues RESET, write clears it) + HAL_READ_UINT8(base+DP_CARD_RESET, tmp); + HAL_WRITE_UINT8(base+DP_CARD_RESET, tmp); + // Wait for card + do { + DP_IN(base, DP_ISR, tmp); + } while (0 == (tmp & DP_ISR_RESET)); + + // Fetch hardware address from card - terrible, but not well defined + // Patterned after what Linux drivers do + if (!dp->hardwired_esa) { + static unsigned char sc_lpe_addr[] = { 0x00, 0xC0, 0x1B, 0x00, 0x99, 0x9E}; + if ((slot->attr[0x1C0] == sc_lpe_addr[0]) && + (slot->attr[0x1C2] == sc_lpe_addr[1]) && + (slot->attr[0x1C4] == sc_lpe_addr[2])) { + sc_lpe_addr[3] = slot->attr[0x1C6]; + sc_lpe_addr[4] = slot->attr[0x1C8]; + sc_lpe_addr[5] = slot->attr[0x1CA]; + } else { + // Coudn't find it in the CIS (attribute) data + unsigned char prom[32]; + + // Tell device to give up ESA + DP_OUT(base, DP_DCR, 0x48); // Bytewide access + DP_OUT(base, DP_RBCH, 0); // Remote byte count + DP_OUT(base, DP_RBCL, 0); + DP_OUT(base, DP_ISR, 0xFF); // Clear any pending interrupts + DP_OUT(base, DP_IMR, 0x00); // Mask all interrupts + DP_OUT(base, DP_RCR, 0x20); // Monitor + DP_OUT(base, DP_TCR, 0x02); // loopback + DP_OUT(base, DP_RBCH, 32); // Remote byte count + DP_OUT(base, DP_RBCL, 0); + DP_OUT(base, DP_RSAL, 0); // Remote address + DP_OUT(base, DP_RSAH, 0); + DP_OUT(base, DP_CR, DP_CR_START|DP_CR_RDMA); // Read data + for (i = 0; i < 32; i++) { + HAL_READ_UINT8(base+DP_DATAPORT, prom[i]); + } + if ((prom[0] == sc_lpe_addr[0]) && + (prom[2] == sc_lpe_addr[1]) && + (prom[4] == sc_lpe_addr[2])) { + diag_printf("Getting address from port\n"); + sc_lpe_addr[3] = prom[6]; + sc_lpe_addr[4] = prom[8]; + sc_lpe_addr[5] = prom[10]; + } else { + diag_printf("No valid ESA found in CIS! Hardwiring to 00:C0:1B:00:99:9E\n"); + } + } + for (i = 0; i < 6; i++) { + dp->esa[i] = sc_lpe_addr[i]; + } + } + + // Initialize upper level driver + (sc->funs->eth_drv->init)(sc, dp->esa); + // Tell system card is ready to talk + dp->tab->status = CYG_NETDEVTAB_STATUS_AVAIL; +#ifndef CYGPKG_KERNEL + cyg_drv_dsr_unlock(); + return true; +#endif + } else { + diag_printf("Can't parse CIS\n"); + continue; + } + } else { + diag_printf("Can't fetch config info\n"); + continue; + } + } else if (slot->state == CF_SLOT_STATE_Removed) { + diag_printf("Compact Flash card removed!\n"); + } else { + cyg_drv_dsr_unlock(); + do_delay(50); // FIXME! +#ifndef CYGPKG_KERNEL + if (tries == 0) diag_printf("... Waiting for network card: "); + diag_printf("."); + if (++tries == 10) { + // 5 seconds have elapsed - give up + return false; + } + cf_hwr_poll(slot); // Check to see if card has been inserted +#endif + cyg_drv_dsr_lock(); + } + } +} + +bool +cyg_sc_lpe_init(struct cyg_netdevtab_entry *tab) +{ + struct eth_drv_sc *sc = (struct eth_drv_sc *)tab->device_instance; + dp83902a_priv_data_t *dp = (dp83902a_priv_data_t *)sc->driver_private; + struct cf_slot* slot; + + cf_init(); // Make sure Compact Flash subsystem is initialized + slot = dp->plf_priv = (void*)cf_get_slot(0); + dp->tab = tab; + +#ifdef CYGPKG_KERNEL + // Create card handling [background] thread + cyg_thread_create(CYGPKG_NET_THREAD_PRIORITY-1, // Priority + sc_lpe_card_handler, // entry + (cyg_addrword_t)sc, // entry parameter + "SC LP-E card support", // Name + &sc_lpe_card_handler_stack[0], // Stack + STACK_SIZE, // Size + &sc_lpe_card_handler_thread_handle, // Handle + &sc_lpe_card_handler_thread_data // Thread data structure + ); + cyg_thread_resume(sc_lpe_card_handler_thread_handle); // Start it + + // Initialize environment, setup interrupt handler + // eth_drv_dsr is used to tell the fast net thread to run the deliver funcion. + cf_register_handler(slot, eth_drv_dsr, sc); + + return false; // Device is not ready until inserted, powered up, etc. +#else + // Initialize card + return sc_lpe_card_handler((cyg_addrword_t)sc); +#endif +} + +int +cyg_sc_lpe_int_vector(struct eth_drv_sc *sc) +{ + dp83902a_priv_data_t *dp = (dp83902a_priv_data_t *)sc->driver_private; + struct cf_slot* slot = (struct cf_slot*)dp->plf_priv; + + return slot->int_num; +} |