00001 /* 00002 * Copyright 2010 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/at91sam9260_ek.c 00037 * \brief AT91SAM9260-EK initialization. 00038 * 00039 * \verbatim 00040 * $Id$ 00041 * \endverbatim 00042 */ 00043 00044 #include <arch/arm.h> 00045 00046 #define PHY_STRAP_AD0 _BV(PA14_ERX0_A) 00047 #define PHY_STRAP_AD1 _BV(PA15_ERX1_A) 00048 #define PHY_STRAP_AD2 _BV(PA25_ERX2_B) 00049 #define PHY_STRAP_AD3 _BV(PA26_ERX3_B) 00050 #define PHY_STRAP_AD4 _BV(PA28_ECRS_B) 00051 00052 #define PHY_STRAP_TESTMODE _BV(PA17_ERXDV_A) 00053 00054 #define PHY_STRAP_RMIISEL _BV(PA29_ECOL_B) 00055 00056 #define PHY_STRAP ( \ 00057 PHY_STRAP_AD0 | PHY_STRAP_AD1 | PHY_STRAP_AD2 | PHY_STRAP_AD3 | PHY_STRAP_AD4 | \ 00058 PHY_STRAP_TESTMODE | PHY_STRAP_RMIISEL ) 00059 00060 00066 static void Sam9g45ekDelay(int n) 00067 { 00068 int l; 00069 00070 for (l = 0; l < n; l++) { 00071 _NOP(); 00072 } 00073 } 00074 00078 static void Sam9G45ekClockInit(void) 00079 { 00080 outr(PMC_PCER, _BV(PIOA_ID)); 00081 outr(PMC_PCER, _BV(PIOB_ID)); 00082 outr(PMC_PCER, _BV(PIOC_ID)); 00083 outr(PMC_PCER, _BV(EMAC_ID)); 00084 } 00085 00089 static void Sam9260ekReset(void) 00090 { 00091 /* Set reset pulse length to 250us, disable user reset. */ 00092 outr(RSTC_MR, RSTC_KEY | (2 << RSTC_ERSTL_LSB)); 00093 /* Invoke external reset. */ 00094 outr(RSTC_CR, RSTC_KEY | RSTC_EXTRST); 00095 Sam9g45ekDelay(250); 00096 /* Wait until reset pin is released. */ 00097 while ((inr(RSTC_SR) & RSTC_NRSTL) == 0); 00098 Sam9g45ekDelay(25000); 00099 } 00100 00109 static void Sam9G45ekPhyInit(void) 00110 { 00111 /* The PHY needs 25ms for powering up. */ 00112 Sam9g45ekDelay(250000); 00113 /* Disable pull-ups. */ 00114 #if 0 00115 outr(PIOA_PUDR, PHY_STRAP); 00116 outr(PIOA_ODR, PHY_STRAP); 00117 outr(PIOA_PER, PHY_STRAP); 00118 #endif 00119 /* Toggle reset line. */ 00120 Sam9260ekReset(); 00121 /* Re-enable the pull-ups. */ 00122 // outr(PIOA_PUER, PHY_STRAP); 00123 } 00124 00130 void NutBoardInit(void) 00131 { 00132 Sam9G45ekClockInit(); 00133 return; 00134 Sam9G45ekPhyInit(); 00135 }