Changes for clean compile of DM90x0 driver on Neuros OSD

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@365 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-11-02 23:05:53 +00:00
parent f3209435ab
commit 03e6e759a6
13 changed files with 214 additions and 58 deletions

View File

@ -44,6 +44,7 @@
* Included Files
************************************************************/
#include <nuttx/irq.h>
#include <arch/chip/irq.h>
/************************************************************

View File

@ -37,7 +37,7 @@ HEAD_ASRC = up_nommuhead.S
CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S
CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copystate.c \
up_createstack.c up_dataabort.c up_delay.c up_doirq.c \
up_createstack.c up_dataabort.c up_mdelay.c up_udealy.c up_doirq.c \
up_exit.c up_idle.c up_initialize.c up_initialstate.c \
up_interruptcontext.c up_prefetchabort.c up_releasepending.c \
up_releasestack.c up_reprioritizertr.c up_schedulesigaction.c \

View File

@ -1,5 +1,5 @@
/************************************************************
* c5471/c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471c5471_serial.c
* c5471/c5471_serial.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@ -38,16 +38,19 @@
************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <unistd.h>
#include <semaphore.h>
#include <string.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/serial.h>
#include <arch/serial.h>
#include "up_arch.h"
#include "os_internal.h"
#include "up_internal.h"
@ -381,9 +384,9 @@ static int up_setup(struct uart_dev_s *dev)
/* Both the IrDA and MODEM UARTs support RESET and UART mode. */
up_serialout(priv, UART_MDR_OFFS, MDR_RESET_MODE);
up_delay(5);
up_mdelay(5);
up_serialout(priv, UART_MDR_OFFS, MDR_UART_MODE);
up_delay(5);
up_mdelay(5);
priv->regs.ier = up_inserial(priv, UART_IER_OFFS);
priv->regs.lcr = up_inserial(priv, UART_LCR_OFFS);

View File

@ -38,11 +38,15 @@
************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdlib.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include "up_arch.h"
#include "os_internal.h"
#include "up_internal.h"
@ -163,9 +167,9 @@ static void _up_assert(int errorcode) /* __attribute__ ((noreturn)) */
{
#ifdef CONFIG_ARCH_LEDS
up_ledon(LED_PANIC);
up_delay(250);
up_mdelay(250);
up_ledoff(LED_PANIC);
up_delay(250);
up_mdelay(250);
#endif
}
}

View File

@ -100,7 +100,6 @@ extern uint32 g_heapbase;
extern void up_boot(void);
extern void up_copystate(uint32 *dest, uint32 *src);
extern void up_dataabort(uint32 *regs);
extern void up_delay(int milliseconds);
extern void up_decodeirq(uint32 *regs);
extern void up_doirq(int irq, uint32 *regs);
extern void up_fullcontextrestore(uint32 *regs) __attribute__ ((noreturn));
@ -160,7 +159,7 @@ extern void up_ledoff(int led);
/* Defined in board/up_network.c */
#ifdef CONFIG_NET
extern up_netinitialize(void);
extern void up_netinitialize(void);
#else
# define up_netinitialize()
#endif

View File

