2 * Copyright (C) 2012 Linaro Limited
3 * Mathieu Poirier <mathieu.poirier@linaro.org>
5 * Based on original code from Joakim Axelsson at ST-Ericsson
6 * (C) Copyright 2010 ST-Ericsson
8 * See file CREDITS for list of people who contributed to this
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.
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.
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,
29 #include <asm/arch/prcmu.h>
30 #include <asm/arch/clock.h>
31 #include <asm/arch/hardware.h>
33 #include <asm/arch/hardware.h>
35 #define CPUID_DB8500V1 0x411fc091
36 #define CPUID_DB8500V2 0x412fc091
37 #define ASICID_DB8500V11 0x008500A1
39 static unsigned int read_asicid(void);
41 static inline unsigned int read_cpuid(void)
45 /* Main ID register (MIDR) */
46 asm("mrc p15, 0, %0, c0, c0, 0"
54 static int cpu_is_u8500v11(void)
56 return read_asicid() == ASICID_DB8500V11;
59 static int cpu_is_u8500v2(void)
61 return read_cpuid() == CPUID_DB8500V2;
64 static unsigned int read_asicid(void)
66 unsigned int *address;
69 address = (void *) U8500_ASIC_ID_LOC_V2;
71 address = (void *) U8500_ASIC_ID_LOC_ED_V1;
73 return readl(address);
76 #ifdef CONFIG_ARCH_CPU_INIT
78 * SOC specific cpu init
80 int arch_cpu_init(void)
87 #endif /* CONFIG_ARCH_CPU_INIT */
91 int u8500_mmc_power_init(void)
97 if (!cpu_is_u8500v11() && !cpu_is_u8500v2())
100 /* Get AB8500 revision */
101 ret = ab8500_read(AB8500_MISC, AB8500_REV_REG);
105 ab8500_revision = ret;
108 * On v1.1 HREF boards (HREF+), Vaux3 needs to be enabled for the SD
109 * card to work. This is done by enabling the regulators in the AB8500
110 * via PRCMU I2C transactions.
112 * This code is derived from the handling of AB8500_LDO_VAUX3 in
113 * ab8500_ldo_enable() and ab8500_ldo_disable() in Linux.
115 * Turn off and delay is required to have it work across soft reboots.
118 /* Turn off (read-modify-write) */
119 ret = ab8500_read(AB8500_REGU_CTRL2,
120 AB8500_REGU_VRF1VAUX3_REGU_REG);
127 ret = ab8500_write(AB8500_REGU_CTRL2,
128 AB8500_REGU_VRF1VAUX3_REGU_REG,
129 enable & ~LDO_VAUX3_ENABLE_MASK);
135 /* Set the voltage to 2.91 V or 2.9 V without overriding VRF1 value */
136 ret = ab8500_read(AB8500_REGU_CTRL2,
137 AB8500_REGU_VRF1VAUX3_SEL_REG);
143 if (ab8500_revision < 0x20) {
144 voltage &= ~LDO_VAUX3_SEL_MASK;
145 voltage |= LDO_VAUX3_SEL_2V9;
147 voltage &= ~LDO_VAUX3_V2_SEL_MASK;
148 voltage |= LDO_VAUX3_V2_SEL_2V91;
151 ret = ab8500_write(AB8500_REGU_CTRL2,
152 AB8500_REGU_VRF1VAUX3_SEL_REG, voltage);
156 /* Turn on the supply */
157 enable &= ~LDO_VAUX3_ENABLE_MASK;
158 enable |= LDO_VAUX3_ENABLE_VAL;
160 ret = ab8500_write(AB8500_REGU_CTRL2,
161 AB8500_REGU_VRF1VAUX3_REGU_REG, enable);
166 #endif /* CONFIG_MMC */