2 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
10 #include <linux/types.h>
11 #include <linux/kernel.h>
12 #include <linux/init.h>
15 #include <asm/bootinfo.h>
16 #include <asm/addrspace.h>
18 #include <asm/mach-adm5120/adm5120_info.h>
19 #include <asm/mach-adm5120/adm5120_defs.h>
20 #include <asm/mach-adm5120/adm5120_switch.h>
22 unsigned int adm5120_product_code
;
23 unsigned int adm5120_revision
;
24 unsigned int adm5120_package
;
25 unsigned int adm5120_nand_boot
;
26 unsigned long adm5120_speed
;
29 * CPU settings detection
31 #define CODE_GET_PC(c) ((c) & CODE_PC_MASK)
32 #define CODE_GET_REV(c) (((c) >> CODE_REV_SHIFT) & CODE_REV_MASK)
33 #define CODE_GET_PK(c) (((c) >> CODE_PK_SHIFT) & CODE_PK_MASK)
34 #define CODE_GET_CLKS(c) (((c) >> CODE_CLKS_SHIFT) & CODE_CLKS_MASK)
35 #define CODE_GET_NAB(c) (((c) & CODE_NAB) != 0)
37 void adm5120_ndelay(u32 ns
)
41 SW_WRITE_REG(SWITCH_REG_TIMER
, TIMER_PERIOD_DEFAULT
);
42 SW_WRITE_REG(SWITCH_REG_TIMER_INT
, (TIMER_INT_TOS
| TIMER_INT_TOM
));
45 t
&= TIMER_PERIOD_MASK
;
46 SW_WRITE_REG(SWITCH_REG_TIMER
, t
| TIMER_TE
);
48 /* wait until the timer expires */
50 t
= SW_READ_REG(SWITCH_REG_TIMER_INT
);
51 } while ((t
& TIMER_INT_TOS
) == 0);
53 /* leave the timer disabled */
54 SW_WRITE_REG(SWITCH_REG_TIMER
, TIMER_PERIOD_DEFAULT
);
55 SW_WRITE_REG(SWITCH_REG_TIMER_INT
, (TIMER_INT_TOS
| TIMER_INT_TOM
));
58 void __init
adm5120_soc_init(void)
63 code
= SW_READ_REG(SWITCH_REG_CODE
);
65 adm5120_product_code
= CODE_GET_PC(code
);
66 adm5120_revision
= CODE_GET_REV(code
);
67 adm5120_package
= (CODE_GET_PK(code
) == CODE_PK_BGA
) ?
68 ADM5120_PACKAGE_BGA
: ADM5120_PACKAGE_PQFP
;
69 adm5120_nand_boot
= CODE_GET_NAB(code
);
71 clks
= CODE_GET_CLKS(code
);
72 adm5120_speed
= ADM5120_SPEED_175
;
74 adm5120_speed
+= 25000000;
76 adm5120_speed
+= 50000000;