blob: bb7f54474b92e7f7fef65e1c504dbf4544c84992 [file] [log] [blame]
Greg Ungerereb1d65a2007-07-30 02:38:57 +01001/*
2 * arch/arm/mach-at91/at91x40.c
3 *
4 * (C) Copyright 2007, Greg Ungerer <gerg@snapgear.com>
5 * Copyright (C) 2005 SAN People
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/irq.h>
Arnd Bergmann14070ad2012-07-04 07:45:16 +000016#include <linux/io.h>
Nicolas Pitrec9dfafb2011-08-02 10:21:36 -040017#include <asm/proc-fns.h>
Olof Johansson86dfe442012-03-29 23:22:44 -070018#include <asm/system_misc.h>
Greg Ungerereb1d65a2007-07-30 02:38:57 +010019#include <asm/mach/arch.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010020#include <mach/at91x40.h>
Ludovic Desroches8fe82a52012-06-21 14:47:27 +020021#include <mach/at91_aic.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010022#include <mach/at91_st.h>
23#include <mach/timex.h>
Greg Ungerereb1d65a2007-07-30 02:38:57 +010024#include "generic.h"
25
26/*
Greg Ungerer66aaeff2008-05-23 08:26:24 +010027 * Export the clock functions for the AT91X40. Some external code common
28 * to all AT91 family parts relys on this, like the gpio and serial support.
Greg Ungerereb1d65a2007-07-30 02:38:57 +010029 */
30int clk_enable(struct clk *clk)
31{
32 return 0;
33}
34
Greg Ungerer66aaeff2008-05-23 08:26:24 +010035void clk_disable(struct clk *clk)
36{
37}
38
39unsigned long clk_get_rate(struct clk *clk)
40{
41 return AT91X40_MASTER_CLOCK;
42}
43
Nicolas Pitrec9dfafb2011-08-02 10:21:36 -040044static void at91x40_idle(void)
45{
46 /*
47 * Disable the processor clock. The processor will be automatically
48 * re-enabled by an interrupt or by a reset.
49 */
Arnd Bergmanndca4ba42012-09-14 20:10:19 +000050 __raw_writel(AT91_PS_CR_CPU, AT91_IO_P2V(AT91_PS_CR));
Nicolas Pitrec9dfafb2011-08-02 10:21:36 -040051 cpu_do_idle();
52}
53
Greg Ungerereb1d65a2007-07-30 02:38:57 +010054void __init at91x40_initialize(unsigned long main_clock)
55{
Nicolas Pitrec9dfafb2011-08-02 10:21:36 -040056 arm_pm_idle = at91x40_idle;
Greg Ungerereb1d65a2007-07-30 02:38:57 +010057 at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1)
58 | (1 << AT91X40_ID_IRQ2);
59}
60
61/*
62 * The default interrupt priority levels (0 = lowest, 7 = highest).
63 */
64static unsigned int at91x40_default_irq_priority[NR_AIC_IRQS] __initdata = {
65 7, /* Advanced Interrupt Controller (FIQ) */
66 0, /* System Peripherals */
67 0, /* USART 0 */
68 0, /* USART 1 */
69 2, /* Timer Counter 0 */
70 2, /* Timer Counter 1 */
71 2, /* Timer Counter 2 */
72 0, /* Watchdog timer */
73 0, /* Parallel IO Controller A */
74 0, /* Reserved */
75 0, /* Reserved */
76 0, /* Reserved */
77 0, /* Reserved */
78 0, /* Reserved */
79 0, /* Reserved */
80 0, /* Reserved */
81 0, /* External IRQ0 */
82 0, /* External IRQ1 */
83 0, /* External IRQ2 */
84};
85
86void __init at91x40_init_interrupts(unsigned int priority[NR_AIC_IRQS])
87{
88 if (!priority)
89 priority = at91x40_default_irq_priority;
90
Arnd Bergmann0654f4a2012-10-26 22:49:09 +020091 at91_aic_init(priority, at91_extern_irq);
Greg Ungerereb1d65a2007-07-30 02:38:57 +010092}
93