]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/omap5/abb.c
Merge branch 'u-boot-imx/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / omap5 / abb.c
1 /*
2  *
3  * Adaptive Body Bias programming sequence for OMAP5 family
4  *
5  * (C) Copyright 2013
6  * Texas Instruments, <www.ti.com>
7  *
8  * Andrii Tseglytskyi <andrii.tseglytskyi@ti.com>
9  *
10  * See file CREDITS for list of people who contributed to this
11  * project.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License as
15  * published by the Free Software Foundation; either version 2 of
16  * the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26  * MA 02111-1307 USA
27  */
28
29 #include <common.h>
30 #include <asm/omap_common.h>
31 #include <asm/io.h>
32
33 /*
34  * Setup LDOVBB for OMAP5.
35  * On OMAP5+ some ABB settings are fused. They are handled
36  * in the following way:
37  *
38  * 1. corresponding EFUSE register contains ABB enable bit
39  *    and VSET value
40  * 2. If ABB enable bit is set to 1, than ABB should be
41  *    enabled, otherwise ABB should be disabled
42  * 3. If ABB is enabled, than VSET value should be copied
43  *    to corresponding MUX control register
44  */
45 s8 abb_setup_ldovbb(u32 fuse, u32 ldovbb)
46 {
47         u32 vset;
48
49         /*
50          * ABB parameters must be properly fused
51          * otherwise ABB should be disabled
52          */
53         vset = readl(fuse);
54         if (!(vset & OMAP5_ABB_FUSE_ENABLE_MASK))
55                 return -1;
56
57         /* prepare VSET value for LDOVBB mux register */
58         vset &= OMAP5_ABB_FUSE_VSET_MASK;
59         vset >>= ffs(OMAP5_ABB_FUSE_VSET_MASK) - 1;
60         vset <<= ffs(OMAP5_ABB_LDOVBBMPU_VSET_OUT_MASK) - 1;
61         vset |= OMAP5_ABB_LDOVBBMPU_MUX_CTRL_MASK;
62
63         /* setup LDOVBB using fused value */
64         clrsetbits_le32(ldovbb,  OMAP5_ABB_LDOVBBMPU_VSET_OUT_MASK, vset);
65
66         return 0;
67 }