Nut/OS  4.10.3
API Reference
elektor_ir1.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010-2011 by egnite GmbH
00003  *
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 3. Neither the name of the copyright holders nor the names of
00016  *    contributors may be used to endorse or promote products derived
00017  *    from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00023  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00026  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00027  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00028  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00029  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  * For additional information see http://www.ethernut.de/
00033  */
00034 
00035 /*
00036  * \file arch/arm/board/eir1.c
00037  * \brief Elektor Internet Radio board initialization.
00038  *
00039  * \verbatim
00040  * $Id$
00041  * \endverbatim
00042  */
00043 
00044 #include <arch/arm.h>
00045 
00055 static void Delay(int n)
00056 {
00057     int l;
00058 
00059     for (l = 0; l < n; l++) {
00060         _NOP();
00061     }
00062 }
00063 
00067 void NutBoardInit(void)
00068 {
00069     /*
00070      * Reset the NIC.
00071      *
00072      * The low active PW_RST line of the DM9000E is connected to PC17.
00073      * Unfortunately the datasheet does not specify the minimum active
00074      * time. It only tells us, that the NIC will be available 5us
00075      * after de-asserting PW_RST. We keep the line low for 75us and
00076      * add a delay of 75us after putting it high again. This seems
00077      * to work reliable.
00078      */
00079     outr(PIOC_PER,  _BV(17));
00080     outr(PIOC_OER,  _BV(17));
00081     outr(PIOC_CODR, _BV(17));
00082     Delay(50);
00083     outr(PIOC_SODR, _BV(17));
00084     Delay(50);
00085 
00086     /* Enable Ethernet controller chip select. */
00087     outr(PIOA_BSR, _BV(PA20_NCS2_B));
00088     outr(PIOA_PDR, _BV(PA20_NCS2_B));
00089     /* Enable external memory read, write and wait signals. */
00090     outr(PIOC_BSR, _BV(PC16_NWAIT_B) | _BV(PC21_NWR0_B) | _BV(PC22_NRD_B));
00091     outr(PIOC_PDR, _BV(PC16_NWAIT_B) | _BV(PC21_NWR0_B) | _BV(PC22_NRD_B));
00092     /* Configure Ethernet controller chip select. */
00093     outr(SMC_CSR(2)
00094         , (1 << SMC_NWS_LSB)
00095         | SMC_WSEN
00096         | (2 << SMC_TDF_LSB)
00097         | SMC_BAT
00098         | SMC_DBW_16
00099         | (1 << SMC_RWSETUP_LSB)
00100         | (1 << SMC_RWHOLD_LSB)
00101         );
00102 }