2 * arch/arm/mach-spear3xx/spear3xx.c
4 * SPEAr3XX machines common source file
6 * Copyright (C) 2009 ST Microelectronics
7 * Viresh Kumar<viresh.kumar@st.com>
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.
14 #include <linux/types.h>
15 #include <linux/amba/pl061.h>
16 #include <linux/ptrace.h>
18 #include <asm/hardware/vic.h>
20 #include <asm/mach/arch.h>
21 #include <mach/generic.h>
22 #include <mach/hardware.h>
24 /* Add spear3xx machines common devices here */
25 /* gpio device registration */
26 static struct pl061_platform_data gpio_plat_data
= {
28 .irq_base
= SPEAR3XX_GPIO_INT_BASE
,
31 struct amba_device spear3xx_gpio_device
= {
34 .platform_data
= &gpio_plat_data
,
37 .start
= SPEAR3XX_ICM3_GPIO_BASE
,
38 .end
= SPEAR3XX_ICM3_GPIO_BASE
+ SZ_4K
- 1,
39 .flags
= IORESOURCE_MEM
,
41 .irq
= {SPEAR3XX_IRQ_BASIC_GPIO
, NO_IRQ
},
44 /* uart device registration */
45 struct amba_device spear3xx_uart_device
= {
50 .start
= SPEAR3XX_ICM1_UART_BASE
,
51 .end
= SPEAR3XX_ICM1_UART_BASE
+ SZ_4K
- 1,
52 .flags
= IORESOURCE_MEM
,
54 .irq
= {SPEAR3XX_IRQ_UART
, NO_IRQ
},
57 /* Do spear3xx familiy common initialization part here */
58 void __init
spear3xx_init(void)
60 /* nothing to do for now */
63 /* This will initialize vic */
64 void __init
spear3xx_init_irq(void)
66 vic_init((void __iomem
*)VA_SPEAR3XX_ML1_VIC_BASE
, 0, ~0, 0);
69 /* Following will create static virtual/physical mappings */
70 struct map_desc spear3xx_io_desc
[] __initdata
= {
72 .virtual = VA_SPEAR3XX_ICM1_UART_BASE
,
73 .pfn
= __phys_to_pfn(SPEAR3XX_ICM1_UART_BASE
),
77 .virtual = VA_SPEAR3XX_ML1_VIC_BASE
,
78 .pfn
= __phys_to_pfn(SPEAR3XX_ML1_VIC_BASE
),
82 .virtual = VA_SPEAR3XX_ICM3_SYS_CTRL_BASE
,
83 .pfn
= __phys_to_pfn(SPEAR3XX_ICM3_SYS_CTRL_BASE
),
87 .virtual = VA_SPEAR3XX_ICM3_MISC_REG_BASE
,
88 .pfn
= __phys_to_pfn(SPEAR3XX_ICM3_MISC_REG_BASE
),
94 /* This will create static memory mapping for selected devices */
95 void __init
spear3xx_map_io(void)
97 iotable_init(spear3xx_io_desc
, ARRAY_SIZE(spear3xx_io_desc
));
99 /* This will initialize clock framework */
103 /* pad multiplexing support */
105 static struct pmx_dev_mode pmx_firda_modes
[] = {
108 .mask
= PMX_FIRDA_MASK
,
112 struct pmx_dev spear3xx_pmx_firda
= {
114 .modes
= pmx_firda_modes
,
115 .mode_count
= ARRAY_SIZE(pmx_firda_modes
),
119 static struct pmx_dev_mode pmx_i2c_modes
[] = {
122 .mask
= PMX_I2C_MASK
,
126 struct pmx_dev spear3xx_pmx_i2c
= {
128 .modes
= pmx_i2c_modes
,
129 .mode_count
= ARRAY_SIZE(pmx_i2c_modes
),
133 static struct pmx_dev_mode pmx_ssp_cs_modes
[] = {
136 .mask
= PMX_SSP_CS_MASK
,
140 struct pmx_dev spear3xx_pmx_ssp_cs
= {
141 .name
= "ssp_chip_selects",
142 .modes
= pmx_ssp_cs_modes
,
143 .mode_count
= ARRAY_SIZE(pmx_ssp_cs_modes
),
147 static struct pmx_dev_mode pmx_ssp_modes
[] = {
150 .mask
= PMX_SSP_MASK
,
154 struct pmx_dev spear3xx_pmx_ssp
= {
156 .modes
= pmx_ssp_modes
,
157 .mode_count
= ARRAY_SIZE(pmx_ssp_modes
),
161 static struct pmx_dev_mode pmx_mii_modes
[] = {
164 .mask
= PMX_MII_MASK
,
168 struct pmx_dev spear3xx_pmx_mii
= {
170 .modes
= pmx_mii_modes
,
171 .mode_count
= ARRAY_SIZE(pmx_mii_modes
),
175 static struct pmx_dev_mode pmx_gpio_pin0_modes
[] = {
178 .mask
= PMX_GPIO_PIN0_MASK
,
182 struct pmx_dev spear3xx_pmx_gpio_pin0
= {
184 .modes
= pmx_gpio_pin0_modes
,
185 .mode_count
= ARRAY_SIZE(pmx_gpio_pin0_modes
),
189 static struct pmx_dev_mode pmx_gpio_pin1_modes
[] = {
192 .mask
= PMX_GPIO_PIN1_MASK
,
196 struct pmx_dev spear3xx_pmx_gpio_pin1
= {
198 .modes
= pmx_gpio_pin1_modes
,
199 .mode_count
= ARRAY_SIZE(pmx_gpio_pin1_modes
),
203 static struct pmx_dev_mode pmx_gpio_pin2_modes
[] = {
206 .mask
= PMX_GPIO_PIN2_MASK
,
210 struct pmx_dev spear3xx_pmx_gpio_pin2
= {
212 .modes
= pmx_gpio_pin2_modes
,
213 .mode_count
= ARRAY_SIZE(pmx_gpio_pin2_modes
),
217 static struct pmx_dev_mode pmx_gpio_pin3_modes
[] = {
220 .mask
= PMX_GPIO_PIN3_MASK
,
224 struct pmx_dev spear3xx_pmx_gpio_pin3
= {
226 .modes
= pmx_gpio_pin3_modes
,
227 .mode_count
= ARRAY_SIZE(pmx_gpio_pin3_modes
),
231 static struct pmx_dev_mode pmx_gpio_pin4_modes
[] = {
234 .mask
= PMX_GPIO_PIN4_MASK
,
238 struct pmx_dev spear3xx_pmx_gpio_pin4
= {
240 .modes
= pmx_gpio_pin4_modes
,
241 .mode_count
= ARRAY_SIZE(pmx_gpio_pin4_modes
),
245 static struct pmx_dev_mode pmx_gpio_pin5_modes
[] = {
248 .mask
= PMX_GPIO_PIN5_MASK
,
252 struct pmx_dev spear3xx_pmx_gpio_pin5
= {
254 .modes
= pmx_gpio_pin5_modes
,
255 .mode_count
= ARRAY_SIZE(pmx_gpio_pin5_modes
),
259 static struct pmx_dev_mode pmx_uart0_modem_modes
[] = {
262 .mask
= PMX_UART0_MODEM_MASK
,
266 struct pmx_dev spear3xx_pmx_uart0_modem
= {
267 .name
= "uart0_modem",
268 .modes
= pmx_uart0_modem_modes
,
269 .mode_count
= ARRAY_SIZE(pmx_uart0_modem_modes
),
273 static struct pmx_dev_mode pmx_uart0_modes
[] = {
276 .mask
= PMX_UART0_MASK
,
280 struct pmx_dev spear3xx_pmx_uart0
= {
282 .modes
= pmx_uart0_modes
,
283 .mode_count
= ARRAY_SIZE(pmx_uart0_modes
),
287 static struct pmx_dev_mode pmx_timer_3_4_modes
[] = {
290 .mask
= PMX_TIMER_3_4_MASK
,
294 struct pmx_dev spear3xx_pmx_timer_3_4
= {
296 .modes
= pmx_timer_3_4_modes
,
297 .mode_count
= ARRAY_SIZE(pmx_timer_3_4_modes
),
301 static struct pmx_dev_mode pmx_timer_1_2_modes
[] = {
304 .mask
= PMX_TIMER_1_2_MASK
,
308 struct pmx_dev spear3xx_pmx_timer_1_2
= {
310 .modes
= pmx_timer_1_2_modes
,
311 .mode_count
= ARRAY_SIZE(pmx_timer_1_2_modes
),
315 #if defined(CONFIG_MACH_SPEAR310) || defined(CONFIG_MACH_SPEAR320)
316 /* plgpios devices */
317 static struct pmx_dev_mode pmx_plgpio_0_1_modes
[] = {
320 .mask
= PMX_FIRDA_MASK
,
324 struct pmx_dev spear3xx_pmx_plgpio_0_1
= {
325 .name
= "plgpio 0 and 1",
326 .modes
= pmx_plgpio_0_1_modes
,
327 .mode_count
= ARRAY_SIZE(pmx_plgpio_0_1_modes
),
331 static struct pmx_dev_mode pmx_plgpio_2_3_modes
[] = {
334 .mask
= PMX_UART0_MASK
,
338 struct pmx_dev spear3xx_pmx_plgpio_2_3
= {
339 .name
= "plgpio 2 and 3",
340 .modes
= pmx_plgpio_2_3_modes
,
341 .mode_count
= ARRAY_SIZE(pmx_plgpio_2_3_modes
),
345 static struct pmx_dev_mode pmx_plgpio_4_5_modes
[] = {
348 .mask
= PMX_I2C_MASK
,
352 struct pmx_dev spear3xx_pmx_plgpio_4_5
= {
353 .name
= "plgpio 4 and 5",
354 .modes
= pmx_plgpio_4_5_modes
,
355 .mode_count
= ARRAY_SIZE(pmx_plgpio_4_5_modes
),
359 static struct pmx_dev_mode pmx_plgpio_6_9_modes
[] = {
362 .mask
= PMX_SSP_MASK
,
366 struct pmx_dev spear3xx_pmx_plgpio_6_9
= {
367 .name
= "plgpio 6 to 9",
368 .modes
= pmx_plgpio_6_9_modes
,
369 .mode_count
= ARRAY_SIZE(pmx_plgpio_6_9_modes
),
373 static struct pmx_dev_mode pmx_plgpio_10_27_modes
[] = {
376 .mask
= PMX_MII_MASK
,
380 struct pmx_dev spear3xx_pmx_plgpio_10_27
= {
381 .name
= "plgpio 10 to 27",
382 .modes
= pmx_plgpio_10_27_modes
,
383 .mode_count
= ARRAY_SIZE(pmx_plgpio_10_27_modes
),
387 static struct pmx_dev_mode pmx_plgpio_28_modes
[] = {
390 .mask
= PMX_GPIO_PIN0_MASK
,
394 struct pmx_dev spear3xx_pmx_plgpio_28
= {
396 .modes
= pmx_plgpio_28_modes
,
397 .mode_count
= ARRAY_SIZE(pmx_plgpio_28_modes
),
401 static struct pmx_dev_mode pmx_plgpio_29_modes
[] = {
404 .mask
= PMX_GPIO_PIN1_MASK
,
408 struct pmx_dev spear3xx_pmx_plgpio_29
= {
410 .modes
= pmx_plgpio_29_modes
,
411 .mode_count
= ARRAY_SIZE(pmx_plgpio_29_modes
),
415 static struct pmx_dev_mode pmx_plgpio_30_modes
[] = {
418 .mask
= PMX_GPIO_PIN2_MASK
,
422 struct pmx_dev spear3xx_pmx_plgpio_30
= {
424 .modes
= pmx_plgpio_30_modes
,
425 .mode_count
= ARRAY_SIZE(pmx_plgpio_30_modes
),
429 static struct pmx_dev_mode pmx_plgpio_31_modes
[] = {
432 .mask
= PMX_GPIO_PIN3_MASK
,
436 struct pmx_dev spear3xx_pmx_plgpio_31
= {
438 .modes
= pmx_plgpio_31_modes
,
439 .mode_count
= ARRAY_SIZE(pmx_plgpio_31_modes
),
443 static struct pmx_dev_mode pmx_plgpio_32_modes
[] = {
446 .mask
= PMX_GPIO_PIN4_MASK
,
450 struct pmx_dev spear3xx_pmx_plgpio_32
= {
452 .modes
= pmx_plgpio_32_modes
,
453 .mode_count
= ARRAY_SIZE(pmx_plgpio_32_modes
),
457 static struct pmx_dev_mode pmx_plgpio_33_modes
[] = {
460 .mask
= PMX_GPIO_PIN5_MASK
,
464 struct pmx_dev spear3xx_pmx_plgpio_33
= {
466 .modes
= pmx_plgpio_33_modes
,
467 .mode_count
= ARRAY_SIZE(pmx_plgpio_33_modes
),
471 static struct pmx_dev_mode pmx_plgpio_34_36_modes
[] = {
474 .mask
= PMX_SSP_CS_MASK
,
478 struct pmx_dev spear3xx_pmx_plgpio_34_36
= {
479 .name
= "plgpio 34 to 36",
480 .modes
= pmx_plgpio_34_36_modes
,
481 .mode_count
= ARRAY_SIZE(pmx_plgpio_34_36_modes
),
485 static struct pmx_dev_mode pmx_plgpio_37_42_modes
[] = {
488 .mask
= PMX_UART0_MODEM_MASK
,
492 struct pmx_dev spear3xx_pmx_plgpio_37_42
= {
493 .name
= "plgpio 37 to 42",
494 .modes
= pmx_plgpio_37_42_modes
,
495 .mode_count
= ARRAY_SIZE(pmx_plgpio_37_42_modes
),
499 static struct pmx_dev_mode pmx_plgpio_43_44_47_48_modes
[] = {
502 .mask
= PMX_TIMER_1_2_MASK
,
506 struct pmx_dev spear3xx_pmx_plgpio_43_44_47_48
= {
507 .name
= "plgpio 43, 44, 47 and 48",
508 .modes
= pmx_plgpio_43_44_47_48_modes
,
509 .mode_count
= ARRAY_SIZE(pmx_plgpio_43_44_47_48_modes
),
513 static struct pmx_dev_mode pmx_plgpio_45_46_49_50_modes
[] = {
516 .mask
= PMX_TIMER_3_4_MASK
,
520 struct pmx_dev spear3xx_pmx_plgpio_45_46_49_50
= {
521 .name
= "plgpio 45, 46, 49 and 50",
522 .modes
= pmx_plgpio_45_46_49_50_modes
,
523 .mode_count
= ARRAY_SIZE(pmx_plgpio_45_46_49_50_modes
),
526 #endif /* CONFIG_MACH_SPEAR310 || CONFIG_MACH_SPEAR320 */
528 static void __init
spear3xx_timer_init(void)
530 char pclk_name
[] = "pll3_48m_clk";
531 struct clk
*gpt_clk
, *pclk
;
533 /* get the system timer clock */
534 gpt_clk
= clk_get_sys("gpt0", NULL
);
535 if (IS_ERR(gpt_clk
)) {
536 pr_err("%s:couldn't get clk for gpt\n", __func__
);
540 /* get the suitable parent clock for timer*/
541 pclk
= clk_get(NULL
, pclk_name
);
543 pr_err("%s:couldn't get %s as parent for gpt\n",
544 __func__
, pclk_name
);
548 clk_set_parent(gpt_clk
, pclk
);
555 struct sys_timer spear3xx_timer
= {
556 .init
= spear3xx_timer_init
,