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 | |
| 10 | #include <linux/types.h> |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/gpio.h> |
| 14 | #include <linux/micrel_phy.h> |
| 15 | #include <linux/of.h> |
| 16 | #include <linux/of_irq.h> |
| 17 | #include <linux/of_platform.h> |
| 18 | #include <linux/phy.h> |
Boris BREZILLON | d4d24c1 | 2013-10-11 14:43:31 +0200 | [diff] [blame] | 19 | #include <linux/clk-provider.h> |
Wenyou Yang | b865975 | 2014-12-11 15:31:09 +0800 | [diff] [blame] | 20 | #include <linux/phy.h> |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 21 | |
Nicolas Ferre | 6bd3e3f | 2015-01-27 15:51:34 +0100 | [diff] [blame] | 22 | #include <mach/hardware.h> |
| 23 | |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 24 | #include <asm/setup.h> |
| 25 | #include <asm/irq.h> |
| 26 | #include <asm/mach/arch.h> |
| 27 | #include <asm/mach/map.h> |
| 28 | #include <asm/mach/irq.h> |
| 29 | |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 30 | #include "generic.h" |
| 31 | |
Wenyou Yang | b865975 | 2014-12-11 15:31:09 +0800 | [diff] [blame] | 32 | static int ksz8081_phy_fixup(struct phy_device *phy) |
| 33 | { |
| 34 | int value; |
| 35 | |
| 36 | value = phy_read(phy, 0x16); |
| 37 | value &= ~0x20; |
| 38 | phy_write(phy, 0x16, value); |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 43 | static void __init sama5_dt_device_init(void) |
| 44 | { |
Wenyou Yang | b865975 | 2014-12-11 15:31:09 +0800 | [diff] [blame] | 45 | if (of_machine_is_compatible("atmel,sama5d4ek") && |
| 46 | IS_ENABLED(CONFIG_PHYLIB)) { |
| 47 | phy_register_fixup_for_id("fc028000.etherne:00", |
| 48 | ksz8081_phy_fixup); |
| 49 | } |
| 50 | |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 51 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
Nicolas Ferre | ad3fc3e | 2015-01-27 18:41:33 +0100 | [diff] [blame] | 52 | at91sam9x5_pm_init(); |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Nicolas Ferre | 726d32b | 2014-09-15 18:15:55 +0200 | [diff] [blame] | 55 | static const char *sama5_dt_board_compat[] __initconst = { |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 56 | "atmel,sama5", |
| 57 | NULL |
| 58 | }; |
| 59 | |
Nicolas Ferre | ad3fc3e | 2015-01-27 18:41:33 +0100 | [diff] [blame] | 60 | DT_MACHINE_START(sama5_dt, "Atmel SAMA5") |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 61 | /* Maintainer: Atmel */ |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 62 | .map_io = at91_map_io, |
Ludovic Desroches | 8f4b479 | 2013-03-22 13:24:12 +0000 | [diff] [blame] | 63 | .init_machine = sama5_dt_device_init, |
| 64 | .dt_compat = sama5_dt_board_compat, |
| 65 | MACHINE_END |
Nicolas Ferre | 726d32b | 2014-09-15 18:15:55 +0200 | [diff] [blame] | 66 | |
Nicolas Ferre | 6bd3e3f | 2015-01-27 15:51:34 +0100 | [diff] [blame] | 67 | static struct map_desc at91_io_desc[] __initdata = { |
| 68 | { |
| 69 | .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_MPDDRC), |
| 70 | .pfn = __phys_to_pfn(SAMA5D4_BASE_MPDDRC), |
| 71 | .length = SZ_512, |
| 72 | .type = MT_DEVICE, |
| 73 | }, |
| 74 | { |
| 75 | .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_PMC), |
| 76 | .pfn = __phys_to_pfn(SAMA5D4_BASE_PMC), |
| 77 | .length = SZ_512, |
| 78 | .type = MT_DEVICE, |
| 79 | }, |
| 80 | { /* On sama5d4, we use USART3 as serial console */ |
| 81 | .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_USART3), |
| 82 | .pfn = __phys_to_pfn(SAMA5D4_BASE_USART3), |
| 83 | .length = SZ_256, |
| 84 | .type = MT_DEVICE, |
| 85 | }, |
| 86 | { /* A bunch of peripheral with fine grained IO space */ |
| 87 | .virtual = (unsigned long)AT91_ALT_IO_P2V(SAMA5D4_BASE_SYS2), |
| 88 | .pfn = __phys_to_pfn(SAMA5D4_BASE_SYS2), |
| 89 | .length = SZ_2K, |
| 90 | .type = MT_DEVICE, |
| 91 | }, |
| 92 | }; |
| 93 | |
| 94 | static void __init sama5_alt_map_io(void) |
| 95 | { |
| 96 | at91_alt_map_io(); |
| 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 |