@ -1,5 +1,5 @@
/************************************************************
* common/up_delay.c
/****************************************************************************
* common/up_mdelay.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
@ -31,62 +31,52 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Included Files
************************************************************/
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <unistd.h>
#include <semaphore.h>
#include <string.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/fs.h>
#include <arch/serial.h>
#include "up_arch.h"
#include "os_internal.h"
#include "up_internal.h"
/************************************************************
/****************************************************************************
* Definitions
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Private Types
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Private Function Prototypes
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Private Variables
************************************************************/
****************************************************************************/
/************************************************************
/****************************************************************************
* Private Functions
************************************************************/
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/************************************************************
* Public Funtions
************************************************************/
/************************************************************
* Name: up_delay
/****************************************************************************
* Name: up_mdelay
*
* Description:
* Delay inline for the requested number of milliseconds.
* NOT multi-tasking friendly.
* *** NOT multi-tasking friendly ***
*
************************************************************/
* ASSUMPTIONS:
* The setting CONFIG_BOARD_LOOPSPERMSEC has been calibrated
*
****************************************************************************/
void up_delay(int milliseconds)
void up_mdelay(unsigned int milliseconds)
{
volatile int i;
volatile int j;

View File

@ -0,0 +1,132 @@
/****************************************************************************
* common/up_udelay.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/arch.h>
/****************************************************************************
* Definitions
****************************************************************************/
#define CONFIG_BOARD_LOOPSPERUSEC ((CONFIG_BOARD_LOOPSPERMSEC+500)/1000)
#define CONFIG_BOARD_LOOPSPER10USEC ((CONFIG_BOARD_LOOPSPERMSEC+50)/100)
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Variables
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_udelay
*
* Description:
* Delay inline for the requested number of microseconds. NOTE: Because
* of all of the setup, several microseconds will be lost before the actual
* timing looop begins. Thus, the delay will always be a few microseconds
* longer than requested.
*
* *** NOT multi-tasking friendly ***
*
* ASSUMPTIONS:
* The setting CONFIG_BOARD_LOOPSPERMSEC has been calibrated
*
****************************************************************************/
void up_udelay(unsigned int microseconds)
{
volatile int i;
volatile int j;
register uint32 loops;
/* The value of microseconds should be less than 1000. If not, then we
* will perform millescond delays until it is.
*/
while (microseconds > 1000)
{
for (j = 0; j < CONFIG_BOARD_LOOPSPERMSEC; j++)
{
}
microseconds -= 1000;
}
/* The numerator of the 'loops' below will overflow if CONFIG_BOARD_LOOPSPERMSEC
* is larger than (4*1024*1024*1024 - 500)/999 = 4,299,266.06
*/
#if CONFIG_BOARD_LOOPSPERMSEC >= 4299266
while (microseconds > 500)
{
for (j = 0; j < ((CONFIG_BOARD_LOOPSPERMSEC+1)/2); j++)
{
}
microseconds -= 500;
}
#endif
/* The overflow could still occur if CONFIG_BOARD_LOOPSPERMSEC is larger than
* (4*1024*1024*1024 - 500)/499 = 8,607,147.89
*/
#if CONFIG_BOARD_LOOPSPERMSEC >= 8607147
# warning "Overflow in loops calculation is possible"
#endif
/* Caculate the number of loops need to produce the required usec delay */
loops = (CONFIG_BOARD_LOOPSPERMSEC * microseconds + 500) / 1000;
for (j = 0; j < loops; j++)
{
}
}

View File

@ -38,7 +38,7 @@ HEAD_ASRC = up_head.S
CMN_ASRCS = up_cache.S up_fullcontextrestore.S up_saveusercontext.S \
up_vectors.S up_vectortab.S
CMN_CSRCS = up_assert.c up_blocktask.c up_copystate.c up_createstack.c \
up_dataabort.c up_delay.c up_exit.c up_idle.c \
up_dataabort.c up_mdelay.c up_udelay.c up_exit.c up_idle.c \
up_initialize.c up_initialstate.c up_interruptcontext.c \
up_prefetchabort.c up_releasepending.c up_releasestack.c \
up_reprioritizertr.c up_schedulesigaction.c \

View File

@ -90,7 +90,7 @@
if ((pin) < 16) { _reg = (reg0); _pin = (pin); } \
else if ((pin) < 32) { _reg = (reg1); _pin = ((pin) - 16); } \
else { _reg = (reg2); _pin = ((pin) - 32); } \
putreg16((getreg16(_reg) | (1 << _pin)), _reg)); \
putreg16((getreg16(_reg) | (1 << _pin)), _reg); \
} while (0)
#define _GIO_CLEAR_REG(pin, reg0, reg1, reg2) \
@ -99,7 +99,7 @@
if ((pin) < 16) { _reg = (reg0); _pin = (pin); } \
else if ((pin) < 32) { _reg = (reg1); _pin = ((pin) - 16); } \
else { _reg = (reg2); _pin = ((pin) - 32); } \
putreg16((getreg16(_reg) & ~(1 << _pin)), _reg)); \
putreg16((getreg16(_reg) & ~(1 << _pin)), _reg); \
} while (0)
/* Select GIO input or output */

