From d34514e41b77b748555577f8c3d65d80050cf8d2 Mon Sep 17 00:00:00 2001 From: Enric Balletbo i Serra Date: Wed, 25 May 2011 11:07:51 +0200 Subject: [PATCH] OMAP3: Move wait_on_value() function to not duplicate code The wait_on_value() function is implemented by various boards, this patch moves this function to a common place to not duplicate code. board/omap3530beagle/omap3530beagle.c :216:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) board/igep00x0/igep00x0.c :90:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) board/omap3430sdp/omap3430sdp.c :104:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) board/omap3evm/omap3evm.c :148:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) board/omap3430labrador/omap3430sdp.c :101:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) board/overo/overo.c :207:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) Signed-off-by: Enric Balletbo i Serra Signed-off-by: Anand Gadiyar --- board/igep00x0/igep00x0.c | 17 ----------------- board/omap3430labrador/omap3430sdp.c | 17 ----------------- board/omap3430sdp/omap3430sdp.c | 17 ----------------- board/omap3530beagle/omap3530beagle.c | 17 ----------------- board/omap3evm/omap3evm.c | 17 ----------------- board/overo/overo.c | 17 ----------------- cpu/omap3/sys_info.c | 17 +++++++++++++++++ 7 files changed, 17 insertions(+), 102 deletions(-) diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c index f1c1829..0b2ce5e 100644 --- a/board/igep00x0/igep00x0.c +++ b/board/igep00x0/igep00x0.c @@ -83,23 +83,6 @@ u32 get_mem_type(void) return GPMC_ONENAND; } -/********************************************************************* - * wait_on_value() - common routine to allow waiting for changes in - * volatile regs. - *********************************************************************/ -u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) -{ - u32 i = 0, val; - do { - ++i; - val = __raw_readl(read_addr) & read_bit_mask; - if (val == match_value) - return 1; - if (i == bound) - return 0; - } while (1); -} - /************************************************************* * get_sys_clk_speed - determine reference oscillator speed * based on known 32kHz clock and gptimer. diff --git a/board/omap3430labrador/omap3430sdp.c b/board/omap3430labrador/omap3430sdp.c index 300deb1..79d0dce 100644 --- a/board/omap3430labrador/omap3430sdp.c +++ b/board/omap3430labrador/omap3430sdp.c @@ -94,23 +94,6 @@ u32 cpu_is_3410(void) } } -/********************************************************************* - * wait_on_value() - common routine to allow waiting for changes in - * volatile regs. - *********************************************************************/ -u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) -{ - u32 i = 0, val; - do { - ++i; - val = __raw_readl(read_addr) & read_bit_mask; - if (val == match_value) - return (1); - if (i == bound) - return (0); - } while (1); -} - #ifdef CFG_3430SDRAM_DDR /********************************************************************* * config_3430sdram_ddr() - Init DDR on 3430SDP dev board. diff --git a/board/omap3430sdp/omap3430sdp.c b/board/omap3430sdp/omap3430sdp.c index bfa61dc..bb6070e 100644 --- a/board/omap3430sdp/omap3430sdp.c +++ b/board/omap3430sdp/omap3430sdp.c @@ -97,23 +97,6 @@ u32 cpu_is_3410(void) } } -/********************************************************************* - * wait_on_value() - common routine to allow waiting for changes in - * volatile regs. - *********************************************************************/ -u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) -{ - u32 i = 0, val; - do { - ++i; - val = __raw_readl(read_addr) & read_bit_mask; - if (val == match_value) - return (1); - if (i == bound) - return (0); - } while (1); -} - #ifdef CFG_3430SDRAM_DDR /********************************************************************* * config_3430sdram_ddr() - Init DDR on 3430SDP dev board. diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c index 5659f3b..5a97d96 100644 --- a/board/omap3530beagle/omap3530beagle.c +++ b/board/omap3530beagle/omap3530beagle.c @@ -209,23 +209,6 @@ int beagle_revision(void) return rev; } -/********************************************************************* - * wait_on_value() - common routine to allow waiting for changes in - * volatile regs. - *********************************************************************/ -u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) -{ - u32 i = 0, val; - do { - ++i; - val = __raw_readl(read_addr) & read_bit_mask; - if (val == match_value) - return 1; - if (i == bound) - return 0; - } while (1); -} - #ifdef CFG_3430SDRAM_DDR #define MICRON_DDR 0 diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c index 4265da1..5071046 100644 --- a/board/omap3evm/omap3evm.c +++ b/board/omap3evm/omap3evm.c @@ -141,23 +141,6 @@ u32 cpu_is_3410(void) } } -/********************************************************************* - * wait_on_value() - common routine to allow waiting for changes in - * volatile regs. - *********************************************************************/ -u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) -{ - u32 i = 0, val; - do { - ++i; - val = __raw_readl(read_addr) & read_bit_mask; - if (val == match_value) - return (1); - if (i == bound) - return (0); - } while (1); -} - #ifdef CFG_3430SDRAM_DDR /********************************************************************* * config_3430sdram_ddr() - Init DDR on 3430SDP dev board. diff --git a/board/overo/overo.c b/board/overo/overo.c index 3b61335..e7ac7a6 100644 --- a/board/overo/overo.c +++ b/board/overo/overo.c @@ -200,23 +200,6 @@ int get_board_revision(void) return revision; } -/********************************************************************* - * wait_on_value() - common routine to allow waiting for changes in - * volatile regs. - *********************************************************************/ -u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) -{ - u32 i = 0, val; - do { - ++i; - val = __raw_readl(read_addr) & read_bit_mask; - if (val == match_value) - return 1; - if (i == bound) - return 0; - } while (1); -} - #ifdef CFG_3430SDRAM_DDR /********************************************************************* * config_3430sdram_ddr() - Init DDR on 3430SDP dev board. diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c index bcf5f8e..d6568a9 100644 --- a/cpu/omap3/sys_info.c +++ b/cpu/omap3/sys_info.c @@ -47,6 +47,23 @@ void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value) __raw_writel(tmp, addr); } +/* + * wait_on_value(): common routine to allow waiting for changes in + * volatile regs. + */ +u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound) +{ + u32 i = 0, val; + do { + ++i; + val = __raw_readl(read_addr) & read_bit_mask; + if (val == match_value) + return 1; + if (i == bound) + return 0; + } while (1); +} + /* * get_device_type(): tell if GP/HS/EMU/TST */ -- 2.39.5