]>
Commit | Line | Data |
---|---|---|
9d5028c2 WD |
1 | /* |
2 | * (C) Copyright 2002 | |
3 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> | |
4 | * Marius Groeger <mgroeger@sysgo.de> | |
5 | * | |
6 | * Modified for CMC_PU2 (removed Smart Media support) by Gary Jennejohn | |
7 | * (2004) garyj@denx.de | |
8 | * | |
be6b6e4e WD |
9 | * Modified for CMC_BASIC by Martin Krause (2005), TQ-Systems GmbH |
10 | * | |
9d5028c2 WD |
11 | * See file CREDITS for list of people who contributed to this |
12 | * project. | |
13 | * | |
14 | * This program is free software; you can redistribute it and/or | |
15 | * modify it under the terms of the GNU General Public License as | |
16 | * published by the Free Software Foundation; either version 2 of | |
17 | * the License, or (at your option) any later version. | |
18 | * | |
19 | * This program is distributed in the hope that it will be useful, | |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | * GNU General Public License for more details. | |
23 | * | |
24 | * You should have received a copy of the GNU General Public License | |
25 | * along with this program; if not, write to the Free Software | |
26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
27 | * MA 02111-1307 USA | |
28 | */ | |
29 | ||
30 | #include <common.h> | |
31 | #include <asm/mach-types.h> | |
32 | #include <asm/arch/AT91RM9200.h> | |
33 | ||
34 | /* ------------------------------------------------------------------------- */ | |
35 | /* | |
36 | * Miscelaneous platform dependent initialisations | |
37 | */ | |
601aed1e | 38 | #define CMC_HP_BASIC 1 |
be6b6e4e | 39 | #define CMC_PU2 2 |
601aed1e | 40 | #define CMC_BASIC 4 |
be6b6e4e WD |
41 | |
42 | int hw_detect (void); | |
9d5028c2 WD |
43 | |
44 | int board_init (void) | |
45 | { | |
46 | DECLARE_GLOBAL_DATA_PTR; | |
be6b6e4e WD |
47 | AT91PS_PIO piob = AT91C_BASE_PIOB; |
48 | AT91PS_PIO pioc = AT91C_BASE_PIOC; | |
9d5028c2 WD |
49 | |
50 | /* Enable Ctrlc */ | |
51 | console_init_f (); | |
52 | ||
53 | /* Correct IRDA resistor problem */ | |
54 | /* Set PA23_TXD in Output */ | |
be6b6e4e | 55 | /* (AT91PS_PIO) AT91C_BASE_PIOA->PIO_OER = AT91C_PA23_TXD2; */ |
9d5028c2 WD |
56 | |
57 | /* memory and cpu-speed are setup before relocation */ | |
58 | /* so we do _nothing_ here */ | |
59 | ||
be6b6e4e WD |
60 | /* PIOB and PIOC clock enabling */ |
61 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB; | |
62 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOC; | |
63 | ||
64 | /* | |
65 | * configure PC0-PC3 as input without pull ups, so RS485 driver enable | |
66 | * (CMC-PU2) and digital outputs (CMC-BASIC) are deactivated. | |
67 | */ | |
68 | pioc->PIO_ODR = AT91C_PIO_PC0 | AT91C_PIO_PC1 | | |
69 | AT91C_PIO_PC2 | AT91C_PIO_PC3; | |
70 | pioc->PIO_PPUDR = AT91C_PIO_PC0 | AT91C_PIO_PC1 | | |
71 | AT91C_PIO_PC2 | AT91C_PIO_PC3; | |
72 | pioc->PIO_PER = AT91C_PIO_PC0 | AT91C_PIO_PC1 | | |
73 | AT91C_PIO_PC2 | AT91C_PIO_PC3; | |
74 | ||
75 | /* | |
76 | * On CMC-PU2 board configure PB3-PB6 to input without pull ups to | |
77 | * clear the duo LEDs (the external pull downs assure a proper | |
601aed1e WD |
78 | * signal). On CMC-BASIC and CMC-HP-BASIC set PB3-PB6 to output and |
79 | * drive it high, to configure current measurement on AINx. | |
be6b6e4e WD |
80 | */ |
81 | if (hw_detect() & CMC_PU2) { | |
82 | piob->PIO_ODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | | |
83 | AT91C_PIO_PB5 | AT91C_PIO_PB6; | |
84 | } | |
601aed1e | 85 | else if ((hw_detect() & CMC_BASIC) || (hw_detect() & CMC_HP_BASIC)) { |
be6b6e4e WD |
86 | piob->PIO_SODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | |
87 | AT91C_PIO_PB5 | AT91C_PIO_PB6; | |
88 | piob->PIO_OER = AT91C_PIO_PB3 | AT91C_PIO_PB4 | | |
89 | AT91C_PIO_PB5 | AT91C_PIO_PB6; | |
90 | } | |
91 | piob->PIO_PPUDR = AT91C_PIO_PB3 | AT91C_PIO_PB4 | | |
92 | AT91C_PIO_PB5 | AT91C_PIO_PB6; | |
93 | piob->PIO_PER = AT91C_PIO_PB3 | AT91C_PIO_PB4 | | |
94 | AT91C_PIO_PB5 | AT91C_PIO_PB6; | |
95 | ||
96 | /* | |
97 | * arch number of CMC_PU2-Board. MACH_TYPE_CMC_PU2 is not supported in | |
98 | * the linuxarm kernel, yet. | |
99 | */ | |
9d5028c2 WD |
100 | /* gd->bd->bi_arch_number = MACH_TYPE_CMC_PU2; */ |
101 | gd->bd->bi_arch_number = 251; | |
102 | /* adress of boot parameters */ | |
103 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; | |
104 | ||
105 | return 0; | |
106 | } | |
107 | ||
108 | int dram_init (void) | |
109 | { | |
110 | DECLARE_GLOBAL_DATA_PTR; | |
111 | ||
112 | gd->bd->bi_dram[0].start = PHYS_SDRAM; | |
113 | gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE; | |
114 | return 0; | |
115 | } | |
be6b6e4e WD |
116 | |
117 | int checkboard (void) | |
118 | { | |
119 | if (hw_detect() & CMC_PU2) | |
120 | puts ("Board: CMC-PU2 (Rittal GmbH)\n"); | |
121 | else if (hw_detect() & CMC_BASIC) | |
122 | puts ("Board: CMC-BASIC (Rittal GmbH)\n"); | |
601aed1e WD |
123 | else if (hw_detect() & CMC_HP_BASIC) |
124 | puts ("Board: CMC-HP-BASIC (Rittal GmbH)\n"); | |
be6b6e4e WD |
125 | else |
126 | puts ("Board: unknown\n"); | |
127 | return 0; | |
128 | } | |
129 | ||
130 | int hw_detect (void) | |
131 | { | |
132 | AT91PS_PIO pio = AT91C_BASE_PIOB; | |
133 | ||
134 | /* PIOB clock enabling */ | |
135 | *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB; | |
136 | ||
137 | /* configure PB12 as input without pull up */ | |
138 | pio->PIO_ODR = AT91C_PIO_PB12; | |
139 | pio->PIO_PPUDR = AT91C_PIO_PB12; | |
140 | pio->PIO_PER = AT91C_PIO_PB12; | |
6617aae9 | 141 | |
601aed1e WD |
142 | /* configure PB13 as input without pull up */ |
143 | pio->PIO_ODR = AT91C_PIO_PB13; | |
144 | pio->PIO_PPUDR = AT91C_PIO_PB13; | |
145 | pio->PIO_PER = AT91C_PIO_PB13; | |
be6b6e4e WD |
146 | |
147 | /* read board identification pin */ | |
601aed1e WD |
148 | if (pio->PIO_PDSR & AT91C_PIO_PB12) |
149 | return ((pio->PIO_PDSR & AT91C_PIO_PB13) | |
150 | ? CMC_PU2 : 0); | |
151 | else | |
152 | return ((pio->PIO_PDSR & AT91C_PIO_PB13) | |
153 | ? CMC_HP_BASIC : CMC_BASIC); | |
be6b6e4e | 154 | } |