diff options
author | 2025-03-08 22:04:20 +0800 | |
---|---|---|
committer | 2025-03-08 22:04:20 +0800 | |
commit | a07bb8fd1299070229f0e8f3dcb57ffd5ef9870a (patch) | |
tree | 84f21bd0bf7071bc5fc7dd989e77d7ceb5476682 /arch/mips/cobalt | |
download | ohosKernel-a07bb8fd1299070229f0e8f3dcb57ffd5ef9870a.tar.gz ohosKernel-a07bb8fd1299070229f0e8f3dcb57ffd5ef9870a.zip |
Initial commit: OpenHarmony-v4.0-ReleaseOpenHarmony-v4.0-Release
Diffstat (limited to 'arch/mips/cobalt')
-rw-r--r-- | arch/mips/cobalt/Makefile | 8 | ||||
-rw-r--r-- | arch/mips/cobalt/Platform | 5 | ||||
-rw-r--r-- | arch/mips/cobalt/buttons.c | 41 | ||||
-rw-r--r-- | arch/mips/cobalt/irq.c | 64 | ||||
-rw-r--r-- | arch/mips/cobalt/lcd.c | 42 | ||||
-rw-r--r-- | arch/mips/cobalt/led.c | 49 | ||||
-rw-r--r-- | arch/mips/cobalt/mtd.c | 47 | ||||
-rw-r--r-- | arch/mips/cobalt/pci.c | 48 | ||||
-rw-r--r-- | arch/mips/cobalt/reset.c | 52 | ||||
-rw-r--r-- | arch/mips/cobalt/rtc.c | 51 | ||||
-rw-r--r-- | arch/mips/cobalt/serial.c | 73 | ||||
-rw-r--r-- | arch/mips/cobalt/setup.c | 124 | ||||
-rw-r--r-- | arch/mips/cobalt/time.c | 41 |
13 files changed, 645 insertions, 0 deletions
diff --git a/arch/mips/cobalt/Makefile b/arch/mips/cobalt/Makefile new file mode 100644 index 000000000..f0e2c26c8 --- /dev/null +++ b/arch/mips/cobalt/Makefile | |||
@@ -0,0 +1,8 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0-only | ||
2 | # | ||
3 | # Makefile for the Cobalt micro systems family specific parts of the kernel | ||
4 | # | ||
5 | |||
6 | obj-y := buttons.o irq.o lcd.o led.o mtd.o reset.o rtc.o serial.o setup.o time.o | ||
7 | |||
8 | obj-$(CONFIG_PCI) += pci.o | ||
diff --git a/arch/mips/cobalt/Platform b/arch/mips/cobalt/Platform new file mode 100644 index 000000000..4254895ad --- /dev/null +++ b/arch/mips/cobalt/Platform | |||
@@ -0,0 +1,5 @@ | |||
1 | # | ||
2 | # Cobalt Server | ||
3 | # | ||
4 | cflags-$(CONFIG_MIPS_COBALT) += -I$(srctree)/arch/mips/include/asm/mach-cobalt | ||
5 | load-$(CONFIG_MIPS_COBALT) += 0xffffffff80080000 | ||
diff --git a/arch/mips/cobalt/buttons.c b/arch/mips/cobalt/buttons.c new file mode 100644 index 000000000..0f9299fe5 --- /dev/null +++ b/arch/mips/cobalt/buttons.c | |||
@@ -0,0 +1,41 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Cobalt buttons platform device. | ||
4 | * | ||
5 | * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> | ||
6 | */ | ||
7 | |||
8 | #include <linux/platform_device.h> | ||
9 | #include <linux/errno.h> | ||
10 | #include <linux/init.h> | ||
11 | |||
12 | static struct resource cobalt_buttons_resource __initdata = { | ||
13 | .start = 0x1d000000, | ||
14 | .end = 0x1d000003, | ||
15 | .flags = IORESOURCE_MEM, | ||
16 | }; | ||
17 | |||
18 | static __init int cobalt_add_buttons(void) | ||
19 | { | ||
20 | struct platform_device *pd; | ||
21 | int error; | ||
22 | |||
23 | pd = platform_device_alloc("Cobalt buttons", -1); | ||
24 | if (!pd) | ||
25 | return -ENOMEM; | ||
26 | |||
27 | error = platform_device_add_resources(pd, &cobalt_buttons_resource, 1); | ||
28 | if (error) | ||
29 | goto err_free_device; | ||
30 | |||
31 | error = platform_device_add(pd); | ||
32 | if (error) | ||
33 | goto err_free_device; | ||
34 | |||
35 | return 0; | ||
36 | |||
37 | err_free_device: | ||
38 | platform_device_put(pd); | ||
39 | return error; | ||
40 | } | ||
41 | device_initcall(cobalt_add_buttons); | ||
diff --git a/arch/mips/cobalt/irq.c b/arch/mips/cobalt/irq.c new file mode 100644 index 000000000..ead5ae413 --- /dev/null +++ b/arch/mips/cobalt/irq.c | |||
@@ -0,0 +1,64 @@ | |||
1 | /* | ||
2 | * IRQ vector handles | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1995, 1996, 1997, 2003 by Ralf Baechle | ||
9 | */ | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/irq.h> | ||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/pci.h> | ||
15 | |||
16 | #include <asm/i8259.h> | ||
17 | #include <asm/irq_cpu.h> | ||
18 | #include <asm/irq_gt641xx.h> | ||
19 | #include <asm/gt64120.h> | ||
20 | |||
21 | #include <irq.h> | ||
22 | |||
23 | asmlinkage void plat_irq_dispatch(void) | ||
24 | { | ||
25 | unsigned pending = read_c0_status() & read_c0_cause() & ST0_IM; | ||
26 | int irq; | ||
27 | |||
28 | if (pending & CAUSEF_IP2) | ||
29 | gt641xx_irq_dispatch(); | ||
30 | else if (pending & CAUSEF_IP6) { | ||
31 | irq = i8259_irq(); | ||
32 | if (irq < 0) | ||
33 | spurious_interrupt(); | ||
34 | else | ||
35 | do_IRQ(irq); | ||
36 | } else if (pending & CAUSEF_IP3) | ||
37 | do_IRQ(MIPS_CPU_IRQ_BASE + 3); | ||
38 | else if (pending & CAUSEF_IP4) | ||
39 | do_IRQ(MIPS_CPU_IRQ_BASE + 4); | ||
40 | else if (pending & CAUSEF_IP5) | ||
41 | do_IRQ(MIPS_CPU_IRQ_BASE + 5); | ||
42 | else if (pending & CAUSEF_IP7) | ||
43 | do_IRQ(MIPS_CPU_IRQ_BASE + 7); | ||
44 | else | ||
45 | spurious_interrupt(); | ||
46 | } | ||
47 | |||
48 | void __init arch_init_irq(void) | ||
49 | { | ||
50 | mips_cpu_irq_init(); | ||
51 | gt641xx_irq_init(); | ||
52 | init_i8259_irqs(); | ||
53 | |||
54 | if (request_irq(GT641XX_CASCADE_IRQ, no_action, IRQF_NO_THREAD, | ||
55 | "cascade", NULL)) { | ||
56 | pr_err("Failed to request irq %d (cascade)\n", | ||
57 | GT641XX_CASCADE_IRQ); | ||
58 | } | ||
59 | if (request_irq(I8259_CASCADE_IRQ, no_action, IRQF_NO_THREAD, | ||
60 | "cascade", NULL)) { | ||
61 | pr_err("Failed to request irq %d (cascade)\n", | ||
62 | I8259_CASCADE_IRQ); | ||
63 | } | ||
64 | } | ||
diff --git a/arch/mips/cobalt/lcd.c b/arch/mips/cobalt/lcd.c new file mode 100644 index 000000000..7d43b5ec3 --- /dev/null +++ b/arch/mips/cobalt/lcd.c | |||
@@ -0,0 +1,42 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Registration of Cobalt LCD platform device. | ||
4 | * | ||
5 | * Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org> | ||
6 | */ | ||
7 | #include <linux/errno.h> | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/ioport.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | |||
12 | static struct resource cobalt_lcd_resource __initdata = { | ||
13 | .start = 0x1f000000, | ||
14 | .end = 0x1f00001f, | ||
15 | .flags = IORESOURCE_MEM, | ||
16 | }; | ||
17 | |||
18 | static __init int cobalt_lcd_add(void) | ||
19 | { | ||
20 | struct platform_device *pdev; | ||
21 | int retval; | ||
22 | |||
23 | pdev = platform_device_alloc("cobalt-lcd", -1); | ||
24 | if (!pdev) | ||
25 | return -ENOMEM; | ||
26 | |||
27 | retval = platform_device_add_resources(pdev, &cobalt_lcd_resource, 1); | ||
28 | if (retval) | ||
29 | goto err_free_device; | ||
30 | |||
31 | retval = platform_device_add(pdev); | ||
32 | if (retval) | ||
33 | goto err_free_device; | ||
34 | |||
35 | return 0; | ||
36 | |||
37 | err_free_device: | ||
38 | platform_device_put(pdev); | ||
39 | |||
40 | return retval; | ||
41 | } | ||
42 | device_initcall(cobalt_lcd_add); | ||
diff --git a/arch/mips/cobalt/led.c b/arch/mips/cobalt/led.c new file mode 100644 index 000000000..196660cac --- /dev/null +++ b/arch/mips/cobalt/led.c | |||
@@ -0,0 +1,49 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Registration of Cobalt LED platform device. | ||
4 | * | ||
5 | * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> | ||
6 | */ | ||
7 | #include <linux/errno.h> | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/ioport.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | |||
12 | #include <cobalt.h> | ||
13 | |||
14 | static struct resource cobalt_led_resource __initdata = { | ||
15 | .start = 0x1c000000, | ||
16 | .end = 0x1c000000, | ||
17 | .flags = IORESOURCE_MEM, | ||
18 | }; | ||
19 | |||
20 | static __init int cobalt_led_add(void) | ||
21 | { | ||
22 | struct platform_device *pdev; | ||
23 | int retval; | ||
24 | |||
25 | if (cobalt_board_id == COBALT_BRD_ID_QUBE1 || | ||
26 | cobalt_board_id == COBALT_BRD_ID_QUBE2) | ||
27 | pdev = platform_device_alloc("cobalt-qube-leds", -1); | ||
28 | else | ||
29 | pdev = platform_device_alloc("cobalt-raq-leds", -1); | ||
30 | |||
31 | if (!pdev) | ||
32 | return -ENOMEM; | ||
33 | |||
34 | retval = platform_device_add_resources(pdev, &cobalt_led_resource, 1); | ||
35 | if (retval) | ||
36 | goto err_free_device; | ||
37 | |||
38 | retval = platform_device_add(pdev); | ||
39 | if (retval) | ||
40 | goto err_free_device; | ||
41 | |||
42 | return 0; | ||
43 | |||
44 | err_free_device: | ||
45 | platform_device_put(pdev); | ||
46 | |||
47 | return retval; | ||
48 | } | ||
49 | device_initcall(cobalt_led_add); | ||
diff --git a/arch/mips/cobalt/mtd.c b/arch/mips/cobalt/mtd.c new file mode 100644 index 000000000..95f579d8c --- /dev/null +++ b/arch/mips/cobalt/mtd.c | |||
@@ -0,0 +1,47 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Registration of Cobalt MTD device. | ||
4 | * | ||
5 | * Copyright (C) 2006 Yoichi Yuasa <yuasa@linux-mips.org> | ||
6 | */ | ||
7 | #include <linux/init.h> | ||
8 | #include <linux/platform_device.h> | ||
9 | #include <linux/mtd/partitions.h> | ||
10 | #include <linux/mtd/physmap.h> | ||
11 | |||
12 | static struct mtd_partition cobalt_mtd_partitions[] = { | ||
13 | { | ||
14 | .name = "firmware", | ||
15 | .offset = 0x0, | ||
16 | .size = 0x80000, | ||
17 | }, | ||
18 | }; | ||
19 | |||
20 | static struct physmap_flash_data cobalt_flash_data = { | ||
21 | .width = 1, | ||
22 | .nr_parts = 1, | ||
23 | .parts = cobalt_mtd_partitions, | ||
24 | }; | ||
25 | |||
26 | static struct resource cobalt_mtd_resource = { | ||
27 | .start = 0x1fc00000, | ||
28 | .end = 0x1fc7ffff, | ||
29 | .flags = IORESOURCE_MEM, | ||
30 | }; | ||
31 | |||
32 | static struct platform_device cobalt_mtd = { | ||
33 | .name = "physmap-flash", | ||
34 | .dev = { | ||
35 | .platform_data = &cobalt_flash_data, | ||
36 | }, | ||
37 | .num_resources = 1, | ||
38 | .resource = &cobalt_mtd_resource, | ||
39 | }; | ||
40 | |||
41 | static int __init cobalt_mtd_init(void) | ||
42 | { | ||
43 | platform_device_register(&cobalt_mtd); | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | device_initcall(cobalt_mtd_init); | ||
diff --git a/arch/mips/cobalt/pci.c b/arch/mips/cobalt/pci.c new file mode 100644 index 000000000..85ec9cc31 --- /dev/null +++ b/arch/mips/cobalt/pci.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Register PCI controller. | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1996, 1997, 2004, 05 by Ralf Baechle (ralf@linux-mips.org) | ||
9 | * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv) | ||
10 | * | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/pci.h> | ||
14 | |||
15 | #include <asm/gt64120.h> | ||
16 | |||
17 | extern struct pci_ops gt64xxx_pci0_ops; | ||
18 | |||
19 | static struct resource cobalt_mem_resource = { | ||
20 | .start = GT_DEF_PCI0_MEM0_BASE, | ||
21 | .end = GT_DEF_PCI0_MEM0_BASE + GT_DEF_PCI0_MEM0_SIZE - 1, | ||
22 | .name = "PCI memory", | ||
23 | .flags = IORESOURCE_MEM, | ||
24 | }; | ||
25 | |||
26 | static struct resource cobalt_io_resource = { | ||
27 | .start = 0x1000, | ||
28 | .end = 0xffffffUL, | ||
29 | .name = "PCI I/O", | ||
30 | .flags = IORESOURCE_IO, | ||
31 | }; | ||
32 | |||
33 | static struct pci_controller cobalt_pci_controller = { | ||
34 | .pci_ops = >64xxx_pci0_ops, | ||
35 | .mem_resource = &cobalt_mem_resource, | ||
36 | .io_resource = &cobalt_io_resource, | ||
37 | .io_offset = 0 - GT_DEF_PCI0_IO_BASE, | ||
38 | .io_map_base = CKSEG1ADDR(GT_DEF_PCI0_IO_BASE), | ||
39 | }; | ||
40 | |||
41 | static int __init cobalt_pci_init(void) | ||
42 | { | ||
43 | register_pci_controller(&cobalt_pci_controller); | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | arch_initcall(cobalt_pci_init); | ||
diff --git a/arch/mips/cobalt/reset.c b/arch/mips/cobalt/reset.c new file mode 100644 index 000000000..4eedd481d --- /dev/null +++ b/arch/mips/cobalt/reset.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Cobalt Reset operations | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1995, 1996, 1997 by Ralf Baechle | ||
9 | * Copyright (C) 2001 by Liam Davies (ldavies@agile.tv) | ||
10 | */ | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/io.h> | ||
13 | #include <linux/leds.h> | ||
14 | |||
15 | #include <asm/idle.h> | ||
16 | #include <asm/processor.h> | ||
17 | |||
18 | #include <cobalt.h> | ||
19 | |||
20 | #define RESET_PORT ((void __iomem *)CKSEG1ADDR(0x1c000000)) | ||
21 | #define RESET 0x0f | ||
22 | |||
23 | DEFINE_LED_TRIGGER(power_off_led_trigger); | ||
24 | |||
25 | static int __init ledtrig_power_off_init(void) | ||
26 | { | ||
27 | led_trigger_register_simple("power-off", &power_off_led_trigger); | ||
28 | return 0; | ||
29 | } | ||
30 | device_initcall(ledtrig_power_off_init); | ||
31 | |||
32 | void cobalt_machine_halt(void) | ||
33 | { | ||
34 | /* | ||
35 | * turn on power off LED on RaQ | ||
36 | */ | ||
37 | led_trigger_event(power_off_led_trigger, LED_FULL); | ||
38 | |||
39 | local_irq_disable(); | ||
40 | while (1) { | ||
41 | if (cpu_wait) | ||
42 | cpu_wait(); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | void cobalt_machine_restart(char *command) | ||
47 | { | ||
48 | writeb(RESET, RESET_PORT); | ||
49 | |||
50 | /* we should never get here */ | ||
51 | cobalt_machine_halt(); | ||
52 | } | ||
diff --git a/arch/mips/cobalt/rtc.c b/arch/mips/cobalt/rtc.c new file mode 100644 index 000000000..0f9ca45da --- /dev/null +++ b/arch/mips/cobalt/rtc.c | |||
@@ -0,0 +1,51 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Registration of Cobalt RTC platform device. | ||
4 | * | ||
5 | * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> | ||
6 | */ | ||
7 | #include <linux/errno.h> | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/ioport.h> | ||
10 | #include <linux/mc146818rtc.h> | ||
11 | #include <linux/platform_device.h> | ||
12 | |||
13 | static struct resource cobalt_rtc_resource[] __initdata = { | ||
14 | { | ||
15 | .start = 0x70, | ||
16 | .end = 0x77, | ||
17 | .flags = IORESOURCE_IO, | ||
18 | }, | ||
19 | { | ||
20 | .start = RTC_IRQ, | ||
21 | .end = RTC_IRQ, | ||
22 | .flags = IORESOURCE_IRQ, | ||
23 | }, | ||
24 | }; | ||
25 | |||
26 | static __init int cobalt_rtc_add(void) | ||
27 | { | ||
28 | struct platform_device *pdev; | ||
29 | int retval; | ||
30 | |||
31 | pdev = platform_device_alloc("rtc_cmos", -1); | ||
32 | if (!pdev) | ||
33 | return -ENOMEM; | ||
34 | |||
35 | retval = platform_device_add_resources(pdev, cobalt_rtc_resource, | ||
36 | ARRAY_SIZE(cobalt_rtc_resource)); | ||
37 | if (retval) | ||
38 | goto err_free_device; | ||
39 | |||
40 | retval = platform_device_add(pdev); | ||
41 | if (retval) | ||
42 | goto err_free_device; | ||
43 | |||
44 | return 0; | ||
45 | |||
46 | err_free_device: | ||
47 | platform_device_put(pdev); | ||
48 | |||
49 | return retval; | ||
50 | } | ||
51 | device_initcall(cobalt_rtc_add); | ||
diff --git a/arch/mips/cobalt/serial.c b/arch/mips/cobalt/serial.c new file mode 100644 index 000000000..5fb676719 --- /dev/null +++ b/arch/mips/cobalt/serial.c | |||
@@ -0,0 +1,73 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Registration of Cobalt UART platform device. | ||
4 | * | ||
5 | * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> | ||
6 | */ | ||
7 | #include <linux/errno.h> | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/ioport.h> | ||
10 | #include <linux/platform_device.h> | ||
11 | #include <linux/serial_8250.h> | ||
12 | |||
13 | #include <cobalt.h> | ||
14 | #include <irq.h> | ||
15 | |||
16 | static struct resource cobalt_uart_resource[] __initdata = { | ||
17 | { | ||
18 | .start = 0x1c800000, | ||
19 | .end = 0x1c800007, | ||
20 | .flags = IORESOURCE_MEM, | ||
21 | }, | ||
22 | { | ||
23 | .start = SERIAL_IRQ, | ||
24 | .end = SERIAL_IRQ, | ||
25 | .flags = IORESOURCE_IRQ, | ||
26 | }, | ||
27 | }; | ||
28 | |||
29 | static struct plat_serial8250_port cobalt_serial8250_port[] = { | ||
30 | { | ||
31 | .irq = SERIAL_IRQ, | ||
32 | .uartclk = 18432000, | ||
33 | .iotype = UPIO_MEM, | ||
34 | .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, | ||
35 | .mapbase = 0x1c800000, | ||
36 | }, | ||
37 | {}, | ||
38 | }; | ||
39 | |||
40 | static __init int cobalt_uart_add(void) | ||
41 | { | ||
42 | struct platform_device *pdev; | ||
43 | int retval; | ||
44 | |||
45 | /* | ||
46 | * Cobalt Qube1 has no UART. | ||
47 | */ | ||
48 | if (cobalt_board_id == COBALT_BRD_ID_QUBE1) | ||
49 | return 0; | ||
50 | |||
51 | pdev = platform_device_alloc("serial8250", -1); | ||
52 | if (!pdev) | ||
53 | return -ENOMEM; | ||
54 | |||
55 | pdev->id = PLAT8250_DEV_PLATFORM; | ||
56 | pdev->dev.platform_data = cobalt_serial8250_port; | ||
57 | |||
58 | retval = platform_device_add_resources(pdev, cobalt_uart_resource, ARRAY_SIZE(cobalt_uart_resource)); | ||
59 | if (retval) | ||
60 | goto err_free_device; | ||
61 | |||
62 | retval = platform_device_add(pdev); | ||
63 | if (retval) | ||
64 | goto err_free_device; | ||
65 | |||
66 | return 0; | ||
67 | |||
68 | err_free_device: | ||
69 | platform_device_put(pdev); | ||
70 | |||
71 | return retval; | ||
72 | } | ||
73 | device_initcall(cobalt_uart_add); | ||
diff --git a/arch/mips/cobalt/setup.c b/arch/mips/cobalt/setup.c new file mode 100644 index 000000000..46581e686 --- /dev/null +++ b/arch/mips/cobalt/setup.c | |||
@@ -0,0 +1,124 @@ | |||
1 | /* | ||
2 | * Setup pointers to hardware dependent routines. | ||
3 | * | ||
4 | * This file is subject to the terms and conditions of the GNU General Public | ||
5 | * License. See the file "COPYING" in the main directory of this archive | ||
6 | * for more details. | ||
7 | * | ||
8 | * Copyright (C) 1996, 1997, 2004, 05 by Ralf Baechle (ralf@linux-mips.org) | ||
9 | * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv) | ||
10 | * | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/ioport.h> | ||
16 | #include <linux/memblock.h> | ||
17 | #include <linux/pm.h> | ||
18 | |||
19 | #include <asm/bootinfo.h> | ||
20 | #include <asm/reboot.h> | ||
21 | #include <asm/setup.h> | ||
22 | #include <asm/gt64120.h> | ||
23 | |||
24 | #include <cobalt.h> | ||
25 | |||
26 | extern void cobalt_machine_restart(char *command); | ||
27 | extern void cobalt_machine_halt(void); | ||
28 | |||
29 | const char *get_system_type(void) | ||
30 | { | ||
31 | switch (cobalt_board_id) { | ||
32 | case COBALT_BRD_ID_QUBE1: | ||
33 | return "Cobalt Qube"; | ||
34 | case COBALT_BRD_ID_RAQ1: | ||
35 | return "Cobalt RaQ"; | ||
36 | case COBALT_BRD_ID_QUBE2: | ||
37 | return "Cobalt Qube2"; | ||
38 | case COBALT_BRD_ID_RAQ2: | ||
39 | return "Cobalt RaQ2"; | ||
40 | } | ||
41 | return "MIPS Cobalt"; | ||
42 | } | ||
43 | |||
44 | /* | ||
45 | * Cobalt doesn't have PS/2 keyboard/mouse interfaces, | ||
46 | * keyboard controller is never used. | ||
47 | * Also PCI-ISA bridge DMA controller is never used. | ||
48 | */ | ||
49 | static struct resource cobalt_reserved_resources[] = { | ||
50 | { /* dma1 */ | ||
51 | .start = 0x00, | ||
52 | .end = 0x1f, | ||
53 | .name = "reserved", | ||
54 | .flags = IORESOURCE_BUSY | IORESOURCE_IO, | ||
55 | }, | ||
56 | { /* keyboard */ | ||
57 | .start = 0x60, | ||
58 | .end = 0x6f, | ||
59 | .name = "reserved", | ||
60 | .flags = IORESOURCE_BUSY | IORESOURCE_IO, | ||
61 | }, | ||
62 | { /* dma page reg */ | ||
63 | .start = 0x80, | ||
64 | .end = 0x8f, | ||
65 | .name = "reserved", | ||
66 | .flags = IORESOURCE_BUSY | IORESOURCE_IO, | ||
67 | }, | ||
68 | { /* dma2 */ | ||
69 | .start = 0xc0, | ||
70 | .end = 0xdf, | ||
71 | .name = "reserved", | ||
72 | .flags = IORESOURCE_BUSY | IORESOURCE_IO, | ||
73 | }, | ||
74 | }; | ||
75 | |||
76 | void __init plat_mem_setup(void) | ||
77 | { | ||
78 | int i; | ||
79 | |||
80 | _machine_restart = cobalt_machine_restart; | ||
81 | _machine_halt = cobalt_machine_halt; | ||
82 | pm_power_off = cobalt_machine_halt; | ||
83 | |||
84 | set_io_port_base(CKSEG1ADDR(GT_DEF_PCI0_IO_BASE)); | ||
85 | |||
86 | /* I/O port resource */ | ||
87 | ioport_resource.end = 0x01ffffff; | ||
88 | |||
89 | /* These resources have been reserved by VIA SuperI/O chip. */ | ||
90 | for (i = 0; i < ARRAY_SIZE(cobalt_reserved_resources); i++) | ||
91 | request_resource(&ioport_resource, cobalt_reserved_resources + i); | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Prom init. We read our one and only communication with the firmware. | ||
96 | * Grab the amount of installed memory. | ||
97 | * Better boot loaders (CoLo) pass a command line too :-) | ||
98 | */ | ||
99 | |||
100 | void __init prom_init(void) | ||
101 | { | ||
102 | unsigned long memsz; | ||
103 | int argc, i; | ||
104 | char **argv; | ||
105 | |||
106 | memsz = fw_arg0 & 0x7fff0000; | ||
107 | argc = fw_arg0 & 0x0000ffff; | ||
108 | argv = (char **)fw_arg1; | ||
109 | |||
110 | for (i = 1; i < argc; i++) { | ||
111 | strlcat(arcs_cmdline, argv[i], COMMAND_LINE_SIZE); | ||
112 | if (i < (argc - 1)) | ||
113 | strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE); | ||
114 | } | ||
115 | |||
116 | memblock_add(0, memsz); | ||
117 | |||
118 | setup_8250_early_printk_port(CKSEG1ADDR(0x1c800000), 0, 0); | ||
119 | } | ||
120 | |||
121 | void __init prom_free_prom_memory(void) | ||
122 | { | ||
123 | /* Nothing to do! */ | ||
124 | } | ||
diff --git a/arch/mips/cobalt/time.c b/arch/mips/cobalt/time.c new file mode 100644 index 000000000..1b6fa6649 --- /dev/null +++ b/arch/mips/cobalt/time.c | |||
@@ -0,0 +1,41 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Cobalt time initialization. | ||
4 | * | ||
5 | * Copyright (C) 2007 Yoichi Yuasa <yuasa@linux-mips.org> | ||
6 | */ | ||
7 | #include <linux/i8253.h> | ||
8 | #include <linux/init.h> | ||
9 | |||
10 | #include <asm/gt64120.h> | ||
11 | #include <asm/time.h> | ||
12 | |||
13 | #define GT641XX_BASE_CLOCK 50000000 /* 50MHz */ | ||
14 | |||
15 | void __init plat_time_init(void) | ||
16 | { | ||
17 | u32 start, end; | ||
18 | int i = HZ / 10; | ||
19 | |||
20 | setup_pit_timer(); | ||
21 | |||
22 | gt641xx_set_base_clock(GT641XX_BASE_CLOCK); | ||
23 | |||
24 | /* | ||
25 | * MIPS counter frequency is measured during a 100msec interval | ||
26 | * using GT64111 timer0. | ||
27 | */ | ||
28 | while (!gt641xx_timer0_state()) | ||
29 | ; | ||
30 | |||
31 | start = read_c0_count(); | ||
32 | |||
33 | while (i--) | ||
34 | while (!gt641xx_timer0_state()) | ||
35 | ; | ||
36 | |||
37 | end = read_c0_count(); | ||
38 | |||
39 | mips_hpt_frequency = (end - start) * 10; | ||
40 | printk(KERN_INFO "MIPS counter frequency %dHz\n", mips_hpt_frequency); | ||
41 | } | ||