blob: 8e0f6d3b739c5de5c08271c6475210045fc4f97e [file] [log] [blame]
wdenk9d5028c2004-11-21 00:06:33 +00001/*
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 *
wdenkbe6b6e42005-04-01 15:18:44 +00009 * Modified for CMC_BASIC by Martin Krause (2005), TQ-Systems GmbH
10 *
wdenk9d5028c2004-11-21 00:06:33 +000011 * 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 */
wdenkbe6b6e42005-04-01 15:18:44 +000038#define CMC_BASIC 1
39#define CMC_PU2 2
40
41int hw_detect (void);
wdenk9d5028c2004-11-21 00:06:33 +000042
43int board_init (void)
44{
45 DECLARE_GLOBAL_DATA_PTR;
wdenkbe6b6e42005-04-01 15:18:44 +000046 AT91PS_PIO piob = AT91C_BASE_PIOB;
47 AT91PS_PIO pioc = AT91C_BASE_PIOC;
wdenk9d5028c2004-11-21 00:06:33 +000048
49 /* Enable Ctrlc */
50 console_init_f ();
51
52 /* Correct IRDA resistor problem */
53 /* Set PA23_TXD in Output */
wdenkbe6b6e42005-04-01 15:18:44 +000054 /* (AT91PS_PIO) AT91C_BASE_PIOA->PIO_OER = AT91C_PA23_TXD2; */
wdenk9d5028c2004-11-21 00:06:33 +000055
56 /* memory and cpu-speed are setup before relocation */
57 /* so we do _nothing_ here */
58
wdenkbe6b6e42005-04-01 15:18:44 +000059 /* PIOB and PIOC clock enabling */
60 *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB;
61 *AT91C_PMC_PCER = 1 << AT91C_ID_PIOC;
62
63 /*
64 * configure PC0-PC3 as input without pull ups, so RS485 driver enable
65 * (CMC-PU2) and digital outputs (CMC-BASIC) are deactivated.
66 */
67 pioc->PIO_ODR = AT91C_PIO_PC0 | AT91C_PIO_PC1 |
68 AT91C_PIO_PC2 | AT91C_PIO_PC3;
69 pioc->PIO_PPUDR = AT91C_PIO_PC0 | AT91C_PIO_PC1 |
70 AT91C_PIO_PC2 | AT91C_PIO_PC3;
71 pioc->PIO_PER = AT91C_PIO_PC0 | AT91C_PIO_PC1 |
72 AT91C_PIO_PC2 | AT91C_PIO_PC3;
73
74 /*
75 * On CMC-PU2 board configure PB3-PB6 to input without pull ups to
76 * clear the duo LEDs (the external pull downs assure a proper
77 * signal). On CMC-BASIC set PB3-PB6 to output and drive it
78 * high, to configure current meassurement on AINx.
79 */
80 if (hw_detect() & CMC_PU2) {
81 piob->PIO_ODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 |
82 AT91C_PIO_PB5 | AT91C_PIO_PB6;
83 }
84 else if (hw_detect() & CMC_BASIC) {
85 piob->PIO_SODR = AT91C_PIO_PB3 | AT91C_PIO_PB4 |
86 AT91C_PIO_PB5 | AT91C_PIO_PB6;
87 piob->PIO_OER = AT91C_PIO_PB3 | AT91C_PIO_PB4 |
88 AT91C_PIO_PB5 | AT91C_PIO_PB6;
89 }
90 piob->PIO_PPUDR = AT91C_PIO_PB3 | AT91C_PIO_PB4 |
91 AT91C_PIO_PB5 | AT91C_PIO_PB6;
92 piob->PIO_PER = AT91C_PIO_PB3 | AT91C_PIO_PB4 |
93 AT91C_PIO_PB5 | AT91C_PIO_PB6;
94
95 /*
96 * arch number of CMC_PU2-Board. MACH_TYPE_CMC_PU2 is not supported in
97 * the linuxarm kernel, yet.
98 */
wdenk9d5028c2004-11-21 00:06:33 +000099 /* gd->bd->bi_arch_number = MACH_TYPE_CMC_PU2; */
100 gd->bd->bi_arch_number = 251;
101 /* adress of boot parameters */
102 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
103
104 return 0;
105}
106
107int dram_init (void)
108{
109 DECLARE_GLOBAL_DATA_PTR;
110
111 gd->bd->bi_dram[0].start = PHYS_SDRAM;
112 gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
113 return 0;
114}
wdenkbe6b6e42005-04-01 15:18:44 +0000115
116int checkboard (void)
117{
118 if (hw_detect() & CMC_PU2)
119 puts ("Board: CMC-PU2 (Rittal GmbH)\n");
120 else if (hw_detect() & CMC_BASIC)
121 puts ("Board: CMC-BASIC (Rittal GmbH)\n");
122 else
123 puts ("Board: unknown\n");
124 return 0;
125}
126
127int hw_detect (void)
128{
129 AT91PS_PIO pio = AT91C_BASE_PIOB;
130
131 /* PIOB clock enabling */
132 *AT91C_PMC_PCER = 1 << AT91C_ID_PIOB;
133
134 /* configure PB12 as input without pull up */
135 pio->PIO_ODR = AT91C_PIO_PB12;
136 pio->PIO_PPUDR = AT91C_PIO_PB12;
137 pio->PIO_PER = AT91C_PIO_PB12;
138
139 /* read board identification pin */
140 return ((pio->PIO_PDSR & AT91C_PIO_PB12) ? CMC_PU2 : CMC_BASIC);
141}