Commit | Line | Data |
---|---|---|
355c471f | 1 | /* |
355c471f | 2 | * Copyright (C) NEC Electronics Corporation 2004-2006 |
3 | * | |
4 | * This file is based on the arch/mips/ddb5xxx/ddb5477/setup.c. | |
5 | * | |
6 | * Copyright 2001 MontaVista Software Inc. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
355c471f | 22 | #include <linux/init.h> |
23 | #include <linux/kernel.h> | |
24 | #include <linux/types.h> | |
2841d8b8 | 25 | |
355c471f | 26 | #include <asm/time.h> |
355c471f | 27 | #include <asm/reboot.h> |
355c471f | 28 | |
d91f2cbe | 29 | #include <asm/emma/emma2rh.h> |
355c471f | 30 | |
31 | #define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */ | |
32 | ||
33 | extern void markeins_led(const char *); | |
34 | ||
982f6ffe | 35 | static int bus_frequency; |
355c471f | 36 | |
37 | static void markeins_machine_restart(char *command) | |
38 | { | |
39 | static void (*back_to_prom) (void) = (void (*)(void))0xbfc00000; | |
40 | ||
41 | printk("cannot EMMA2RH Mark-eins restart.\n"); | |
42 | markeins_led("restart."); | |
43 | back_to_prom(); | |
44 | } | |
45 | ||
46 | static void markeins_machine_halt(void) | |
47 | { | |
48 | printk("EMMA2RH Mark-eins halted.\n"); | |
49 | markeins_led("halted."); | |
50 | while (1) ; | |
51 | } | |
52 | ||
53 | static void markeins_machine_power_off(void) | |
54 | { | |
55 | printk("EMMA2RH Mark-eins halted. Please turn off the power.\n"); | |
56 | markeins_led("poweroff."); | |
57 | while (1) ; | |
58 | } | |
59 | ||
b01273f1 AB |
60 | static unsigned long __initdata emma2rh_clock[4] = { |
61 | 166500000, 187312500, 199800000, 210600000 | |
62 | }; | |
355c471f | 63 | |
64 | static unsigned int __init detect_bus_frequency(unsigned long rtc_base) | |
65 | { | |
66 | u32 reg; | |
67 | ||
68 | /* detect from boot strap */ | |
69 | reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0); | |
70 | reg = (reg >> 4) & 0x3; | |
b01273f1 AB |
71 | |
72 | return emma2rh_clock[reg]; | |
355c471f | 73 | } |
74 | ||
4b550488 | 75 | void __init plat_time_init(void) |
355c471f | 76 | { |
77 | u32 reg; | |
78 | if (bus_frequency == 0) | |
79 | bus_frequency = detect_bus_frequency(0); | |
80 | ||
81 | reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0); | |
82 | if ((reg & 0x3) == 0) | |
83 | reg = (reg >> 6) & 0x3; | |
84 | else { | |
85 | reg = emma2rh_in32(EMMA2RH_BHIF_MAIN_CTRL); | |
86 | reg = (reg >> 4) & 0x3; | |
87 | } | |
88 | mips_hpt_frequency = (bus_frequency * (4 + reg)) / 4 / 2; | |
89 | } | |
90 | ||
355c471f | 91 | static void markeins_board_init(void); |
92 | extern void markeins_irq_setup(void); | |
93 | ||
94 | static void inline __init markeins_sio_setup(void) | |
95 | { | |
355c471f | 96 | } |
97 | ||
98 | void __init plat_mem_setup(void) | |
99 | { | |
100 | /* initialize board - we don't trust the loader */ | |
101 | markeins_board_init(); | |
102 | ||
103 | set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE)); | |
104 | ||
355c471f | 105 | _machine_restart = markeins_machine_restart; |
106 | _machine_halt = markeins_machine_halt; | |
107 | pm_power_off = markeins_machine_power_off; | |
108 | ||
109 | /* setup resource limits */ | |
110 | ioport_resource.start = EMMA2RH_PCI_IO_BASE; | |
111 | ioport_resource.end = EMMA2RH_PCI_IO_BASE + EMMA2RH_PCI_IO_SIZE - 1; | |
112 | iomem_resource.start = EMMA2RH_IO_BASE; | |
113 | iomem_resource.end = EMMA2RH_ROM_BASE - 1; | |
114 | ||
115 | /* Reboot on panic */ | |
116 | panic_timeout = 180; | |
117 | ||
118 | markeins_sio_setup(); | |
119 | } | |
120 | ||
121 | static void __init markeins_board_init(void) | |
122 | { | |
123 | u32 val; | |
124 | ||
125 | val = emma2rh_in32(EMMA2RH_PBRD_INT_EN); /* open serial interrupts. */ | |
126 | emma2rh_out32(EMMA2RH_PBRD_INT_EN, val | 0xaa); | |
127 | val = emma2rh_in32(EMMA2RH_PBRD_CLKSEL); /* set serial clocks. */ | |
128 | emma2rh_out32(EMMA2RH_PBRD_CLKSEL, val | 0x5); /* 18MHz */ | |
129 | emma2rh_out32(EMMA2RH_PCI_CONTROL, 0); | |
130 | ||
131 | markeins_led("MVL E2RH"); | |
132 | } |