Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net> |
| 3 | * |
| 4 | * arch/arm/mach-kirkwood/board-dt.c |
| 5 | * |
Jason Cooper | 6fa6b87 | 2012-03-15 00:52:31 +0000 | [diff] [blame] | 6 | * Flattened Device Tree board initialization |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 7 | * |
| 8 | * This file is licensed under the terms of the GNU General Public |
| 9 | * License version 2. This program is licensed "as is" without any |
| 10 | * warranty of any kind, whether express or implied. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 15 | #include <linux/of.h> |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 16 | #include <linux/of_platform.h> |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 17 | #include <linux/clk-provider.h> |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame] | 18 | #include <linux/clocksource.h> |
| 19 | #include <linux/dma-mapping.h> |
| 20 | #include <linux/irqchip.h> |
Ian Campbell | a7ac56d | 2012-04-29 14:40:42 +0100 | [diff] [blame] | 21 | #include <linux/kexec.h> |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 22 | #include <asm/mach/arch.h> |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 23 | #include <asm/mach/map.h> |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 24 | #include <mach/bridge-regs.h> |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 25 | #include <linux/platform_data/usb-ehci-orion.h> |
Andrew Lunn | 278b45b | 2012-06-27 13:40:04 +0200 | [diff] [blame] | 26 | #include <plat/irq.h> |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 27 | #include <plat/common.h> |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 28 | #include "common.h" |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 29 | |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 30 | /* |
| 31 | * There are still devices that doesn't know about DT yet. Get clock |
| 32 | * gates here and add a clock lookup alias, so that old platform |
| 33 | * devices still work. |
| 34 | */ |
| 35 | |
| 36 | static void __init kirkwood_legacy_clk_init(void) |
| 37 | { |
| 38 | |
| 39 | struct device_node *np = of_find_compatible_node( |
| 40 | NULL, NULL, "marvell,kirkwood-gating-clock"); |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 41 | struct of_phandle_args clkspec; |
Sebastian Hesselbarth | 7bf5b40 | 2013-01-30 21:29:58 +0100 | [diff] [blame] | 42 | struct clk *clk; |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 43 | |
| 44 | clkspec.np = np; |
| 45 | clkspec.args_count = 1; |
| 46 | |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 47 | clkspec.args[0] = CGC_BIT_PEX0; |
| 48 | orion_clkdev_add("0", "pcie", |
| 49 | of_clk_get_from_provider(&clkspec)); |
| 50 | |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 51 | clkspec.args[0] = CGC_BIT_PEX1; |
| 52 | orion_clkdev_add("1", "pcie", |
| 53 | of_clk_get_from_provider(&clkspec)); |
| 54 | |
Sebastian Hesselbarth | 7bf5b40 | 2013-01-30 21:29:58 +0100 | [diff] [blame] | 55 | /* |
| 56 | * The ethernet interfaces forget the MAC address assigned by |
| 57 | * u-boot if the clocks are turned off. Until proper DT support |
| 58 | * is available we always enable them for now. |
| 59 | */ |
| 60 | clkspec.args[0] = CGC_BIT_GE0; |
| 61 | clk = of_clk_get_from_provider(&clkspec); |
Sebastian Hesselbarth | 7bf5b40 | 2013-01-30 21:29:58 +0100 | [diff] [blame] | 62 | clk_prepare_enable(clk); |
| 63 | |
| 64 | clkspec.args[0] = CGC_BIT_GE1; |
| 65 | clk = of_clk_get_from_provider(&clkspec); |
Sebastian Hesselbarth | 7bf5b40 | 2013-01-30 21:29:58 +0100 | [diff] [blame] | 66 | clk_prepare_enable(clk); |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 67 | } |
| 68 | |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame] | 69 | static void __init kirkwood_dt_time_init(void) |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 70 | { |
Sebastian Hesselbarth | ed9f30a | 2013-05-11 03:08:08 +0200 | [diff] [blame] | 71 | of_clk_init(NULL); |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame] | 72 | clocksource_of_init(); |
| 73 | } |
| 74 | |
| 75 | static void __init kirkwood_dt_init_early(void) |
| 76 | { |
| 77 | mvebu_mbus_init("marvell,kirkwood-mbus", |
| 78 | BRIDGE_WINS_BASE, BRIDGE_WINS_SZ, |
| 79 | DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ); |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 80 | } |
Michael Walle | 7637212 | 2012-06-06 20:30:57 +0200 | [diff] [blame] | 81 | |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 82 | static void __init kirkwood_dt_init(void) |
| 83 | { |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 84 | pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk); |
| 85 | |
| 86 | /* |
| 87 | * Disable propagation of mbus errors to the CPU local bus, |
| 88 | * as this causes mbus errors (which can occur for example |
| 89 | * for PCI aborts) to throw CPU aborts, which we're not set |
| 90 | * up to deal with. |
| 91 | */ |
| 92 | writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG); |
| 93 | |
Thomas Petazzoni | 5cc0673 | 2013-03-21 17:59:16 +0100 | [diff] [blame] | 94 | kirkwood_setup_wins(); |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 95 | |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 96 | kirkwood_l2_init(); |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 97 | |
Andrew Lunn | 0e2ee0c | 2013-01-27 11:07:23 +0100 | [diff] [blame] | 98 | kirkwood_cpufreq_init(); |
| 99 | |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame] | 100 | /* Setup clocks for legacy devices */ |
| 101 | kirkwood_legacy_clk_init(); |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 102 | |
Andrew Lunn | 9cfc94e | 2013-01-09 13:22:15 +0100 | [diff] [blame] | 103 | kirkwood_cpuidle_init(); |
| 104 | |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 105 | #ifdef CONFIG_KEXEC |
| 106 | kexec_reinit = kirkwood_enable_pcie; |
| 107 | #endif |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 108 | |
Jamie Lentin | 9007d10 | 2012-04-18 11:06:40 +0100 | [diff] [blame] | 109 | if (of_machine_is_compatible("dlink,dns-kirkwood")) |
| 110 | dnskw_init(); |
| 111 | |
Thomas Petazzoni | 37ae08c | 2013-08-01 17:07:32 +0200 | [diff] [blame^] | 112 | if (of_machine_is_compatible("marvell,mv88f6281gtw-ge")) |
| 113 | mv88f6281gtw_ge_init(); |
| 114 | |
Thomas Petazzoni | 3207792 | 2013-05-15 16:04:59 +0200 | [diff] [blame] | 115 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Andrew Lunn | 98adf93 | 2012-10-20 13:23:16 +0200 | [diff] [blame] | 118 | static const char * const kirkwood_dt_board_compat[] = { |
Sebastian Hesselbarth | a977e18 | 2013-07-03 18:57:51 +0200 | [diff] [blame] | 119 | "marvell,kirkwood", |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 120 | NULL |
| 121 | }; |
| 122 | |
| 123 | DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)") |
| 124 | /* Maintainer: Jason Cooper <jason@lakedaemon.net> */ |
| 125 | .map_io = kirkwood_map_io, |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame] | 126 | .init_early = kirkwood_dt_init_early, |
| 127 | .init_time = kirkwood_dt_time_init, |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 128 | .init_machine = kirkwood_dt_init, |
| 129 | .restart = kirkwood_restart, |
| 130 | .dt_compat = kirkwood_dt_board_compat, |
| 131 | MACHINE_END |