blob: 5b13ad7c82ef5987569d9c1fd1f75e88738eaede [file] [log] [blame]
Ludovic Desroches8f4b4792013-03-22 13:24:12 +00001/*
Nicolas Ferrecac01722015-01-27 16:41:55 +01002 * Setup code for SAMA5
Ludovic Desroches8f4b4792013-03-22 13:24:12 +00003 *
4 * Copyright (C) 2013 Atmel,
5 * 2013 Ludovic Desroches <ludovic.desroches@atmel.com>
6 *
7 * Licensed under GPLv2 or later.
8 */
9
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000010#include <linux/of.h>
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000011#include <linux/of_platform.h>
Alexandre Bellonie7336082015-03-12 15:54:30 +010012
13#include <asm/mach/arch.h>
14#include <asm/mach/map.h>
15#include <asm/system_misc.h>
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000016
Nicolas Ferre6bd3e3f2015-01-27 15:51:34 +010017#include <mach/hardware.h>
18
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000019#include "generic.h"
Alexandre Bellonie7336082015-03-12 15:54:30 +010020#include "soc.h"
21
22static const struct at91_soc sama5_socs[] = {
23 AT91_SOC(SAMA5D3_CIDR_MATCH, SAMA5D31_EXID_MATCH,
24 "sama5d31", "sama5d3"),
25 AT91_SOC(SAMA5D3_CIDR_MATCH, SAMA5D33_EXID_MATCH,
26 "sama5d33", "sama5d3"),
27 AT91_SOC(SAMA5D3_CIDR_MATCH, SAMA5D34_EXID_MATCH,
28 "sama5d34", "sama5d3"),
29 AT91_SOC(SAMA5D3_CIDR_MATCH, SAMA5D35_EXID_MATCH,
30 "sama5d35", "sama5d3"),
31 AT91_SOC(SAMA5D3_CIDR_MATCH, SAMA5D36_EXID_MATCH,
32 "sama5d36", "sama5d3"),
33 AT91_SOC(SAMA5D4_CIDR_MATCH, SAMA5D41_EXID_MATCH,
34 "sama5d41", "sama5d4"),
35 AT91_SOC(SAMA5D4_CIDR_MATCH, SAMA5D42_EXID_MATCH,
36 "sama5d42", "sama5d4"),
37 AT91_SOC(SAMA5D4_CIDR_MATCH, SAMA5D43_EXID_MATCH,
38 "sama5d43", "sama5d4"),
39 AT91_SOC(SAMA5D4_CIDR_MATCH, SAMA5D44_EXID_MATCH,
40 "sama5d44", "sama5d4"),
41 { /* sentinel */ },
42};
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000043
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000044static void __init sama5_dt_device_init(void)
45{
Alexandre Bellonie7336082015-03-12 15:54:30 +010046 struct soc_device *soc;
47 struct device *soc_dev = NULL;
48
49 soc = at91_soc_init(sama5_socs);
50 if (soc != NULL)
51 soc_dev = soc_device_to_device(soc);
52
53 of_platform_populate(NULL, of_default_bus_match_table, NULL, soc_dev);
Nicolas Ferread3fc3e2015-01-27 18:41:33 +010054 at91sam9x5_pm_init();
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000055}
56
Nicolas Ferre726d32b2014-09-15 18:15:55 +020057static const char *sama5_dt_board_compat[] __initconst = {
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000058 "atmel,sama5",
59 NULL
60};
61
Nicolas Ferread3fc3e2015-01-27 18:41:33 +010062DT_MACHINE_START(sama5_dt, "Atmel SAMA5")
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000063 /* Maintainer: Atmel */
Ludovic Desroches8f4b4792013-03-22 13:24:12 +000064 .init_machine = sama5_dt_device_init,
65 .dt_compat = sama5_dt_board_compat,
66MACHINE_END
Nicolas Ferre726d32b2014-09-15 18:15:55 +020067
Nicolas Ferre6bd3e3f2015-01-27 15:51:34 +010068static struct map_desc at91_io_desc[] __initdata = {
69 {
70 .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_MPDDRC),
71 .pfn = __phys_to_pfn(SAMA5D4_BASE_MPDDRC),
72 .length = SZ_512,
73 .type = MT_DEVICE,
74 },
75 {
76 .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_PMC),
77 .pfn = __phys_to_pfn(SAMA5D4_BASE_PMC),
78 .length = SZ_512,
79 .type = MT_DEVICE,
80 },
81 { /* On sama5d4, we use USART3 as serial console */
82 .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_USART3),
83 .pfn = __phys_to_pfn(SAMA5D4_BASE_USART3),
84 .length = SZ_256,
85 .type = MT_DEVICE,
86 },
87 { /* A bunch of peripheral with fine grained IO space */
88 .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_SYS2),
89 .pfn = __phys_to_pfn(SAMA5D4_BASE_SYS2),
90 .length = SZ_2K,
91 .type = MT_DEVICE,
92 },
93};
94
95static void __init sama5_alt_map_io(void)
96{
Nicolas Ferre6bd3e3f2015-01-27 15:51:34 +010097 iotable_init(at91_io_desc, ARRAY_SIZE(at91_io_desc));
98}
99
Nicolas Ferre726d32b2014-09-15 18:15:55 +0200100static const char *sama5_alt_dt_board_compat[] __initconst = {
101 "atmel,sama5d4",
102 NULL
103};
104
Nicolas Ferread3fc3e2015-01-27 18:41:33 +0100105DT_MACHINE_START(sama5_alt_dt, "Atmel SAMA5")
Nicolas Ferre726d32b2014-09-15 18:15:55 +0200106 /* Maintainer: Atmel */
Nicolas Ferre6bd3e3f2015-01-27 15:51:34 +0100107 .map_io = sama5_alt_map_io,
Nicolas Ferre726d32b2014-09-15 18:15:55 +0200108 .init_machine = sama5_dt_device_init,
109 .dt_compat = sama5_alt_dt_board_compat,
110 .l2c_aux_mask = ~0UL,
111MACHINE_END