2 * Copyright (C) 2012 Spreadtrum Communications Inc.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
18 #include <asm/errno.h>
19 #include <asm/arch-sc8825/ldo.h>
20 #include <asm/arch/sc8810_reg_global.h>
21 #include <asm/arch/regs_global.h>
22 #include <asm/arch/regs_cpc.h>
23 #include <asm/arch/analog_reg_v3.h>
24 #include <ubi_uboot.h>
25 #include <asm/sizes.h>
27 #define rounddown(x, y) ( \
29 typeof(x) __x = (x); \
34 /* vars definitions for controller REGS_GLB */
35 #define REG_GLB_SET(A) ( A + 0x1000 )
36 #define REG_GLB_CLR(A) ( A + 0x2000 )
38 u32 sci_glb_read(u32 reg, u32 msk)
40 return __raw_readl(reg) & msk;
43 int sci_glb_write(u32 reg, u32 val, u32 msk)
45 unsigned long flags, hw_flags;
46 __raw_writel((__raw_readl(reg) & ~msk) | val, reg);
50 static int __is_glb(u32 reg)
52 return rounddown(reg, SZ_64K) == rounddown(GREG_BASE, SZ_64K) ||
53 rounddown(reg, SZ_64K) == rounddown(AHB_GEN_CTL_BEGIN, SZ_64K);
56 int sci_glb_set(u32 reg, u32 bit)
59 __raw_writel(bit, REG_GLB_SET(reg));
65 int sci_glb_clr(u32 reg, u32 bit)
68 __raw_writel(bit, REG_GLB_CLR(reg));