~ubuntu-branches/ubuntu/vivid/linux-fsl-imx51/vivid

« back to all changes in this revision

Viewing changes to arch/arm/mach-mx25/system.c

  • Committer: Bazaar Package Importer
  • Author(s): Andy Whitcroft, Amit Kucheria, Andy Whitcroft, Bryan Wu, Upstream Kernel Changes
  • Date: 2010-01-11 16:26:27 UTC
  • Revision ID: james.westby@ubuntu.com-20100111162627-1q2fl9tcuwcywt1e
Tags: 2.6.31-602.4
[ Amit Kucheria ]

* Update to official 2.6.31 BSP release from Freescale

[ Andy Whitcroft ]

* drop a number of modules no longer built

[ Bryan Wu ]

* [Config] Update configs after applying .31 patchset from Freescale
* [Config] Sync with imx51_defconfig from Freescale BSP

[ Upstream Kernel Changes ]

* Update to official 2.6.31 BSP release from Freescale.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
 
3
 */
 
4
 
 
5
/*
 
6
 * The code contained herein is licensed under the GNU General Public
 
7
 * License. You may obtain a copy of the GNU General Public License
 
8
 * Version 2 or later at the following locations:
 
9
 *
 
10
 * http://www.opensource.org/licenses/gpl-license.html
 
11
 * http://www.gnu.org/copyleft/gpl.html
 
12
 */
 
13
 
 
14
#include <linux/clk.h>
 
15
#include <linux/io.h>
 
16
#include <linux/irq.h>
 
17
#include <linux/interrupt.h>
 
18
#include <mach/hardware.h>
 
19
#include <asm/proc-fns.h>
 
20
#include <asm/system.h>
 
21
#include <mach/clock.h>
 
22
#include "crm_regs.h"
 
23
 
 
24
/*!
 
25
 * @defgroup MSL_MX25 i.MX25 Machine Specific Layer (MSL)
 
26
 */
 
27
 
 
28
/*!
 
29
 * @file mach-mx25/system.c
 
30
 * @brief This file contains idle and reset functions.
 
31
 *
 
32
 * @ingroup MSL_MX25
 
33
 */
 
34
 
 
35
/*!
 
36
 * MX25 low-power mode
 
37
 */
 
38
enum mx25_low_pwr_mode {
 
39
        MX25_RUN_MODE,
 
40
        MX25_WAIT_MODE,
 
41
        MX25_DOZE_MODE,
 
42
        MX25_STOP_MODE
 
43
};
 
44
 
 
45
extern int mxc_jtag_enabled;
 
46
 
 
47
/*!
 
48
 * This function is used to set cpu low power mode before WFI instruction
 
49
 *
 
50
 * @param  mode         indicates different kinds of power modes
 
51
 */
 
52
void mxc_cpu_lp_set(enum mxc_cpu_pwr_mode mode)
 
53
{
 
54
        unsigned int lpm;
 
55
        unsigned long reg;
 
56
        unsigned int pmcr2, lpimr;
 
57
        unsigned int cgcr0, cgcr1, cgcr2;
 
58
        struct irq_desc *desc;
 
59
        int i;
 
60
 
 
61
        /*read CCTL value */
 
62
        reg = __raw_readl(MXC_CCM_CCTL);
 
63
 
 
64
        switch (mode) {
 
65
        case WAIT_UNCLOCKED_POWER_OFF:
 
66
                lpm = MX25_DOZE_MODE;
 
67
                break;
 
68
 
 
69
        case STOP_POWER_ON:
 
70
        case STOP_POWER_OFF:
 
71
                lpm = MX25_STOP_MODE;
 
72
                /* The clock of LCDC/SLCDC, SDMA, RTIC, RNGC, MAX, CAN
 
73
                   and EMI needs to be gated on when entering Stop mode.
 
74
                 */
 
75
                cgcr0 = __raw_readl(MXC_CCM_CGCR0);
 
76
                cgcr1 = __raw_readl(MXC_CCM_CGCR1);
 
77
                cgcr2 = __raw_readl(MXC_CCM_CGCR2);
 
78
                __raw_writel(cgcr0 | MXC_CCM_CGCR0_STOP_MODE_MASK,
 
79
                             MXC_CCM_CGCR0);
 
80
                __raw_writel(cgcr1 | MXC_CCM_CGCR1_STOP_MODE_MASK,
 
81
                             MXC_CCM_CGCR1);
 
82
                __raw_writel(cgcr2 | MXC_CCM_CGCR2_STOP_MODE_MASK,
 
83
                             MXC_CCM_CGCR2);
 
84
                /* The interrupts which are not wake-up sources need
 
85
                   be mask when entering Stop mode.
 
86
                 */
 
87
                lpimr = MXC_CCM_LPIMR0_MASK;
 
88
                for (i = 0; i < 32; i++) {
 
89
                        desc = irq_desc + i;
 
90
                        if ((desc->status & IRQ_WAKEUP) != 0)
 
91
                                lpimr &= ~(1 << i);
 
92
                }
 
93
                __raw_writel(lpimr, MXC_CCM_LPIMR0);
 
94
                lpimr = MXC_CCM_LPIMR1_MASK;
 
95
                for (i = 32; i < 64; i++) {
 
96
                        desc = irq_desc + i;
 
97
                        if ((desc->status & IRQ_WAKEUP) != 0)
 
98
                                lpimr &= ~(1 << (i - 32));
 
99
                }
 
100
                __raw_writel(lpimr, MXC_CCM_LPIMR1);
 
101
 
 
102
                if (mode == STOP_POWER_OFF) {
 
103
                        pmcr2 = __raw_readl(MXC_CCM_PMCR2);
 
104
                        pmcr2 |= (MXC_CCM_PMCR2_OSC24M_DOWN |
 
105
                                  MXC_CCM_PMCR2_VSTBY);
 
106
                        __raw_writel(pmcr2, MXC_CCM_PMCR2);
 
107
                }
 
108
                break;
 
109
 
 
110
        case WAIT_CLOCKED:
 
111
        case WAIT_UNCLOCKED:
 
112
        default:
 
113
                /* Wait is the default mode used when idle. */
 
114
                lpm = MX25_WAIT_MODE;
 
115
                break;
 
116
        }
 
117
 
 
118
        /* program LP CTL bit */
 
119
        reg = ((reg & (~MXC_CCM_CCTL_LP_CTL_MASK)) |
 
120
               lpm << MXC_CCM_CCTL_LP_CTL_OFFSET);
 
121
 
 
122
        __raw_writel(reg, MXC_CCM_CCTL);
 
123
}
 
124
 
 
125
/*!
 
126
 * This function puts the CPU into idle mode. It is called by default_idle()
 
127
 * in process.c file.
 
128
 */
 
129
void arch_idle(void)
 
130
{
 
131
        /*
 
132
         * This should do all the clock switching
 
133
         * and wait for interrupt tricks.
 
134
         */
 
135
        if (!mxc_jtag_enabled) {
 
136
                /* set as Wait mode */
 
137
                mxc_cpu_lp_set(WAIT_UNCLOCKED);
 
138
                cpu_do_idle();
 
139
        }
 
140
}
 
141
 
 
142
/*
 
143
 * This function resets the system. It is called by machine_restart().
 
144
 *
 
145
 * @param  mode         indicates different kinds of resets
 
146
 */
 
147
void arch_reset(char mode)
 
148
{
 
149
        /* Assert SRS signal */
 
150
        mxc_wd_reset();
 
151
}