View File

@ -37,8 +37,8 @@ HEAD_ASRC = lpc214x_head.S
CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_vectors.S
CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copystate.c \
up_createstack.c up_dataabort.c up_delay.c up_exit.c \
up_idle.c up_initialize.c up_initialstate.c \
up_createstack.c up_dataabort.c up_mdelay.c up_udelay.c \
up_exit.c up_idle.c up_initialize.c up_initialstate.c \
up_interruptcontext.c up_prefetchabort.c up_releasepending.c \
up_releasestack.c up_reprioritizertr.c up_schedulesigaction.c \
up_sigdeliver.c up_syscall.c up_unblocktask.c \

View File

@ -41,10 +41,13 @@
#if defined(CONFIG_NET) && defined(CONFIG_NET_DM90x0)
#include <sys/types.h>
#include <arch/board.h>
#include <arch/board/board.h>
#include "up_arch.h"
#include "up_internal.h"
#include "chip/dm320_gio.h"
#include "dm320_memorymap.h"
#include "dm320_gio.h"
extern void dm9x_initialize(void);

View File

@ -46,12 +46,15 @@
/* Force debug on for this file */
#undef CONFIG_DEBUG
#undef CONFIG_DEBUG
#define CONFIG_DEBUG 1
#undef CONFIG_DEBUG_VERBOSE
#undef CONFIG_DEBUG_VERBOSE
#define CONFIG_DEBUG_VERBOSE 1
/* Only one hardware interface supported */
/* Only one hardware interface supported at present (althought there are
* hooks throughout the design to that extending the support to multiple
* interfaces should not be that difficult)
*/
#undef CONFIG_DM9X_NINTERFACES
#define CONFIG_DM9X_NINTERFACES 1
@ -830,6 +833,15 @@ static int dm9x_uiptxpoll(struct dm9x_driver_s *dm9x)
{
uip_arp_out(&dm9x->dev);
dm9x_transmit(dm9x);
/* Check if there is room in the DM90x0 to hold another packet. In 100M mode,
* that can be 2 packets, otherwise it is a single packet.
*/
if (dm9x->ntxpending > 1 || !dm9x->b100M)
{
return;
}
}
}
@ -847,6 +859,15 @@ static int dm9x_uiptxpoll(struct dm9x_driver_s *dm9x)
{
uip_arp_out(&dm9x->dev);
dm9x_transmit(dm9x);
/* Check if there is room in the DM90x0 to hold another packet. In 100M mode,
* that can be 2 packets, otherwise it is a single packet.
*/
if (dm9x->ntxpending > 1 || !dm9x->b100M)
{
return;
}
}
}
#endif /* CONFIG_NET_UDP */
@ -1118,7 +1139,7 @@ static int dm9x_interrupt(int irq, FAR void *context)
for (i = 0; i < 200; i++)
{
up_udelay(1000);
up_mdelay(1);
}
/* Set the new network speed */
@ -1133,7 +1154,7 @@ static int dm9x_interrupt(int irq, FAR void *context)
}
break;
}
up_udelay(1000);
up_mdelay(1);
}
dbg("delay: %d mS speed: %s\n", i, dm9x->b100M ? "100M" : "10M");
}
@ -1255,7 +1276,9 @@ static void dm9x_polltimer(int argc, uint32 arg, ...)
putreg(DM9X_IMR, DM9X_IMRENABLE);
}
/* Check if there is room in the TX FIFO to hold another packet */
/* Check if there is room in the DM90x0 to hold another packet. In 100M mode,
* that can be 2 packets, otherwise it is a single packet.
*/
if (dm9x->ntxpending < 1 || (dm9x->b100M && dm9x->ntxpending < 2))
{
@ -1561,7 +1584,7 @@ static void dm9x_reset(struct dm9x_driver_s *dm9x)
}
break;
}
up_udelay(1000);
up_mdelay(1);
}
/* Restore previous register address */

View File

@ -42,6 +42,7 @@
#include <time.h>
#include <wdog.h>
#include <debug.h>
#include <net/uip/uip-arp.h>