summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/setup.c
blob: 8962d9a1a8f6528da1b7f4871c480ed89dff6288 (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
/*
 * Copyright (C) 2007 Atmel Corporation.
 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
 *
 * Under GPLv2
 */

#include <linux/module.h>
#include <linux/io.h>

#include <asm/mach/map.h>

#include <mach/hardware.h>
#include <mach/cpu.h>

#include "soc.h"
#include "generic.h"

struct at91_soc __initdata at91_boot_soc;

void __init at91_init_irq_default(void)
{
	at91_init_interrupts(at91_boot_soc.default_irq_priority);
}

void __init at91_init_interrupts(unsigned int *priority)
{
	/* Initialize the AIC interrupt controller */
	at91_aic_init(priority);

	/* Enable GPIO interrupts */
	at91_gpio_irq_setup();
}

static struct map_desc at91_io_desc __initdata = {
	.virtual	= AT91_VA_BASE_SYS,
	.pfn		= __phys_to_pfn(AT91_BASE_SYS),
	.length		= SZ_16K,
	.type		= MT_DEVICE,
};

void __init at91_map_io(void)
{
	/* Map peripherals */
	iotable_init(&at91_io_desc, 1);

	if (cpu_is_at91cap9())
		at91_boot_soc = at91cap9_soc;
	else if (cpu_is_at91rm9200())
		at91_boot_soc = at91rm9200_soc;
	else if (cpu_is_at91sam9260())
		at91_boot_soc = at91sam9260_soc;
	else if (cpu_is_at91sam9261())
		at91_boot_soc = at91sam9261_soc;
	else if (cpu_is_at91sam9263())
		at91_boot_soc = at91sam9263_soc;
	else if (cpu_is_at91sam9g10())
		at91_boot_soc = at91sam9261_soc;
	else if (cpu_is_at91sam9g20())
		at91_boot_soc = at91sam9260_soc;
	else if (cpu_is_at91sam9g45())
		at91_boot_soc = at91sam9g45_soc;
	else if (cpu_is_at91sam9rl())
		at91_boot_soc = at91sam9rl_soc;
	else if (cpu_is_at91sam9x5())
		at91_boot_soc = at91sam9x5_soc;
	else
		panic("Impossible to detect the SOC type");

	if (at91_boot_soc.map_io)
		at91_boot_soc.map_io();
}

void __init at91_initialize(unsigned long main_clock)
{
	at91_boot_soc.init(main_clock);
}