]>
Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
355c471f | 2 | /* |
355c471f | 3 | * Copyright (C) NEC Electronics Corporation 2004-2006 |
4 | * | |
5 | * This file is based on the arch/mips/ddb5xxx/ddb5477/setup.c. | |
6 | * | |
7 | * Copyright 2001 MontaVista Software Inc. | |
355c471f | 8 | */ |
355c471f | 9 | #include <linux/init.h> |
10 | #include <linux/kernel.h> | |
11 | #include <linux/types.h> | |
2841d8b8 | 12 | |
355c471f | 13 | #include <asm/time.h> |
355c471f | 14 | #include <asm/reboot.h> |
355c471f | 15 | |
d91f2cbe | 16 | #include <asm/emma/emma2rh.h> |
355c471f | 17 | |
70342287 | 18 | #define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */ |
355c471f | 19 | |
20 | extern void markeins_led(const char *); | |
21 | ||
982f6ffe | 22 | static int bus_frequency; |
355c471f | 23 | |
24 | static void markeins_machine_restart(char *command) | |
25 | { | |
26 | static void (*back_to_prom) (void) = (void (*)(void))0xbfc00000; | |
27 | ||
28 | printk("cannot EMMA2RH Mark-eins restart.\n"); | |
29 | markeins_led("restart."); | |
30 | back_to_prom(); | |
31 | } | |
32 | ||
33 | static void markeins_machine_halt(void) | |
34 | { | |
35 | printk("EMMA2RH Mark-eins halted.\n"); | |
36 | markeins_led("halted."); | |
37 | while (1) ; | |
38 | } | |
39 | ||
40 | static void markeins_machine_power_off(void) | |
41 | { | |
355c471f | 42 | markeins_led("poweroff."); |
43 | while (1) ; | |
44 | } | |
45 | ||
b01273f1 AB |
46 | static unsigned long __initdata emma2rh_clock[4] = { |
47 | 166500000, 187312500, 199800000, 210600000 | |
48 | }; | |
355c471f | 49 | |
50 | static unsigned int __init detect_bus_frequency(unsigned long rtc_base) | |
51 | { | |
52 | u32 reg; | |
53 | ||
54 | /* detect from boot strap */ | |
55 | reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0); | |
56 | reg = (reg >> 4) & 0x3; | |
b01273f1 AB |
57 | |
58 | return emma2rh_clock[reg]; | |
355c471f | 59 | } |
60 | ||
4b550488 | 61 | void __init plat_time_init(void) |
355c471f | 62 | { |
63 | u32 reg; | |
64 | if (bus_frequency == 0) | |
65 | bus_frequency = detect_bus_frequency(0); | |
66 | ||
67 | reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0); | |
68 | if ((reg & 0x3) == 0) | |
69 | reg = (reg >> 6) & 0x3; | |
70 | else { | |
71 | reg = emma2rh_in32(EMMA2RH_BHIF_MAIN_CTRL); | |
72 | reg = (reg >> 4) & 0x3; | |
73 | } | |
74 | mips_hpt_frequency = (bus_frequency * (4 + reg)) / 4 / 2; | |
75 | } | |
76 | ||
355c471f | 77 | static void markeins_board_init(void); |
78 | extern void markeins_irq_setup(void); | |
79 | ||
42b76a1d | 80 | static inline void __init markeins_sio_setup(void) |
355c471f | 81 | { |
355c471f | 82 | } |
83 | ||
84 | void __init plat_mem_setup(void) | |
85 | { | |
86 | /* initialize board - we don't trust the loader */ | |
87 | markeins_board_init(); | |
88 | ||
89 | set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE)); | |
90 | ||
355c471f | 91 | _machine_restart = markeins_machine_restart; |
92 | _machine_halt = markeins_machine_halt; | |
93 | pm_power_off = markeins_machine_power_off; | |
94 | ||
95 | /* setup resource limits */ | |
96 | ioport_resource.start = EMMA2RH_PCI_IO_BASE; | |
97 | ioport_resource.end = EMMA2RH_PCI_IO_BASE + EMMA2RH_PCI_IO_SIZE - 1; | |
98 | iomem_resource.start = EMMA2RH_IO_BASE; | |
99 | iomem_resource.end = EMMA2RH_ROM_BASE - 1; | |
100 | ||
355c471f | 101 | markeins_sio_setup(); |
102 | } | |
103 | ||
104 | static void __init markeins_board_init(void) | |
105 | { | |
106 | u32 val; | |
107 | ||
108 | val = emma2rh_in32(EMMA2RH_PBRD_INT_EN); /* open serial interrupts. */ | |
109 | emma2rh_out32(EMMA2RH_PBRD_INT_EN, val | 0xaa); | |
110 | val = emma2rh_in32(EMMA2RH_PBRD_CLKSEL); /* set serial clocks. */ | |
111 | emma2rh_out32(EMMA2RH_PBRD_CLKSEL, val | 0x5); /* 18MHz */ | |
112 | emma2rh_out32(EMMA2RH_PCI_CONTROL, 0); | |
113 | ||
114 | markeins_led("MVL E2RH"); | |
115 | } |