blob: 65a8b2989f84a2113f067b67d2fbaf2825224c95 [file] [log] [blame]
Timo Tuunainen7174cc02008-02-01 10:09:03 +00001/*
2 * (C) Copyright 2008
3 * Based on modifications by Alan Lu / Artila
4 * Author : Timo Tuunainen / Sysart
5 Kimmo Leppala / Sysart
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <common.h>
27#include <at91rm9200_net.h>
28#include <dm9161.h>
29#include "m501sk.h"
30#include "net.h"
31
32#ifdef CONFIG_M501SK
33
34void m501sk_gpio_init(void)
35{
36 AT91C_BASE_PIOD->PIO_PER = 1 << (M501SK_DEBUG_LED1 - 96) |
37 1 << (M501SK_DEBUG_LED2 - 96) | 1 << (M501SK_DEBUG_LED3 - 96) |
38 1 << (M501SK_DEBUG_LED4 - 96) | 1 << (M501SK_READY_LED - 96);
39
40 AT91C_BASE_PIOD->PIO_OER = 1 << (M501SK_DEBUG_LED1 - 96) |
41 1 << (M501SK_DEBUG_LED2 - 96) | 1 << (M501SK_DEBUG_LED3 - 96) |
42 1 << (M501SK_DEBUG_LED4 - 96) | 1 << (M501SK_READY_LED - 96);
43
44 AT91C_BASE_PIOD->PIO_SODR = 1 << (M501SK_READY_LED - 96);
45 AT91C_BASE_PIOD->PIO_CODR = 1 << (M501SK_DEBUG_LED3 - 96);
46 AT91C_BASE_PIOB->PIO_PER = 1 << (M501SK_BUZZER - 32);
47 AT91C_BASE_PIOB->PIO_OER = 1 << (M501SK_BUZZER - 32);
48 AT91C_BASE_PIOC->PIO_PDR = (1 << 7) | (1 << 8);
49
50 /* Power OFF all USART's LEDs */
51 AT91C_BASE_PIOA->PIO_PER = AT91C_PA5_TXD3 | AT91C_PA6_RXD3 |
52 AT91C_PA17_TXD0 | AT91C_PA18_RXD0 | AT91C_PA22_RXD2 | \
53 AT91C_PA23_TXD2;
54
55 AT91C_BASE_PIOA->PIO_OER = AT91C_PA5_TXD3 | AT91C_PA6_RXD3 |
56 AT91C_PA17_TXD0 | AT91C_PA18_RXD0 | AT91C_PA22_RXD2 | \
57 AT91C_PA23_TXD2;
58
59 AT91C_BASE_PIOA->PIO_SODR = AT91C_PA5_TXD3 | AT91C_PA6_RXD3 |
60 AT91C_PA17_TXD0 | AT91C_PA18_RXD0 | AT91C_PA22_RXD2 | \
61 AT91C_PA23_TXD2;
62
63 AT91C_BASE_PIOB->PIO_PER = AT91C_PB20_RXD1 | AT91C_PB21_TXD1;
64 AT91C_BASE_PIOB->PIO_OER = AT91C_PB20_RXD1 | AT91C_PB21_TXD1;
65 AT91C_BASE_PIOB->PIO_SODR = AT91C_PB20_RXD1 | AT91C_PB21_TXD1;
66}
67
68uchar m501sk_gpio_set(M501SK_PIO io)
69{
70 uchar status = 0xff;
71 switch (io) {
72 case M501SK_DEBUG_LED1:
73 case M501SK_DEBUG_LED2:
74 case M501SK_DEBUG_LED3:
75 case M501SK_DEBUG_LED4:
76 case M501SK_READY_LED:
77 AT91C_BASE_PIOD->PIO_SODR = 1 << (io - 96);
78 status = AT91C_BASE_PIOD->PIO_ODSR & (1 << (io - 96));
79 break;
80 case M501SK_BUZZER:
81 AT91C_BASE_PIOB->PIO_SODR = 1 << (io - 32);
82 status = AT91C_BASE_PIOB->PIO_ODSR & (1 << (io - 32));
83 break;
84 }
85 return status;
86}
87
88uchar m501sk_gpio_clear(M501SK_PIO io)
89{
90 uchar status = 0xff;
91 switch (io) {
92 case M501SK_DEBUG_LED1:
93 case M501SK_DEBUG_LED2:
94 case M501SK_DEBUG_LED3:
95 case M501SK_DEBUG_LED4:
96 case M501SK_READY_LED:
97 AT91C_BASE_PIOD->PIO_CODR = 1 << (io - 96);
98 status = AT91C_BASE_PIOD->PIO_ODSR & (1 << (io - 96));
99 break;
100 case M501SK_BUZZER:
101 AT91C_BASE_PIOB->PIO_CODR = 1 << (io - 32);
102 status = AT91C_BASE_PIOB->PIO_ODSR & (1 << (io - 32));
103 break;
104 }
105 return status;
106}
107
108void load_sernum_ethaddr(void)
109{
110 return;
111}
112
113/*
114 * Miscelaneous platform dependent initialisations
115 */
116DECLARE_GLOBAL_DATA_PTR;
117
118int board_init(void)
119{
120 /* Enable Ctrlc */
121 console_init_f();
122
123 /* Correct IRDA resistor problem */
124 /* Set PA23_TXD in Output */
125 ((AT91PS_PIO)AT91C_BASE_PIOA)->PIO_OER = AT91C_PA23_TXD2;
126
127 /* memory and cpu-speed are setup before relocation */
128 /* so we do _nothing_ here */
129 gd->bd->bi_arch_number = MACH_TYPE_M501;
130 /* adress of boot parameters */
131 gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
132 m501sk_gpio_init();
133
134 /* Do interrupt init here, because flash needs timers */
135 interrupt_init();
136 flash_init();
137
138 return 0;
139}
140
141int dram_init(void)
142{
143 int i = 0;
144 gd->bd->bi_dram[0].start = PHYS_SDRAM;
145 gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
146
147 for (i = 0; i < 500; i++) {
148 m501sk_gpio_clear(M501SK_DEBUG_LED3);
149 m501sk_gpio_clear(M501SK_BUZZER);
150 udelay(250);
151 m501sk_gpio_set(M501SK_DEBUG_LED3);
152 m501sk_gpio_set(M501SK_BUZZER);
153 udelay(80);
154 }
155 m501sk_gpio_clear(M501SK_BUZZER);
156 m501sk_gpio_clear(M501SK_DEBUG_LED3);
157
158 return 0;
159}
160
161int board_late_init(void)
162{
163#if defined(CONFIG_CMD_NET)
164 eth_init(gd->bd);
165 eth_halt();
166#endif
167
168 /* Protect U-Boot, kernel & ramdisk memory addresses */
169 run_command("protect on 10000000 1041ffff", 0);
170 return 0;
171}
172
173#ifdef CONFIG_DRIVER_ETHER
174#if defined(CONFIG_CMD_NET)
175/*
176 * Name:
177 * at91rm9200_GetPhyInterface
178 * Description:
179 * Initialise the interface functions to the PHY
180 * Arguments:
181 * None
182 * Return value:
183 * None
184 */
185void at91rm9200_GetPhyInterface(AT91PS_PhyOps p_phyops)
186{
187 p_phyops->Init = dm9161_InitPhy;
188 p_phyops->IsPhyConnected = dm9161_IsPhyConnected;
189 p_phyops->GetLinkSpeed = dm9161_GetLinkSpeed;
190 p_phyops->AutoNegotiate = dm9161_AutoNegotiate;
191}
192#endif /* CONFIG_CMD_NET */
193#endif /* CONFIG_DRIVER_ETHER */
194#endif /* CONFIG_M501SK */