]> git.sur5r.net Git - u-boot/blob - arch/arm/cpu/armv7/u8500/cpu.c
u8500: Moving processor-specific functions to cpu area.
[u-boot] / arch / arm / cpu / armv7 / u8500 / cpu.c
1 /*
2  * Copyright (C) 2012 Linaro Limited
3  * Mathieu Poirier <mathieu.poirier@linaro.org>
4  *
5  * Based on original code from Joakim Axelsson at ST-Ericsson
6  * (C) Copyright 2010 ST-Ericsson
7  *
8  * See file CREDITS for list of people who contributed to this
9  * project.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License as
13  * published by the Free Software Foundation; either version 2 of
14  * the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24  * MA 02111-1307 USA
25  */
26
27 #include <common.h>
28 #include <asm/io.h>
29 #include <asm/arch/prcmu.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/hardware.h>
32
33 #include <asm/arch/hardware.h>
34
35 #define CPUID_DB8500V1          0x411fc091
36 #define ASICID_DB8500V11        0x008500A1
37
38 static unsigned int read_asicid(void)
39 {
40         unsigned int *address = (void *)U8500_BOOTROM_BASE
41                                 + U8500_BOOTROM_ASIC_ID_OFFSET;
42         return readl(address);
43 }
44
45 static int cpu_is_u8500v11(void)
46 {
47         return read_asicid() == ASICID_DB8500V11;
48 }
49
50 #ifdef CONFIG_ARCH_CPU_INIT
51 /*
52  * SOC specific cpu init
53  */
54 int arch_cpu_init(void)
55 {
56         db8500_prcmu_init();
57         db8500_clocks_init();
58
59         return 0;
60 }
61 #endif /* CONFIG_ARCH_CPU_INIT */
62
63 #ifdef CONFIG_MMC
64
65 #define LDO_VAUX3_MASK          0x3
66 #define LDO_VAUX3_ENABLE        0x1
67 #define VAUX3_VOLTAGE_2_9V      0xd
68
69 #define AB8500_REGU_CTRL2       0x4
70 #define AB8500_REGU_VRF1VAUX3_REGU_REG  0x040A
71 #define AB8500_REGU_VRF1VAUX3_SEL_REG   0x0421
72
73 int u8500_mmc_power_init(void)
74 {
75         int ret;
76         int val;
77
78         if (!cpu_is_u8500v11())
79                 return 0;
80
81         /*
82          * On v1.1 HREF boards (HREF+), Vaux3 needs to be enabled for the SD
83          * card to work.  This is done by enabling the regulators in the AB8500
84          * via PRCMU I2C transactions.
85          *
86          * This code is derived from the handling of AB8500_LDO_VAUX3 in
87          * ab8500_ldo_enable() and ab8500_ldo_disable() in Linux.
88          *
89          * Turn off and delay is required to have it work across soft reboots.
90          */
91
92         ret = prcmu_i2c_read(AB8500_REGU_CTRL2, AB8500_REGU_VRF1VAUX3_REGU_REG);
93         if (ret < 0)
94                 goto out;
95
96         val = ret;
97
98         /* Turn off */
99         ret = prcmu_i2c_write(AB8500_REGU_CTRL2, AB8500_REGU_VRF1VAUX3_REGU_REG,
100                                                         val & ~LDO_VAUX3_MASK);
101         if (ret < 0)
102                 goto out;
103
104         udelay(10 * 1000);
105
106         /* Set the voltage to 2.9V */
107         ret = prcmu_i2c_write(AB8500_REGU_CTRL2,
108                                 AB8500_REGU_VRF1VAUX3_SEL_REG,
109                                 VAUX3_VOLTAGE_2_9V);
110         if (ret < 0)
111                 goto out;
112
113         val = val & ~LDO_VAUX3_MASK;
114         val = val | LDO_VAUX3_ENABLE;
115
116         /* Turn on the supply */
117         ret = prcmu_i2c_write(AB8500_REGU_CTRL2,
118                                 AB8500_REGU_VRF1VAUX3_REGU_REG, val);
119
120 out:
121         return ret;
122 }
123 #endif /* CONFIG_MMC */