summaryrefslogtreecommitdiffstats
path: root/arch/arm/boards/edb93xx/edb93xx.c
blob: b0078a522776d70393c629cbafa80a7443c6d41d (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
 * Copyright (C) 2009 Matthias Kaehlcke <matthias@kaehlcke.net>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * 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 <driver.h>
#include <environment.h>
#include <fs.h>
#include <init.h>
#include <partition.h>
#include <asm/armlinux.h>
#include <asm/io.h>
#include <asm/mach-types.h>
#include <mach/ep93xx-regs.h>
#include "edb93xx.h"

#define DEVCFG_U1EN (1 << 18)

/*
 * Up to 32MiB NOR type flash, connected to
 * CS line 6, data width is 16 bit
 */
static struct device_d cfi_dev = {
	.name     = "cfi_flash",
	.map_base = 0x60000000,
	.size     = EDB93XX_CFI_FLASH_SIZE,
};

static struct memory_platform_data ram_dev_pdata0 = {
	.name = "ram0",
	.flags = DEVFS_RDWR,
};

static struct device_d sdram0_dev = {
	.name     = "mem",
	.map_base = CONFIG_EP93XX_SDRAM_BANK0_BASE,
	.size     = CONFIG_EP93XX_SDRAM_BANK0_SIZE,
	.platform_data = &ram_dev_pdata0,
};

#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
static struct memory_platform_data ram_dev_pdata1 = {
	.name = "ram1",
	.flags = DEVFS_RDWR,
};

static struct device_d sdram1_dev = {
	.name     = "mem",
	.map_base = CONFIG_EP93XX_SDRAM_BANK1_BASE,
	.size     = CONFIG_EP93XX_SDRAM_BANK1_SIZE,
	.platform_data = &ram_dev_pdata1,
};
#endif

#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
static struct memory_platform_data ram_dev_pdata2 = {
	.name = "ram2",
	.flags = DEVFS_RDWR,
};

static struct device_d sdram2_dev = {
	.name     = "mem",
	.map_base = CONFIG_EP93XX_SDRAM_BANK2_BASE,
	.size     = CONFIG_EP93XX_SDRAM_BANK2_SIZE,
	.platform_data = &ram_dev_pdata2,
};
#endif

#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
static struct memory_platform_data ram_dev_pdata3 = {
	.name = "ram3",
	.flags = DEVFS_RDWR,
};

static struct device_d sdram3_dev = {
	.name     = "mem",
	.map_base = CONFIG_EP93XX_SDRAM_BANK3_BASE,
	.size     = CONFIG_EP93XX_SDRAM_BANK3_SIZE,
	.platform_data = &ram_dev_pdata3,
};
#endif

static struct device_d eth_dev = {
	.name     = "ep93xx_eth",
};

static int ep93xx_devices_init(void)
{
	register_device(&cfi_dev);

	/*
	 * Create partitions that should be
	 * not touched by any regular user
	 */
	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
	devfs_add_partition("nor0", 0x40000, 0x20000, PARTITION_FIXED, "env0");

	protect_file("/dev/env0", 1);

	register_device(&sdram0_dev);
#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
	register_device(&sdram1_dev);
#endif
#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
	register_device(&sdram2_dev);
#endif
#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
	register_device(&sdram3_dev);
#endif

	armlinux_add_dram(&sdram0_dev);
#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 2)
	armlinux_add_dram(&sdram1_dev);
#endif
#if (CONFIG_EP93XX_SDRAM_NUM_BANKS >= 3)
	armlinux_add_dram(&sdram2_dev);
#endif
#if (CONFIG_EP93XX_SDRAM_NUM_BANKS == 4)
	armlinux_add_dram(&sdram3_dev);
#endif

	register_device(&eth_dev);

	armlinux_set_bootparams((void *)CONFIG_EP93XX_SDRAM_BANK0_BASE + 0x100);

	armlinux_set_architecture(MACH_TYPE);

	return 0;
}

device_initcall(ep93xx_devices_init);

static struct device_d edb93xx_serial_device = {
	.name     = "pl010_serial",
	.map_base = UART1_BASE,
	.size     = 4096,
};

static int edb93xx_console_init(void)
{
	struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE;

	/*
	 * set UARTBAUD bit to drive UARTs with 14.7456MHz instead of
	 * 14.7456/2 MHz
	 */
	uint32_t value = readl(&syscon->pwrcnt);
	value |= SYSCON_PWRCNT_UART_BAUD;
	writel(value, &syscon->pwrcnt);

	/* Enable UART1 */
	value = readl(&syscon->devicecfg);
	value |= DEVCFG_U1EN;
	writel(0xAA, &syscon->sysswlock);
	writel(value, &syscon->devicecfg);

	register_device(&edb93xx_serial_device);

	return 0;
}

console_initcall(edb93xx_console_init);