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 | clkspec.args[0] = CGC_BIT_SDIO; |
| 56 | orion_clkdev_add(NULL, "mvsdio", |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 57 | of_clk_get_from_provider(&clkspec)); |
Sebastian Hesselbarth | 7bf5b40 | 2013-01-30 21:29:58 +0100 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * The ethernet interfaces forget the MAC address assigned by |
| 61 | * u-boot if the clocks are turned off. Until proper DT support |
| 62 | * is available we always enable them for now. |
| 63 | */ |
| 64 | clkspec.args[0] = CGC_BIT_GE0; |
| 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); |
| 67 | |
| 68 | clkspec.args[0] = CGC_BIT_GE1; |
| 69 | clk = of_clk_get_from_provider(&clkspec); |
Sebastian Hesselbarth | 7bf5b40 | 2013-01-30 21:29:58 +0100 | [diff] [blame] | 70 | clk_prepare_enable(clk); |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 71 | } |
| 72 | |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame^] | 73 | static void __init kirkwood_dt_time_init(void) |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 74 | { |
Sebastian Hesselbarth | ed9f30a | 2013-05-11 03:08:08 +0200 | [diff] [blame] | 75 | of_clk_init(NULL); |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame^] | 76 | clocksource_of_init(); |
| 77 | } |
| 78 | |
| 79 | static void __init kirkwood_dt_init_early(void) |
| 80 | { |
| 81 | mvebu_mbus_init("marvell,kirkwood-mbus", |
| 82 | BRIDGE_WINS_BASE, BRIDGE_WINS_SZ, |
| 83 | DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ); |
Andrew Lunn | 1611f87 | 2012-11-17 15:22:28 +0100 | [diff] [blame] | 84 | } |
Michael Walle | 7637212 | 2012-06-06 20:30:57 +0200 | [diff] [blame] | 85 | |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 86 | static void __init kirkwood_dt_init(void) |
| 87 | { |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 88 | pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk); |
| 89 | |
| 90 | /* |
| 91 | * Disable propagation of mbus errors to the CPU local bus, |
| 92 | * as this causes mbus errors (which can occur for example |
| 93 | * for PCI aborts) to throw CPU aborts, which we're not set |
| 94 | * up to deal with. |
| 95 | */ |
| 96 | writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG); |
| 97 | |
Thomas Petazzoni | 5cc0673 | 2013-03-21 17:59:16 +0100 | [diff] [blame] | 98 | kirkwood_setup_wins(); |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 99 | |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 100 | kirkwood_l2_init(); |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 101 | |
Andrew Lunn | 0e2ee0c | 2013-01-27 11:07:23 +0100 | [diff] [blame] | 102 | kirkwood_cpufreq_init(); |
| 103 | |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame^] | 104 | /* Setup clocks for legacy devices */ |
| 105 | kirkwood_legacy_clk_init(); |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 106 | |
Andrew Lunn | 9cfc94e | 2013-01-09 13:22:15 +0100 | [diff] [blame] | 107 | kirkwood_cpuidle_init(); |
| 108 | |
Jason Cooper | 2b45e05 | 2012-02-29 17:39:08 +0000 | [diff] [blame] | 109 | #ifdef CONFIG_KEXEC |
| 110 | kexec_reinit = kirkwood_enable_pcie; |
| 111 | #endif |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 112 | |
Jamie Lentin | 9007d10 | 2012-04-18 11:06:40 +0100 | [diff] [blame] | 113 | if (of_machine_is_compatible("dlink,dns-kirkwood")) |
| 114 | dnskw_init(); |
| 115 | |
Thomas Petazzoni | 3207792 | 2013-05-15 16:04:59 +0200 | [diff] [blame] | 116 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 117 | } |
| 118 | |
Andrew Lunn | 98adf93 | 2012-10-20 13:23:16 +0200 | [diff] [blame] | 119 | static const char * const kirkwood_dt_board_compat[] = { |
Sebastian Hesselbarth | a977e18 | 2013-07-03 18:57:51 +0200 | [diff] [blame] | 120 | "marvell,kirkwood", |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 121 | NULL |
| 122 | }; |
| 123 | |
| 124 | DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)") |
| 125 | /* Maintainer: Jason Cooper <jason@lakedaemon.net> */ |
| 126 | .map_io = kirkwood_map_io, |
Sebastian Hesselbarth | 2326f04 | 2013-07-02 15:15:07 +0200 | [diff] [blame^] | 127 | .init_early = kirkwood_dt_init_early, |
| 128 | .init_time = kirkwood_dt_time_init, |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 129 | .init_machine = kirkwood_dt_init, |
| 130 | .restart = kirkwood_restart, |
| 131 | .dt_compat = kirkwood_dt_board_compat, |
| 132 | MACHINE_END |