viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-spear6xx/spear6xx.c |
| 3 | * |
| 4 | * SPEAr6XX machines common source file |
| 5 | * |
| 6 | * Copyright (C) 2009 ST Microelectronics |
| 7 | * Rajeev Kumar<rajeev-dlh.kumar@st.com> |
| 8 | * |
Stefan Roese | 9652e8b | 2012-03-16 14:03:23 +0100 | [diff] [blame] | 9 | * Copyright 2012 Stefan Roese <sr@denx.de> |
| 10 | * |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 11 | * This file is licensed under the terms of the GNU General Public |
| 12 | * License version 2. This program is licensed "as is" without any |
| 13 | * warranty of any kind, whether express or implied. |
| 14 | */ |
| 15 | |
Stefan Roese | 9652e8b | 2012-03-16 14:03:23 +0100 | [diff] [blame] | 16 | #include <linux/of.h> |
| 17 | #include <linux/of_address.h> |
| 18 | #include <linux/of_irq.h> |
| 19 | #include <linux/of_platform.h> |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 20 | #include <asm/hardware/vic.h> |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 21 | #include <asm/mach/arch.h> |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 22 | #include <mach/generic.h> |
viresh kumar | 02aa06b | 2011-03-07 05:57:02 +0100 | [diff] [blame] | 23 | #include <mach/hardware.h> |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 24 | |
| 25 | /* Following will create static virtual/physical mappings */ |
| 26 | static struct map_desc spear6xx_io_desc[] __initdata = { |
| 27 | { |
| 28 | .virtual = VA_SPEAR6XX_ICM1_UART0_BASE, |
| 29 | .pfn = __phys_to_pfn(SPEAR6XX_ICM1_UART0_BASE), |
viresh kumar | 5382116 | 2011-03-07 05:57:06 +0100 | [diff] [blame] | 30 | .length = SZ_4K, |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 31 | .type = MT_DEVICE |
| 32 | }, { |
| 33 | .virtual = VA_SPEAR6XX_CPU_VIC_PRI_BASE, |
| 34 | .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_PRI_BASE), |
viresh kumar | 5382116 | 2011-03-07 05:57:06 +0100 | [diff] [blame] | 35 | .length = SZ_4K, |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 36 | .type = MT_DEVICE |
| 37 | }, { |
| 38 | .virtual = VA_SPEAR6XX_CPU_VIC_SEC_BASE, |
| 39 | .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_SEC_BASE), |
viresh kumar | 5382116 | 2011-03-07 05:57:06 +0100 | [diff] [blame] | 40 | .length = SZ_4K, |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 41 | .type = MT_DEVICE |
| 42 | }, { |
| 43 | .virtual = VA_SPEAR6XX_ICM3_SYS_CTRL_BASE, |
| 44 | .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SYS_CTRL_BASE), |
viresh kumar | 5382116 | 2011-03-07 05:57:06 +0100 | [diff] [blame] | 45 | .length = SZ_4K, |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 46 | .type = MT_DEVICE |
| 47 | }, { |
| 48 | .virtual = VA_SPEAR6XX_ICM3_MISC_REG_BASE, |
| 49 | .pfn = __phys_to_pfn(SPEAR6XX_ICM3_MISC_REG_BASE), |
viresh kumar | 5382116 | 2011-03-07 05:57:06 +0100 | [diff] [blame] | 50 | .length = SZ_4K, |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 51 | .type = MT_DEVICE |
| 52 | }, |
| 53 | }; |
| 54 | |
| 55 | /* This will create static memory mapping for selected devices */ |
| 56 | void __init spear6xx_map_io(void) |
| 57 | { |
| 58 | iotable_init(spear6xx_io_desc, ARRAY_SIZE(spear6xx_io_desc)); |
| 59 | |
| 60 | /* This will initialize clock framework */ |
viresh kumar | b997f6e | 2011-05-20 08:34:18 +0100 | [diff] [blame] | 61 | spear6xx_clk_init(); |
viresh kumar | 8f590d4 | 2010-04-01 12:31:01 +0100 | [diff] [blame] | 62 | } |
Shiraz Hashim | 5c881d9 | 2011-02-16 07:40:32 +0100 | [diff] [blame] | 63 | |
| 64 | static void __init spear6xx_timer_init(void) |
| 65 | { |
| 66 | char pclk_name[] = "pll3_48m_clk"; |
| 67 | struct clk *gpt_clk, *pclk; |
| 68 | |
| 69 | /* get the system timer clock */ |
| 70 | gpt_clk = clk_get_sys("gpt0", NULL); |
| 71 | if (IS_ERR(gpt_clk)) { |
| 72 | pr_err("%s:couldn't get clk for gpt\n", __func__); |
| 73 | BUG(); |
| 74 | } |
| 75 | |
| 76 | /* get the suitable parent clock for timer*/ |
| 77 | pclk = clk_get(NULL, pclk_name); |
| 78 | if (IS_ERR(pclk)) { |
| 79 | pr_err("%s:couldn't get %s as parent for gpt\n", |
| 80 | __func__, pclk_name); |
| 81 | BUG(); |
| 82 | } |
| 83 | |
| 84 | clk_set_parent(gpt_clk, pclk); |
| 85 | clk_put(gpt_clk); |
| 86 | clk_put(pclk); |
| 87 | |
| 88 | spear_setup_timer(); |
| 89 | } |
| 90 | |
| 91 | struct sys_timer spear6xx_timer = { |
| 92 | .init = spear6xx_timer_init, |
| 93 | }; |
Stefan Roese | 9652e8b | 2012-03-16 14:03:23 +0100 | [diff] [blame] | 94 | |
| 95 | static void __init spear600_dt_init(void) |
| 96 | { |
| 97 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); |
| 98 | } |
| 99 | |
| 100 | static const char *spear600_dt_board_compat[] = { |
| 101 | "st,spear600", |
| 102 | NULL |
| 103 | }; |
| 104 | |
| 105 | static const struct of_device_id vic_of_match[] __initconst = { |
| 106 | { .compatible = "arm,pl190-vic", .data = vic_of_init, }, |
| 107 | { /* Sentinel */ } |
| 108 | }; |
| 109 | |
| 110 | static void __init spear6xx_dt_init_irq(void) |
| 111 | { |
| 112 | of_irq_init(vic_of_match); |
| 113 | } |
| 114 | |
| 115 | DT_MACHINE_START(SPEAR600_DT, "ST SPEAr600 (Flattened Device Tree)") |
| 116 | .map_io = spear6xx_map_io, |
| 117 | .init_irq = spear6xx_dt_init_irq, |
| 118 | .handle_irq = vic_handle_irq, |
| 119 | .timer = &spear6xx_timer, |
| 120 | .init_machine = spear600_dt_init, |
| 121 | .restart = spear_restart, |
| 122 | .dt_compat = spear600_dt_board_compat, |
| 123 | MACHINE_END |