2 * TI DaVinci Power and Sleep Controller (PSC)
4 * Copyright (C) 2006 Texas Instruments.
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.
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.
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.
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/init.h>
26 #include <asm/hardware.h>
27 #include <asm/arch/psc.h>
28 #include <asm/arch/mux.h>
30 /* PSC register offsets */
39 /* System control register offsets */
40 #define VDD3P3V_PWDN 0x48
42 static void davinci_psc_mux(unsigned int id
)
45 case DAVINCI_LPSC_ATA
:
46 davinci_mux_peripheral(DAVINCI_MUX_HDIREN
, 1);
47 davinci_mux_peripheral(DAVINCI_MUX_ATAEN
, 1);
49 case DAVINCI_LPSC_MMC_SD
:
50 /* VDD power manupulations are done in U-Boot for CPMAC
51 * so applies to MMC as well
53 /*Set up the pull regiter for MMC */
54 davinci_writel(0, DAVINCI_SYSTEM_MODULE_BASE
+ VDD3P3V_PWDN
);
55 davinci_mux_peripheral(DAVINCI_MUX_MSTK
, 0);
57 case DAVINCI_LPSC_I2C
:
58 davinci_mux_peripheral(DAVINCI_MUX_I2C
, 1);
60 case DAVINCI_LPSC_McBSP
:
61 davinci_mux_peripheral(DAVINCI_MUX_ASP
, 1);
68 /* Enable or disable a PSC domain */
69 void davinci_psc_config(unsigned int domain
, unsigned int id
, char enable
)
71 u32 epcpr
, ptcmd
, ptstat
, pdstat
, pdctl1
, mdstat
, mdctl
, mdstat_mask
;
76 mdctl
= davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE
+ MDCTL
+ 4 * id
);
78 mdctl
|= 0x00000003; /* Enable Module */
80 mdctl
&= 0xFFFFFFF2; /* Disable Module */
81 davinci_writel(mdctl
, DAVINCI_PWR_SLEEP_CNTRL_BASE
+ MDCTL
+ 4 * id
);
83 pdstat
= davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE
+ PDSTAT
);
84 if ((pdstat
& 0x00000001) == 0) {
85 pdctl1
= davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE
+ PDCTL1
);
87 davinci_writel(pdctl1
, DAVINCI_PWR_SLEEP_CNTRL_BASE
+ PDCTL1
);
90 davinci_writel(ptcmd
, DAVINCI_PWR_SLEEP_CNTRL_BASE
+ PTCMD
);
93 epcpr
= davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE
+
95 } while ((((epcpr
>> domain
) & 1) == 0));
97 pdctl1
= davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE
+ PDCTL1
);
99 davinci_writel(pdctl1
, DAVINCI_PWR_SLEEP_CNTRL_BASE
+ PDCTL1
);
102 ptstat
= davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE
+
104 } while (!(((ptstat
>> domain
) & 1) == 0));
107 davinci_writel(ptcmd
, DAVINCI_PWR_SLEEP_CNTRL_BASE
+ PTCMD
);
110 ptstat
= davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE
+
112 } while (!(((ptstat
>> domain
) & 1) == 0));
121 mdstat
= davinci_readl(DAVINCI_PWR_SLEEP_CNTRL_BASE
+
123 } while (!((mdstat
& 0x0000001F) == mdstat_mask
));
129 void __init
davinci_psc_init(void)
131 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN
, DAVINCI_LPSC_VPSSMSTR
, 1);
132 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN
, DAVINCI_LPSC_VPSSSLV
, 1);
133 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN
, DAVINCI_LPSC_TPCC
, 1);
134 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN
, DAVINCI_LPSC_TPTC0
, 1);
135 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN
, DAVINCI_LPSC_TPTC1
, 1);
136 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN
, DAVINCI_LPSC_GPIO
, 1);
138 /* Turn on WatchDog timer LPSC. Needed for RESET to work */
139 davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN
, DAVINCI_LPSC_TIMER2
, 1);