blob: e0f6628c8b2c878155fc311acad938b15a3d56d4 [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 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#include <linux/types.h>
15#include <linux/amba/pl061.h>
viresh kumar8f590d42010-04-01 12:31:01 +010016#include <linux/ptrace.h>
17#include <linux/io.h>
18#include <asm/hardware/vic.h>
19#include <asm/irq.h>
20#include <asm/mach/arch.h>
viresh kumar8f590d42010-04-01 12:31:01 +010021#include <mach/generic.h>
viresh kumar02aa06b2011-03-07 05:57:02 +010022#include <mach/hardware.h>
viresh kumar410782b2011-03-07 05:57:01 +010023#include <mach/irqs.h>
viresh kumar8f590d42010-04-01 12:31:01 +010024
25/* Add spear6xx machines common devices here */
Uwe Kleine-Königb5950762010-11-01 15:38:34 -040026/* uart device registration */
viresh kumar8f590d42010-04-01 12:31:01 +010027struct amba_device uart_device[] = {
28 {
29 .dev = {
30 .init_name = "uart0",
31 },
32 .res = {
33 .start = SPEAR6XX_ICM1_UART0_BASE,
viresh kumar53821162011-03-07 05:57:06 +010034 .end = SPEAR6XX_ICM1_UART0_BASE + SZ_4K - 1,
viresh kumar8f590d42010-04-01 12:31:01 +010035 .flags = IORESOURCE_MEM,
36 },
37 .irq = {IRQ_UART_0, NO_IRQ},
38 }, {
39 .dev = {
40 .init_name = "uart1",
41 },
42 .res = {
43 .start = SPEAR6XX_ICM1_UART1_BASE,
viresh kumar53821162011-03-07 05:57:06 +010044 .end = SPEAR6XX_ICM1_UART1_BASE + SZ_4K - 1,
viresh kumar8f590d42010-04-01 12:31:01 +010045 .flags = IORESOURCE_MEM,
46 },
47 .irq = {IRQ_UART_1, NO_IRQ},
48 }
49};
50
Uwe Kleine-Königb5950762010-11-01 15:38:34 -040051/* gpio device registration */
viresh kumar8f590d42010-04-01 12:31:01 +010052static struct pl061_platform_data gpio_plat_data[] = {
53 {
54 .gpio_base = 0,
55 .irq_base = SPEAR_GPIO0_INT_BASE,
56 }, {
57 .gpio_base = 8,
58 .irq_base = SPEAR_GPIO1_INT_BASE,
59 }, {
60 .gpio_base = 16,
61 .irq_base = SPEAR_GPIO2_INT_BASE,
62 },
63};
64
65struct amba_device gpio_device[] = {
66 {
67 .dev = {
68 .init_name = "gpio0",
69 .platform_data = &gpio_plat_data[0],
70 },
71 .res = {
72 .start = SPEAR6XX_CPU_GPIO_BASE,
viresh kumar53821162011-03-07 05:57:06 +010073 .end = SPEAR6XX_CPU_GPIO_BASE + SZ_4K - 1,
viresh kumar8f590d42010-04-01 12:31:01 +010074 .flags = IORESOURCE_MEM,
75 },
76 .irq = {IRQ_LOCAL_GPIO, NO_IRQ},
77 }, {
78 .dev = {
79 .init_name = "gpio1",
80 .platform_data = &gpio_plat_data[1],
81 },
82 .res = {
83 .start = SPEAR6XX_ICM3_GPIO_BASE,
viresh kumar53821162011-03-07 05:57:06 +010084 .end = SPEAR6XX_ICM3_GPIO_BASE + SZ_4K - 1,
viresh kumar8f590d42010-04-01 12:31:01 +010085 .flags = IORESOURCE_MEM,
86 },
87 .irq = {IRQ_BASIC_GPIO, NO_IRQ},
88 }, {
89 .dev = {
90 .init_name = "gpio2",
91 .platform_data = &gpio_plat_data[2],
92 },
93 .res = {
94 .start = SPEAR6XX_ICM2_GPIO_BASE,
viresh kumar53821162011-03-07 05:57:06 +010095 .end = SPEAR6XX_ICM2_GPIO_BASE + SZ_4K - 1,
viresh kumar8f590d42010-04-01 12:31:01 +010096 .flags = IORESOURCE_MEM,
97 },
98 .irq = {IRQ_APPL_GPIO, NO_IRQ},
99 }
100};
101
102/* This will add devices, and do machine specific tasks */
103void __init spear6xx_init(void)
104{
105 /* nothing to do for now */
106}
107
108/* This will initialize vic */
109void __init spear6xx_init_irq(void)
110{
111 vic_init((void __iomem *)VA_SPEAR6XX_CPU_VIC_PRI_BASE, 0, ~0, 0);
112 vic_init((void __iomem *)VA_SPEAR6XX_CPU_VIC_SEC_BASE, 32, ~0, 0);
113}
114
115/* Following will create static virtual/physical mappings */
116static struct map_desc spear6xx_io_desc[] __initdata = {
117 {
118 .virtual = VA_SPEAR6XX_ICM1_UART0_BASE,
119 .pfn = __phys_to_pfn(SPEAR6XX_ICM1_UART0_BASE),
viresh kumar53821162011-03-07 05:57:06 +0100120 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +0100121 .type = MT_DEVICE
122 }, {
123 .virtual = VA_SPEAR6XX_CPU_VIC_PRI_BASE,
124 .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_PRI_BASE),
viresh kumar53821162011-03-07 05:57:06 +0100125 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +0100126 .type = MT_DEVICE
127 }, {
128 .virtual = VA_SPEAR6XX_CPU_VIC_SEC_BASE,
129 .pfn = __phys_to_pfn(SPEAR6XX_CPU_VIC_SEC_BASE),
viresh kumar53821162011-03-07 05:57:06 +0100130 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +0100131 .type = MT_DEVICE
132 }, {
133 .virtual = VA_SPEAR6XX_ICM3_SYS_CTRL_BASE,
134 .pfn = __phys_to_pfn(SPEAR6XX_ICM3_SYS_CTRL_BASE),
viresh kumar53821162011-03-07 05:57:06 +0100135 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +0100136 .type = MT_DEVICE
137 }, {
138 .virtual = VA_SPEAR6XX_ICM3_MISC_REG_BASE,
139 .pfn = __phys_to_pfn(SPEAR6XX_ICM3_MISC_REG_BASE),
viresh kumar53821162011-03-07 05:57:06 +0100140 .length = SZ_4K,
viresh kumar8f590d42010-04-01 12:31:01 +0100141 .type = MT_DEVICE
142 },
143};
144
145/* This will create static memory mapping for selected devices */
146void __init spear6xx_map_io(void)
147{
148 iotable_init(spear6xx_io_desc, ARRAY_SIZE(spear6xx_io_desc));
149
150 /* This will initialize clock framework */
viresh kumarb997f6e2011-05-20 08:34:18 +0100151 spear6xx_clk_init();
viresh kumar8f590d42010-04-01 12:31:01 +0100152}
Shiraz Hashim5c881d92011-02-16 07:40:32 +0100153
154static void __init spear6xx_timer_init(void)
155{
156 char pclk_name[] = "pll3_48m_clk";
157 struct clk *gpt_clk, *pclk;
158
159 /* get the system timer clock */
160 gpt_clk = clk_get_sys("gpt0", NULL);
161 if (IS_ERR(gpt_clk)) {
162 pr_err("%s:couldn't get clk for gpt\n", __func__);
163 BUG();
164 }
165
166 /* get the suitable parent clock for timer*/
167 pclk = clk_get(NULL, pclk_name);
168 if (IS_ERR(pclk)) {
169 pr_err("%s:couldn't get %s as parent for gpt\n",
170 __func__, pclk_name);
171 BUG();
172 }
173
174 clk_set_parent(gpt_clk, pclk);
175 clk_put(gpt_clk);
176 clk_put(pclk);
177
178 spear_setup_timer();
179}
180
181struct sys_timer spear6xx_timer = {
182 .init = spear6xx_timer_init,
183};