Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 1 | /* |
Nicolas Ferre | cac0172 | 2015-01-27 16:41:55 +0100 | [diff] [blame] | 2 | * Setup code for SAMA5 |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2013 Atmel, |
| 5 | * 2013 Ludovic Desroches <ludovic.desroches@atmel.com> |
| 6 | * |
| 7 | * Licensed under GPLv2 or later. |
| 8 | */ |
| 9 | |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 10 | #include <linux/of.h> |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 11 | #include <linux/of_platform.h> |
Alexandre Belloni | e733608 | 2015-03-12 15:54:30 +0100 | [diff] [blame^] | 12 | |
| 13 | #include <asm/mach/arch.h> |
| 14 | #include <asm/mach/map.h> |
| 15 | #include <asm/system_misc.h> |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 16 | |
Nicolas Ferre | 6bd3e3f | 2015-01-27 15:51:34 +0100 | [diff] [blame] | 17 | #include <mach/hardware.h> |
| 18 | |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 19 | #include "generic.h" |
Alexandre Belloni | e733608 | 2015-03-12 15:54:30 +0100 | [diff] [blame^] | 20 | #include "soc.h" |
| 21 | |
| 22 | static 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 Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 43 | |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 44 | static void __init sama5_dt_device_init(void) |
| 45 | { |
Alexandre Belloni | e733608 | 2015-03-12 15:54:30 +0100 | [diff] [blame^] | 46 | 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 Ferre | ad3fc3e | 2015-01-27 18:41:33 +0100 | [diff] [blame] | 54 | at91sam9x5_pm_init(); |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 55 | } |
| 56 | |
Nicolas Ferre | 726d32b | 2014-09-15 18:15:55 +0200 | [diff] [blame] | 57 | static const char *sama5_dt_board_compat[] __initconst = { |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 58 | "atmel,sama5", |
| 59 | NULL |
| 60 | }; |
| 61 | |
Nicolas Ferre | ad3fc3e | 2015-01-27 18:41:33 +0100 | [diff] [blame] | 62 | DT_MACHINE_START(sama5_dt, "Atmel SAMA5") |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 63 | /* Maintainer: Atmel */ |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 64 | .init_machine = sama5_dt_device_init, |
| 65 | .dt_compat = sama5_dt_board_compat, |
| 66 | MACHINE_END |
Nicolas Ferre | 726d32b | 2014-09-15 18:15:55 +0200 | [diff] [blame] | 67 | |
Nicolas Ferre | 6bd3e3f | 2015-01-27 15:51:34 +0100 | [diff] [blame] | 68 | static 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 | |
| 95 | static void __init sama5_alt_map_io(void) |
| 96 | { |
Nicolas Ferre | 6bd3e3f | 2015-01-27 15:51:34 +0100 | [diff] [blame] | 97 | iotable_init(at91_io_desc, ARRAY_SIZE(at91_io_desc)); |
| 98 | } |
| 99 | |
Nicolas Ferre | 726d32b | 2014-09-15 18:15:55 +0200 | [diff] [blame] | 100 | static const char *sama5_alt_dt_board_compat[] __initconst = { |
| 101 | "atmel,sama5d4", |
| 102 | NULL |
| 103 | }; |
| 104 | |
Nicolas Ferre | ad3fc3e | 2015-01-27 18:41:33 +0100 | [diff] [blame] | 105 | DT_MACHINE_START(sama5_alt_dt, "Atmel SAMA5") |
Nicolas Ferre | 726d32b | 2014-09-15 18:15:55 +0200 | [diff] [blame] | 106 | /* Maintainer: Atmel */ |
Nicolas Ferre | 6bd3e3f | 2015-01-27 15:51:34 +0100 | [diff] [blame] | 107 | .map_io = sama5_alt_map_io, |
Nicolas Ferre | 726d32b | 2014-09-15 18:15:55 +0200 | [diff] [blame] | 108 | .init_machine = sama5_dt_device_init, |
| 109 | .dt_compat = sama5_alt_dt_board_compat, |
| 110 | .l2c_aux_mask = ~0UL, |
| 111 | MACHINE_END |