summaryrefslogtreecommitdiffstats
path: root/board/mmccpu/init.c
blob: d8f9a5d79e046405338af1709c9ba38792e51eab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
 * Copyright (C) 2007 Sascha Hauer, Pengutronix
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 *
 */

#include <common.h>
#include <net.h>
#include <cfi_flash.h>
#include <init.h>
#include <environment.h>
#include <fec.h>
#include <asm/armlinux.h>
#include <asm/mach-types.h>
#include <partition.h>
#include <fs.h>
#include <fcntl.h>
#include <asm/io.h>
#include <asm/hardware.h>
#include <nand.h>
#include <linux/mtd/nand.h>
#include <asm/arch/ether.h>

static struct device_d sdram_dev = {
	.name		= "ram",
	.id		= "ram0",

	.map_base	= 0x20000000,
	.size		= 128 * 1024 * 1024,

	.type		= DEVICE_TYPE_DRAM,
};

static struct device_d cfi_dev = {
	.name		= "cfi_flash",
	.id		= "nor0",

	.map_base	= 0x10000000,
	.size		= 0,	/* zero means autodetect size */
};

static struct at91sam_ether_platform_data macb_pdata = {
	.flags		= AT91SAM_ETHER_MII | AT91SAM_ETHER_FORCE_LINK,
	.phy_addr	= 4,
};

static struct device_d macb_dev = {
	.name		= "macb",
	.id		= "eth0",
	.map_base	= AT91C_BASE_MACB,
	.size		= 0x1000,
	.type		= DEVICE_TYPE_ETHER,
	.platform_data	= &macb_pdata,
};

static int mmccpu_devices_init(void)
{
	u32 pe = AT91C_PC25_ERXDV |
		AT91C_PC22_ERX2 |
		AT91C_PC23_ERX3 |
		AT91C_PC20_ETX2 |
		AT91C_PC21_ETX3;

	writel(pe, AT91C_BASE_PIOC + PIO_BSR(0));
	writel(pe, AT91C_BASE_PIOC + PIO_PDR(0));

	pe = AT91C_PE21_ETXCK |
		AT91C_PE23_ETX0 |
		AT91C_PE24_ETX1 |
		AT91C_PE25_ERX0 |
		AT91C_PE26_ERX1 |
		AT91C_PE27_ERXER |
		AT91C_PE28_ETXEN |
		AT91C_PE29_EMDC |
		AT91C_PE30_EMDIO;

	writel(pe, AT91C_BASE_PIOE + PIO_ASR(0));
	writel(pe, AT91C_BASE_PIOE + PIO_PDR(0));

	/* set PB27 to '1', enable 50MHz oscillator */
	writel(AT91C_PIO_PB27, AT91C_BASE_PIOB + PIO_PER(0));
	writel(AT91C_PIO_PB27, AT91C_BASE_PIOB + PIO_OER(0));
	writel(AT91C_PIO_PB27, AT91C_BASE_PIOB + PIO_SODR(0));

	/* set PB4, PB5 to '1', enable 50MHz oscillator */
	writel(AT91C_PIO_PB4|AT91C_PIO_PB5, AT91C_BASE_PIOB + PIO_PER(0));
	writel(AT91C_PIO_PB4|AT91C_PIO_PB5, AT91C_BASE_PIOB + PIO_OER(0));
	writel(AT91C_PIO_PB4|AT91C_PIO_PB5, AT91C_BASE_PIOB + PIO_SODR(0));

	writel(1 << AT91C_ID_EMAC, AT91C_PMC_PCER);

	register_device(&sdram_dev);
	register_device(&macb_dev);
	register_device(&cfi_dev);

	dev_add_partition(&cfi_dev, 0x00000, 256 * 1024, PARTITION_FIXED, "self");
	dev_add_partition(&cfi_dev, 0x40000, 128 * 1024, PARTITION_FIXED, "env");

	armlinux_set_bootparams((void *)0x20000100);
	armlinux_set_architecture(MACH_TYPE_MMCCPU);

	return 0;
}

device_initcall(mmccpu_devices_init);

static struct device_d mmccpu_serial_device = {
	.name		= "atmel_serial",
	.id		= "cs0",
	.map_base	= AT91C_BASE_DBGU,
	.size		= 4096,
	.type		= DEVICE_TYPE_CONSOLE,
};

static int mmccpu_console_init(void)
{
	writel(AT91C_PC31_DTXD | AT91C_PC30_DRXD, AT91C_PIOC_PDR);

	register_device(&mmccpu_serial_device);
	return 0;
}

console_initcall(mmccpu_console_init);