4 * Copyright (C) 2007 OpenWrt.org
5 * Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #include <linux/types.h>
25 #include <linux/kernel.h>
26 #include <linux/init.h>
29 #include <asm/bootinfo.h>
30 #include <asm/addrspace.h>
32 #include <adm5120_info.h>
33 #include <adm5120_defs.h>
34 #include <adm5120_switch.h>
36 unsigned int adm5120_product_code
;
37 unsigned int adm5120_revision
;
38 unsigned int adm5120_package
;
39 unsigned int adm5120_nand_boot
;
40 unsigned long adm5120_speed
;
43 * CPU settings detection
45 #define CODE_GET_PC(c) ((c) & CODE_PC_MASK)
46 #define CODE_GET_REV(c) (((c) >> CODE_REV_SHIFT) & CODE_REV_MASK)
47 #define CODE_GET_PK(c) (((c) >> CODE_PK_SHIFT) & CODE_PK_MASK)
48 #define CODE_GET_CLKS(c) (((c) >> CODE_CLKS_SHIFT) & CODE_CLKS_MASK)
49 #define CODE_GET_NAB(c) (((c) & CODE_NAB) != 0)
51 void adm5120_ndelay(u32 ns
)
55 SW_WRITE_REG(SWITCH_REG_TIMER
, TIMER_PERIOD_DEFAULT
);
56 SW_WRITE_REG(SWITCH_REG_TIMER_INT
, (TIMER_INT_TOS
| TIMER_INT_TOM
));
59 t
&= TIMER_PERIOD_MASK
;
60 SW_WRITE_REG(SWITCH_REG_TIMER
, t
| TIMER_TE
);
62 /* wait until the timer expires */
64 t
= SW_READ_REG(SWITCH_REG_TIMER_INT
);
65 } while ((t
& TIMER_INT_TOS
) == 0);
67 /* leave the timer disabled */
68 SW_WRITE_REG(SWITCH_REG_TIMER
, TIMER_PERIOD_DEFAULT
);
69 SW_WRITE_REG(SWITCH_REG_TIMER_INT
, (TIMER_INT_TOS
| TIMER_INT_TOM
));
72 void __init
adm5120_soc_init(void)
77 code
= SW_READ_REG(SWITCH_REG_CODE
);
79 adm5120_product_code
= CODE_GET_PC(code
);
80 adm5120_revision
= CODE_GET_REV(code
);
81 adm5120_package
= (CODE_GET_PK(code
) == CODE_PK_BGA
) ?
82 ADM5120_PACKAGE_BGA
: ADM5120_PACKAGE_PQFP
;
83 adm5120_nand_boot
= CODE_GET_NAB(code
);
85 clks
= CODE_GET_CLKS(code
);
86 adm5120_speed
= ADM5120_SPEED_175
;
88 adm5120_speed
+= 25000000;
90 adm5120_speed
+= 50000000;
This page took 0.04095 seconds and 5 git commands to generate.