From a9d50d07b23fa0ab3cc4063f280a7f75f73966ab Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 1 May 2009 23:42:40 +0000 Subject: update git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1750 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/drivers/net/cs89x0.c | 69 +++++++++++++++++++++++++++++++++++++------- nuttx/include/nuttx/cs89x0.h | 7 ++++- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/nuttx/drivers/net/cs89x0.c b/nuttx/drivers/net/cs89x0.c index 5fe8c8702..bfabe6e93 100644 --- a/nuttx/drivers/net/cs89x0.c +++ b/nuttx/drivers/net/cs89x0.c @@ -57,6 +57,8 @@ * Definitions ****************************************************************************/ +#error "Under construction -- do not use" + /* CONFIG_CS89x0_NINTERFACES determines the number of physical interfaces * that will be supported. */ @@ -192,24 +194,70 @@ static void cs89x0_putreg(struct cs89x0_driver_s *cs89x0, int offset, uint16 val static uint16 cs89x0_getppreg(struct cs89x0_driver_s *cs89x0, int addr) { + /* In memory mode, the CS89x0's internal registers and frame buffers are mapped + * into a contiguous 4kb block providing direct access to the internal registers + * and frame buffers. + */ + +#ifdef CONFIG_CS89x0_MEMMODE + if (cs89x0->cs_memmode) + { #ifdef CONFIG_CS89x0_ALIGN16 - putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); - return getreg16(s89x0->cs_base + CS89x0_PDATA_OFFSET); + return getreg16(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); #else - putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); - return (uint16)getreg32(s89x0->cs_base + CS89x0_PDATA_OFFSET); + return (uint16)getreg32(s89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); #endif + } + + /* When configured in I/O mode, the CS89x0 is accessed through eight, 16-bit + * I/O ports that in the host system's I/O space. + */ + + else +#endif + { +#ifdef CONFIG_CS89x0_ALIGN16 + putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); + return getreg16(s89x0->cs_base + CS89x0_PDATA_OFFSET); +#else + putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); + return (uint16)getreg32(s89x0->cs_base + CS89x0_PDATA_OFFSET); +#endif + } } static void cs89x0_putppreg(struct cs89x0_driver_s *cs89x0, int addr, uint16 value) { + /* In memory mode, the CS89x0's internal registers and frame buffers are mapped + * into a contiguous 4kb block providing direct access to the internal registers + * and frame buffers. + */ + +#ifdef CONFIG_CS89x0_MEMMODE + if (cs89x0->cs_memmode) + { +#ifdef CONFIG_CS89x0_ALIGN16 + putreg16(value), cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); +#else + putreg32((uint32)value, cs89x0->cs_ppbase + (CS89x0_PDATA_OFFSET << ??)); +#endif + } + + /* When configured in I/O mode, the CS89x0 is accessed through eight, 16-bit + * I/O ports that in the host system's I/O space. + */ + + else +#endif + { #ifdef CONFIG_CS89x0_ALIGN16 - putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); - putreg16(value), cs89x0->cs_base + CS89x0_PDATA_OFFSET); + putreg16((uint16)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); + putreg16(value, cs89x0->cs_base + CS89x0_PDATA_OFFSET); #else - putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); - putreg32((uint32)value, cs89x0->cs_base + CS89x0_PDATA_OFFSET); + putreg32((uint32)addr, cs89x0->cs_base + CS89x0_PPTR_OFFSET); + putreg32((uint32)value, cs89x0->cs_base + CS89x0_PDATA_OFFSET); #endif + } } /**************************************************************************** @@ -550,15 +598,14 @@ static int cs89x0_interrupt(int irq, FAR void *context) { ndbg("Transmit underrun\n"); #ifdef CONFIG_CS89x0_XMITEARLY - cd89x0->cs_txunderrun++; if (cd89x0->cs_txunderrun == 3) { - cd89x0->send_cmd = TX_AFTER_381; + cd89x0->cs_txstart = PPR_TXCMD_TXSTART381; } else if (cd89x0->cs_txunderrun == 6) { - cd89x0->send_cmd = TX_AFTER_ALL; + cd89x0->cs_txstart = PPR_TXCMD_TXSTARTFULL; } #endif } diff --git a/nuttx/include/nuttx/cs89x0.h b/nuttx/include/nuttx/cs89x0.h index 29fffdc5a..6e2f5bc34 100755 --- a/nuttx/include/nuttx/cs89x0.h +++ b/nuttx/include/nuttx/cs89x0.h @@ -88,13 +88,18 @@ struct cs89x0_driver_s */ FAR void *cs_base; /* CS89x0 region base address */ +#ifdef CONFIG_CS89x0_MEMMODE FAR void *cs_ppbase; /* CS89x0 page packet base address */ +#endif ubyte cs_irq; /* CS89x00 IRQ number */ /* Driver internal state fields. These must be zeroed by before the * instance of this structure is passed to cs89x0_initialize */ - +#ifdef CONFIG_CS89x0_XMITEARLY + ubyte txstart; /* Bits 6-7 of TxCMD controls Tx race */ +#endif + boolean cs_memmode; /* TRUE:memory mode FALSE: I/O mode */ boolean cs_bifup; /* TRUE:ifup FALSE:ifdown */ WDOG_ID cs_txpoll; /* TX poll timer */ WDOG_ID cs_txtimeout; /* TX timeout timer */ -- cgit v1.2.3