]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/hal/arm/lpc2xxx/phycore229x/v2_0/src/phycore229x_misc.c
Initial revision
[karo-tx-redboot.git] / packages / hal / arm / lpc2xxx / phycore229x / v2_0 / src / phycore229x_misc.c
1 /*==========================================================================
2 //
3 //      phycore_misc.c
4 //
5 //      HAL misc board support code for Phytec phyCORE-LPC2292/94
6 //
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Copyright (C) 2008 eCosCentric Limited
13 //
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
17 //
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // 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 along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 //
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
33 //
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
36 // -------------------------------------------
37 //####ECOSGPLCOPYRIGHTEND####
38 //==========================================================================
39 //#####DESCRIPTIONBEGIN####
40 //
41 // Author(s):    Uwe Kindler 
42 // Contributors: Uwe Kindler
43 // Date:         2007-11-20
44 // Purpose:      HAL board support
45 // Description:  Implementations of HAL board interfaces
46 //
47 //####DESCRIPTIONEND####
48 //
49 //========================================================================*/
50 #include <pkgconf/hal.h>
51 #include <pkgconf/hal_arm_lpc2xxx_phycore229x.h>
52 #include <cyg/hal/hal_io.h>             // IO macros
53
54 #include <cyg/infra/cyg_type.h>         // base types
55 #include <cyg/hal/var_io.h>
56 #include <cyg/hal/plf_io.h>
57 #include <pkgconf/hal.h>
58
59 #include <cyg/hal/hal_arch.h>
60 #include <cyg/hal/hal_intr.h>
61
62 #ifdef CYGPKG_REDBOOT
63 #include <redboot.h>
64 #endif
65  
66 extern void cyg_hal_plf_serial_init(void);
67
68 void cyg_hal_plf_comms_init(void)
69 {
70     static int initialized = 0;
71         
72     if (initialized)
73         return;
74     initialized = 1;
75
76     cyg_hal_plf_serial_init();
77 }
78
79 //--------------------------------------------------------------------------
80 // hal_plf_hardware_init
81 //
82 void hal_plf_hardware_init(void)
83 {
84 #if defined(CYG_HAL_STARTUP_ROM) && defined(CYGPKG_DEVS_ETH_ARM_PHYCORE229X)
85     cyg_uint32 regval; 
86     
87     //
88     // Configures the LAN IRQ
89     // The interrupt is being used as active high edge triggered.
90     // IMPORTANT: We execute this step only for ROM startup. If this is done
91     // for RAM startup then wrong values are stored in EXTMODE and EXTPOLAR
92     // register because of a bug in LPC229x hardware.
93     //
94     HAL_INTERRUPT_CONFIGURE(CYGHWR_HAL_ARM_PHYCORE229X_ETH_EINT + // the configured external interrupt
95                             CYGNUM_HAL_INTERRUPT_EINT0,           // the first external interrupt
96                             0,                                    // level = 0 - edge triggered
97                             1);                                   // up = 1 - rising edge
98     
99     //
100     // Set pin function of P0.16 to EINT0 or P0.14 to EINT1 for ethernet interrupt
101     //
102 #if CYGHWR_HAL_ARM_PHYCORE229X_ETH_EINT == 0
103     HAL_READ_UINT32(CYGARC_HAL_LPC2XXX_REG_PIN_BASE + 
104                     CYGARC_HAL_LPC2XXX_REG_PINSEL1, regval);
105     regval |= 0x01;
106     HAL_WRITE_UINT32(CYGARC_HAL_LPC2XXX_REG_PIN_BASE + 
107                      CYGARC_HAL_LPC2XXX_REG_PINSEL1, regval);
108 #elif CYGHWR_HAL_ARM_PHYCORE229X_ETH_EINT == 1
109     HAL_READ_UINT32(CYGARC_HAL_LPC2XXX_REG_PIN_BASE + 
110                     CYGARC_HAL_LPC2XXX_REG_PINSEL0, regval);
111     regval |= (0x10 << 28);
112     HAL_WRITE_UINT32(CYGARC_HAL_LPC2XXX_REG_PIN_BASE + 
113                      CYGARC_HAL_LPC2XXX_REG_PINSEL0, regval);
114 #else
115 #error "Invalid CYGHWR_HAL_ARM_PHYCORE229X_ETH_EINT value"
116 #endif
117 #endif // #if defined(CYG_HAL_STARTUP_ROM) && defined(CYGPKG_DEVS_ETH_ARM_PHYCORE229X)
118 }
119
120 //--------------------------------------------------------------------------
121 // hal_lpc2xxx_set_leds
122 //
123 void hal_lpc2xxx_set_leds (int mask)
124 {
125     //
126     // implement function for setting diagnostic leds
127     //
128 }
129
130 //--------------------------------------------------------------------------
131 // EOF phycore_misc.c
132
133
134
135
136
137
138