aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-davinci/psc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-12 21:11:33 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-12 21:11:33 -0400
commitf7d02ae76ebbf5b8a9531fe150c49e126a397704 (patch)
treebcfdcab6e70658d55a3c843694e04e938bf9168f /arch/arm/mach-davinci/psc.c
parent78db2ad6f4df9145bfd6aab1c0f1c56d615288ec (diff)
parent158304ef09a28c7f2dd37d78f536a4e09ba084a1 (diff)
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm: (30 commits) [ARM] Use new get_irqnr_preamble [ARM] Ensure machine class menu is sorted alphabetically [ARM] 4333/2: KS8695: Micrel Development board [ARM] 4332/2: KS8695: Serial driver [ARM] 4331/3: Support for Micrel/Kendin KS8695 processor [ARM] 4371/1: AT91: Support for Atmel AT91SAM9RL-EK development board [ARM] 4372/1: Define byte sizes in asm-arm/sizes.h [ARM] 4370/3: AT91: Support for Atmel AT91SAM9RL processors. [ARM] Update mach-types [ARM] export symbol csum_partial_copy_from_user [ARM] iop13xx: msi support [ARM] stacktrace fix [ARM] Spinlock initializer cleanup [ARM] remove useless config option GENERIC_BUST_SPINLOCK [ARM] 4303/3: base kernel support for TI DaVinci [ARM] 4369/1: AT91: Fix circular dependency in header files [ARM] 4368/1: S3C24xx: build fix [ARM] 4364/1: AT91: LEDS on AT91SAM9261-EK [ARM] Fix iop32x/iop33x build [ARM] EBSA110: fix build errors caused by missing "const" ...
Diffstat (limited to 'arch/arm/mach-davinci/psc.c')
-rw-r--r--arch/arm/mach-davinci/psc.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/psc.c b/arch/arm/mach-davinci/psc.c
new file mode 100644
index 000000000000..e1b0050283a6
--- /dev/null
+++ b/arch/arm/mach-davinci/psc.c
@@ -0,0 +1,113 @@
1/*
2 * TI DaVinci Power and Sleep Controller (PSC)
3 *
4 * Copyright (C) 2006 Texas Instruments.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/init.h>
24
25#include <asm/io.h>
26#include <asm/hardware.h>
27#include <asm/arch/psc.h>
28
29#define PTCMD __REG(0x01C41120)
30#define PDSTAT __REG(0x01C41200)
31#define PDCTL1 __REG(0x01C41304)
32#define EPCPR __REG(0x01C41070)
33#define PTSTAT __REG(0x01C41128)
34
35#define MDSTAT IO_ADDRESS(0x01C41800)
36#define MDCTL IO_ADDRESS(0x01C41A00)
37
38#define PINMUX0 __REG(0x01c40000)
39#define PINMUX1 __REG(0x01c40004)
40#define VDD3P3V_PWDN __REG(0x01C40048)
41
42static void davinci_psc_mux(unsigned int id)
43{
44 switch (id) {
45 case DAVINCI_LPSC_ATA:
46 PINMUX0 |= (1 << 17) | (1 << 16);
47 break;
48 case DAVINCI_LPSC_MMC_SD:
49 /* VDD power manupulations are done in U-Boot for CPMAC
50 * so applies to MMC as well
51 */
52 /*Set up the pull regiter for MMC */
53 VDD3P3V_PWDN = 0x0;
54 PINMUX1 &= (~(1 << 9));
55 break;
56 case DAVINCI_LPSC_I2C:
57 PINMUX1 |= (1 << 7);
58 break;
59 case DAVINCI_LPSC_McBSP:
60 PINMUX1 |= (1 << 10);
61 break;
62 default:
63 break;
64 }
65}
66
67/* Enable or disable a PSC domain */
68void davinci_psc_config(unsigned int domain, unsigned int id, char enable)
69{
70 volatile unsigned int *mdstat = (unsigned int *)((int)MDSTAT + 4 * id);
71 volatile unsigned int *mdctl = (unsigned int *)((int)MDCTL + 4 * id);
72
73 if (id < 0)
74 return;
75
76 if (enable)
77 *mdctl |= 0x00000003; /* Enable Module */
78 else
79 *mdctl &= 0xFFFFFFF2; /* Disable Module */
80
81 if ((PDSTAT & 0x00000001) == 0) {
82 PDCTL1 |= 0x1;
83 PTCMD = (1 << domain);
84 while ((((EPCPR >> domain) & 1) == 0));
85
86 PDCTL1 |= 0x100;
87 while (!(((PTSTAT >> domain) & 1) == 0));
88 } else {
89 PTCMD = (1 << domain);
90 while (!(((PTSTAT >> domain) & 1) == 0));
91 }
92
93 if (enable)
94 while (!((*mdstat & 0x0000001F) == 0x3));
95 else
96 while (!((*mdstat & 0x0000001F) == 0x2));
97
98 if (enable)
99 davinci_psc_mux(id);
100}
101
102void __init davinci_psc_init(void)
103{
104 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_VPSSMSTR, 1);
105 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_VPSSSLV, 1);
106 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TPCC, 1);
107 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TPTC0, 1);
108 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TPTC1, 1);
109 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_GPIO, 1);
110
111 /* Turn on WatchDog timer LPSC. Needed for RESET to work */
112 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TIMER2, 1);
113}