1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) NEC Electronics Corporation 2004-2006
5 * This file is based on the arch/mips/ddb5xxx/ddb5477/setup.c.
7 * Copyright 2001 MontaVista Software Inc.
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/types.h>
14 #include <asm/reboot.h>
16 #include <asm/emma/emma2rh.h>
18 #define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */
20 extern void markeins_led(const char *);
22 static int bus_frequency
;
24 static void markeins_machine_restart(char *command
)
26 static void (*back_to_prom
) (void) = (void (*)(void))0xbfc00000;
28 printk("cannot EMMA2RH Mark-eins restart.\n");
29 markeins_led("restart.");
33 static void markeins_machine_halt(void)
35 printk("EMMA2RH Mark-eins halted.\n");
36 markeins_led("halted.");
40 static void markeins_machine_power_off(void)
42 markeins_led("poweroff.");
46 static unsigned long __initdata emma2rh_clock
[4] = {
47 166500000, 187312500, 199800000, 210600000
50 static unsigned int __init
detect_bus_frequency(unsigned long rtc_base
)
54 /* detect from boot strap */
55 reg
= emma2rh_in32(EMMA2RH_BHIF_STRAP_0
);
56 reg
= (reg
>> 4) & 0x3;
58 return emma2rh_clock
[reg
];
61 void __init
plat_time_init(void)
64 if (bus_frequency
== 0)
65 bus_frequency
= detect_bus_frequency(0);
67 reg
= emma2rh_in32(EMMA2RH_BHIF_STRAP_0
);
69 reg
= (reg
>> 6) & 0x3;
71 reg
= emma2rh_in32(EMMA2RH_BHIF_MAIN_CTRL
);
72 reg
= (reg
>> 4) & 0x3;
74 mips_hpt_frequency
= (bus_frequency
* (4 + reg
)) / 4 / 2;
77 static void markeins_board_init(void);
78 extern void markeins_irq_setup(void);
80 static inline void __init
markeins_sio_setup(void)
84 void __init
plat_mem_setup(void)
86 /* initialize board - we don't trust the loader */
87 markeins_board_init();
89 set_io_port_base(KSEG1ADDR(EMMA2RH_PCI_IO_BASE
));
91 _machine_restart
= markeins_machine_restart
;
92 _machine_halt
= markeins_machine_halt
;
93 pm_power_off
= markeins_machine_power_off
;
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;
101 markeins_sio_setup();
104 static void __init
markeins_board_init(void)
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);
114 markeins_led("MVL E2RH");