blob: 2ed8b14c82c8a34d04b8e73eb7cdc1dc1ce6f5ec [file] [log] [blame]
viresh kumar8f590d42010-04-01 12:31:01 +01001/*
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 Roese9652e8b2012-03-16 14:03:23 +01009 * Copyright 2012 Stefan Roese <sr@denx.de>
10 *
viresh kumar8f590d42010-04-01 12:31:01 +010011 * 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 Roese9652e8b2012-03-16 14:03:23 +010016#include <linux/of.h>
17#include <linux/of_address.h>
18#include <linux/of_irq.h>
19#include <linux/of_platform.h>
viresh kumar8f590d42010-04-01 12:31:01 +010020#include <asm/hardware/vic.h>
viresh kumar8f590d42010-04-01 12:31:01 +010021#include <asm/mach/arch.h>
viresh kumar8f590d42010-04-01 12:31:01 +010022#include <mach/generic.h>
viresh kumar02aa06b2011-03-07 05:57:02 +010023#include <mach/hardware.h>
viresh kumar8f590d42010-04-01 12:31:01 +010024
25/* Following will create static virtual/physical mappings */
26static 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 kumar53821162011-03-07 05:57:06 +010030 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +010031 .type = MT_DEVICE
32 }, {
33 .virtual = VA_SPEAR6XX_CPU_VIC_PRI_BASE,
34 .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_PRI_BASE),
viresh kumar53821162011-03-07 05:57:06 +010035 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +010036 .type = MT_DEVICE
37 }, {
38 .virtual = VA_SPEAR6XX_CPU_VIC_SEC_BASE,
39 .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_SEC_BASE),
viresh kumar53821162011-03-07 05:57:06 +010040 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +010041 .type = MT_DEVICE
42 }, {
43 .virtual = VA_SPEAR6XX_ICM3_SYS_CTRL_BASE,
44 .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SYS_CTRL_BASE),
viresh kumar53821162011-03-07 05:57:06 +010045 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +010046 .type = MT_DEVICE
47 }, {
48 .virtual = VA_SPEAR6XX_ICM3_MISC_REG_BASE,
49 .pfn = __phys_to_pfn(SPEAR6XX_ICM3_MISC_REG_BASE),
viresh kumar53821162011-03-07 05:57:06 +010050 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +010051 .type = MT_DEVICE
52 },
53};
54
55/* This will create static memory mapping for selected devices */
56void __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 kumarb997f6e2011-05-20 08:34:18 +010061 spear6xx_clk_init();
viresh kumar8f590d42010-04-01 12:31:01 +010062}
Shiraz Hashim5c881d92011-02-16 07:40:32 +010063
64static 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
91struct sys_timer spear6xx_timer = {
92 .init = spear6xx_timer_init,
93};
Stefan Roese9652e8b2012-03-16 14:03:23 +010094
95static void __init spear600_dt_init(void)
96{
97 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
98}
99
100static const char *spear600_dt_board_compat[] = {
101 "st,spear600",
102 NULL
103};
104
105static const struct of_device_id vic_of_match[] __initconst = {
106 { .compatible = "arm,pl190-vic", .data = vic_of_init, },
107 { /* Sentinel */ }
108};
109
110static void __init spear6xx_dt_init_irq(void)
111{
112 of_irq_init(vic_of_match);
113}
114
115DT_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,
123MACHINE_END