/* * Copyright 2010 by egnite GmbH * * All rights reserved. * * 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 of the copyright holders nor the names of * 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. * * For additional information see http://www.ethernut.de/ */ /* * \file arch/arm/board/at91sam9260_ek.c * \brief AT91SAM9260-EK initialization. * * \verbatim * $Id$ * \endverbatim */ #include #define PHY_STRAP_AD0 _BV(PA14_ERX0_A) #define PHY_STRAP_AD1 _BV(PA15_ERX1_A) #define PHY_STRAP_AD2 _BV(PA25_ERX2_B) #define PHY_STRAP_AD3 _BV(PA26_ERX3_B) #define PHY_STRAP_AD4 _BV(PA28_ECRS_B) #define PHY_STRAP_TESTMODE _BV(PA17_ERXDV_A) #define PHY_STRAP_RMIISEL _BV(PA29_ECOL_B) #define PHY_STRAP ( \ PHY_STRAP_AD0 | PHY_STRAP_AD1 | PHY_STRAP_AD2 | PHY_STRAP_AD3 | PHY_STRAP_AD4 | \ PHY_STRAP_TESTMODE | PHY_STRAP_RMIISEL ) /*! * \brief Delay loop. * * \param Number of loops to execute. */ static void Sam9g45ekDelay(int n) { int l; for (l = 0; l < n; l++) { _NOP(); } } /*! * \brief Enable peripheral clocks. */ static void Sam9G45ekClockInit(void) { outr(PMC_PCER, _BV(PIOA_ID)); outr(PMC_PCER, _BV(PIOB_ID)); outr(PMC_PCER, _BV(PIOC_ID)); outr(PMC_PCER, _BV(EMAC_ID)); } /*! * \brief Toggle external hardware reset line. */ static void Sam9260ekReset(void) { /* Set reset pulse length to 250us, disable user reset. */ outr(RSTC_MR, RSTC_KEY | (2 << RSTC_ERSTL_LSB)); /* Invoke external reset. */ outr(RSTC_CR, RSTC_KEY | RSTC_EXTRST); Sam9g45ekDelay(250); /* Wait until reset pin is released. */ while ((inr(RSTC_SR) & RSTC_NRSTL) == 0); Sam9g45ekDelay(25000); } /*! * \brief Initialize the PHY hardware. * * On startup all GPIO pull-ups on the SAM9 are enabled by default * and may fight against internal pull-downs of the DM9161A. Here * we switch off all pull-ups connected to PHY strap pins and * issue an external reset. */ static void Sam9G45ekPhyInit(void) { /* The PHY needs 25ms for powering up. */ Sam9g45ekDelay(250000); /* Disable pull-ups. */ #if 0 outr(PIOA_PUDR, PHY_STRAP); outr(PIOA_ODR, PHY_STRAP); outr(PIOA_PER, PHY_STRAP); #endif /* Toggle reset line. */ Sam9260ekReset(); /* Re-enable the pull-ups. */ // outr(PIOA_PUER, PHY_STRAP); } /*! * \brief Early AT91SAM9260-EK hardware initialization. * * This routine is called during system initalization. */ void NutBoardInit(void) { Sam9G45ekClockInit(); return; Sam9G45ekPhyInit(); }