treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / mips / emma / markeins / setup.c
blobc8a91c2a63bc54b6b49f24816c4f8db25939839b
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
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.
8 */
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/types.h>
13 #include <asm/time.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.");
30 back_to_prom();
33 static void markeins_machine_halt(void)
35 printk("EMMA2RH Mark-eins halted.\n");
36 markeins_led("halted.");
37 while (1) ;
40 static void markeins_machine_power_off(void)
42 markeins_led("poweroff.");
43 while (1) ;
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)
52 u32 reg;
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)
63 u32 reg;
64 if (bus_frequency == 0)
65 bus_frequency = detect_bus_frequency(0);
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;
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)
106 u32 val;
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");