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 <ubi_uboot.h>
20 #include <asm/sizes.h>
22 #define rounddown(x, y) ( \
24 typeof(x) __x = (x); \
29 /* vars definitions for controller REGS_GLB */
30 #define REG_GLB_SET(A) ( A + 0x1000 )
31 #define REG_GLB_CLR(A) ( A + 0x2000 )
33 u32 sci_glb_read(u32 reg, u32 msk)
35 return __raw_readl(reg) & msk;
38 int sci_glb_write(u32 reg, u32 val, u32 msk)
40 unsigned long flags, hw_flags;
41 __raw_writel((__raw_readl(reg) & ~msk) | val, reg);
45 static int __is_glb(u32 reg)
47 //return rounddown(reg, SZ_64K) == rounddown(GREG_BASE, SZ_64K) || rounddown(reg, SZ_64K) == rounddown(AHB_GEN_CTL_BEGIN, SZ_64K);
51 int sci_glb_set(u32 reg, u32 bit)
54 __raw_writel(bit, REG_GLB_SET(reg));
60 int sci_glb_clr(u32 reg, u32 bit)
63 __raw_writel(bit, REG_GLB_CLR(reg));