1 |
786 |
skrzyp |
/*==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// at91sam7xek_misc.c
|
4 |
|
|
//
|
5 |
|
|
// HAL misc board support code for Atmel AT91SAM7X EK board
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 2006 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): andrew lunn
|
43 |
|
|
// Contributors: Andrew Lunn, John Eigelaar
|
44 |
|
|
// Date: 2006-06-20
|
45 |
|
|
// Purpose: HAL board support
|
46 |
|
|
// Description: Implementations of HAL board interfaces
|
47 |
|
|
//
|
48 |
|
|
//####DESCRIPTIONEND####
|
49 |
|
|
//
|
50 |
|
|
//========================================================================*/
|
51 |
|
|
|
52 |
|
|
#include <pkgconf/system.h>
|
53 |
|
|
#include <pkgconf/hal.h>
|
54 |
|
|
|
55 |
|
|
#include <cyg/hal/hal_io.h> // IO macros
|
56 |
|
|
|
57 |
|
|
// The development board has four LEDs
|
58 |
|
|
void
|
59 |
|
|
hal_at91_led (int val)
|
60 |
|
|
{
|
61 |
|
|
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PB19, AT91_PIN_OUT);
|
62 |
|
|
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PB20, AT91_PIN_OUT);
|
63 |
|
|
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PB21, AT91_PIN_OUT);
|
64 |
|
|
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PB22, AT91_PIN_OUT);
|
65 |
|
|
|
66 |
|
|
HAL_ARM_AT91_GPIO_CFG_PULLUP(AT91_GPIO_PB19, AT91_PIN_PULLUP_DISABLE);
|
67 |
|
|
HAL_ARM_AT91_GPIO_CFG_PULLUP(AT91_GPIO_PB20, AT91_PIN_PULLUP_DISABLE);
|
68 |
|
|
HAL_ARM_AT91_GPIO_CFG_PULLUP(AT91_GPIO_PB21, AT91_PIN_PULLUP_DISABLE);
|
69 |
|
|
HAL_ARM_AT91_GPIO_CFG_PULLUP(AT91_GPIO_PB22, AT91_PIN_PULLUP_DISABLE);
|
70 |
|
|
|
71 |
|
|
// Set the bits. The logic is inverted
|
72 |
|
|
HAL_ARM_AT91_GPIO_PUT(AT91_GPIO_PB19, !(val & 1));
|
73 |
|
|
HAL_ARM_AT91_GPIO_PUT(AT91_GPIO_PB20, !(val & 2));
|
74 |
|
|
HAL_ARM_AT91_GPIO_PUT(AT91_GPIO_PB21, !(val & 4));
|
75 |
|
|
HAL_ARM_AT91_GPIO_PUT(AT91_GPIO_PB22, !(val & 8));
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
void hal_plf_eth_init(void)
|
79 |
|
|
{
|
80 |
|
|
cyg_uint32 stat;
|
81 |
|
|
|
82 |
|
|
/* Enable the PIOB Clock */
|
83 |
|
|
HAL_WRITE_UINT32(AT91_PMC + AT91_PMC_PCER, AT91_PMC_PCER_PIOB);
|
84 |
|
|
|
85 |
|
|
/* RXDV / Testmode select */
|
86 |
|
|
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PB15, AT91_PIN_IN);
|
87 |
|
|
HAL_ARM_AT91_GPIO_CFG_PULLUP(AT91_GPIO_PB15, AT91_PIN_PULLUP_DISABLE);
|
88 |
|
|
|
89 |
|
|
//TODO: The errata reports that the RMII mode for the SAM7X does not work.
|
90 |
|
|
// It would probably still be a good idea to use the RMII/MII CDL
|
91 |
|
|
// configuration to select the appropriate mode here
|
92 |
|
|
/* COL / !MII select */
|
93 |
|
|
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PB16, AT91_PIN_IN);
|
94 |
|
|
HAL_ARM_AT91_GPIO_CFG_PULLUP(AT91_GPIO_PB16, AT91_PIN_PULLUP_DISABLE);
|
95 |
|
|
|
96 |
|
|
/* TXCLK / ISOLATE */
|
97 |
|
|
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PB0, AT91_PIN_IN);
|
98 |
|
|
HAL_ARM_AT91_GPIO_CFG_PULLUP(AT91_GPIO_PB0, AT91_PIN_PULLUP_DISABLE);
|
99 |
|
|
|
100 |
|
|
/* Power Down Mode */
|
101 |
|
|
HAL_ARM_AT91_GPIO_CFG_DIRECTION(AT91_GPIO_PB18, AT91_PIN_OUT);
|
102 |
|
|
HAL_ARM_AT91_GPIO_PUT(AT91_GPIO_PB18,0);
|
103 |
|
|
|
104 |
|
|
/* All the lines setup correctly. Now do a external reset and let the phy
|
105 |
|
|
start up in the correct mode */
|
106 |
|
|
HAL_WRITE_UINT32(AT91_RST+AT91_RST_RMR,AT91_RST_RMR_KEY|(1<<0x8));
|
107 |
|
|
HAL_WRITE_UINT32(AT91_RST+AT91_RST_RCR,AT91_RST_RCR_KEY|AT91_RST_RCR_EXTRST);
|
108 |
|
|
|
109 |
|
|
do {
|
110 |
|
|
HAL_READ_UINT32(AT91_RST+AT91_RST_RSR,stat);
|
111 |
|
|
} while (!(stat&AT91_RST_RSR_NRST_SET));
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
//--------------------------------------------------------------------------
|
115 |
|
|
// EOF at91sam7sek_misc.c
|