xref: /openbmc/u-boot/drivers/power/ftpmu010.c (revision da8241ba)
1 /*
2  * (C) Copyright 2009 Faraday Technology
3  * Po-Yu Chuang <ratbert@faraday-tech.com>
4  *
5  * Copyright (C) 2010 Andes Technology Corporation
6  * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
7  * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23 
24 #include <common.h>
25 #include <asm/io.h>
26 #include "ftpmu010.h"
27 
28 static struct ftpmu010 *pmu = (struct ftpmu010 *)CONFIG_FTPMU010_BASE;
29 
30 void ftpmu010_32768osc_enable(void)
31 {
32 	unsigned int oscc;
33 
34 	/* enable the 32768Hz oscillator */
35 	oscc = readl(&pmu->OSCC);
36 	oscc &= ~(FTPMU010_OSCC_OSCL_OFF | FTPMU010_OSCC_OSCL_TRI);
37 	writel(oscc, &pmu->OSCC);
38 
39 	/* wait until ready */
40 	while (!(readl(&pmu->OSCC) & FTPMU010_OSCC_OSCL_STABLE))
41 		;
42 
43 	/* select 32768Hz oscillator */
44 	oscc = readl(&pmu->OSCC);
45 	oscc |= FTPMU010_OSCC_OSCL_RTCLSEL;
46 	writel(oscc, &pmu->OSCC);
47 }
48 
49 void ftpmu010_dlldis_disable(void)
50 {
51 	unsigned int pdllcr0;
52 
53 	pdllcr0 = readl(&pmu->PDLLCR0);
54 	pdllcr0 |= FTPMU010_PDLLCR0_DLLDIS;
55 	writel(pdllcr0, &pmu->PDLLCR0);
56 }
57 
58 void ftpmu010_sdram_clk_disable(unsigned int cr0)
59 {
60 	unsigned int pdllcr0;
61 
62 	pdllcr0 = readl(&pmu->PDLLCR0);
63 	pdllcr0 |= FTPMU010_PDLLCR0_HCLKOUTDIS(cr0);
64 	writel(pdllcr0, &pmu->PDLLCR0);
65 }
66