2 * Copyright 2012 Freescale Semiconductor, Inc.
3 * Author: Matthew McClintock <msm@freescale.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 #include <asm/processor.h>
25 #include <asm/global_data.h>
27 DECLARE_GLOBAL_DATA_PTR;
29 #ifndef CONFIG_SYS_FSL_TBCLK_DIV
30 #define CONFIG_SYS_FSL_TBCLK_DIV 8
33 void udelay(unsigned long usec)
35 u32 ticks_per_usec = gd->bus_clk / (CONFIG_SYS_FSL_TBCLK_DIV * 1000000);
36 u32 ticks = ticks_per_usec * usec;
37 u32 s = mfspr(SPRN_TBRL);
39 while ((mfspr(SPRN_TBRL) - s) < ticks);