summaryrefslogtreecommitdiffstats
path: root/arch/nios2/boards/generic/generic.c
blob: 499d93bdab1063a1c447185b4ac30094f5a9d876 (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
#include <common.h>
#include <init.h>
#include <driver.h>
#include <partition.h>
#include <fs.h>
#include <memory.h>

static int phy_address = 1;

static struct resource mac_resources[] = {
	[0] = {
		.start	= NIOS_SOPC_TSE_BASE,
		.end	= NIOS_SOPC_TSE_BASE + 0x400 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= NIOS_SOPC_SGDMA_RX_BASE,
		.end	= 0x40 + NIOS_SOPC_SGDMA_RX_BASE - 1,
		.flags	= IORESOURCE_MEM,
	},
	[2] = {
		.start	= NIOS_SOPC_SGDMA_TX_BASE,
		.end	= 0x40 + NIOS_SOPC_SGDMA_TX_BASE - 1,
		.flags	= IORESOURCE_MEM,
	},
};

static struct device_d mac_dev = {
	.id            = DEVICE_ID_DYNAMIC,
	.name          = "altera_tse",
	.num_resources = ARRAY_SIZE(mac_resources),
	.resource      = mac_resources,
	.platform_data = &phy_address,
};

static int mem_init(void)
{
	barebox_add_memory_bank("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE);

	return 0;
}
mem_initcall(mem_init);

static int generic_devices_init(void)
{
	add_cfi_flash_device(DEVICE_ID_DYNAMIC, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
	platform_device_register(&mac_dev);
	/*register_device(&epcs_flash_device);*/

	devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0");
	devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");

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

	return 0;
}

device_initcall(generic_devices_init);


static int altera_console_init(void)
{
	add_generic_device("altera_serial", DEVICE_ID_DYNAMIC, NULL,
			NIOS_SOPC_UART_BASE, 0x20, IORESOURCE_MEM, NULL);

	return 0;
}

console_initcall(altera_console_init);