]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - nand_spl/board/freescale/common.c
spi: atmel: sam9m10g45 also support WDRBT bit
[karo-tx-uboot.git] / nand_spl / board / freescale / common.c
1 /*
2  * Copyright 2012 Freescale Semiconductor, Inc.
3  * Author: Matthew McClintock <msm@freescale.com>
4  *
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.
9  *
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
13  *
14  * GNU General Public License for more details.
15  *
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,
19  * MA 02111-1307 USA
20  *
21  */
22
23 #include <common.h>
24 #include <asm/processor.h>
25 #include <asm/global_data.h>
26
27 DECLARE_GLOBAL_DATA_PTR;
28
29 #ifndef CONFIG_SYS_FSL_TBCLK_DIV
30 #define CONFIG_SYS_FSL_TBCLK_DIV 8
31 #endif
32
33 void udelay(unsigned long usec)
34 {
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);
38
39         while ((mfspr(SPRN_TBRL) - s) < ticks);
40 }