ODROID-C1 SMP support.diff -r1.3 -r1.4 src/sys/arch/arm/amlogic/amlogic_reg.h
(jmcneill)
--- src/sys/arch/arm/amlogic/Attic/amlogic_reg.h 2015/02/28 15:20:43 1.3
+++ src/sys/arch/arm/amlogic/Attic/amlogic_reg.h 2015/03/01 15:07:49 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: amlogic_reg.h,v 1.3 2015/02/28 15:20:43 jmcneill Exp $ */ | 1 | /* $NetBSD: amlogic_reg.h,v 1.4 2015/03/01 15:07:49 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -22,38 +22,51 @@ | @@ -22,38 +22,51 @@ | |||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #ifndef _ARM_AMLOGIC_REG_H | 29 | #ifndef _ARM_AMLOGIC_REG_H | |
30 | #define _ARM_AMLOGIC_REG_H | 30 | #define _ARM_AMLOGIC_REG_H | |
31 | 31 | |||
32 | #define CONSADDR_VA (CONSADDR - AMLOGIC_CORE_BASE + AMLOGIC_CORE_VBASE) | 32 | #define CONSADDR_VA (CONSADDR - AMLOGIC_CORE_BASE + AMLOGIC_CORE_VBASE) | |
33 | 33 | |||
34 | #define AMLOGIC_CORE_BASE 0xc0000000 | 34 | #define AMLOGIC_CORE_BASE 0xc0000000 | |
35 | #define AMLOGIC_CORE_SIZE 0x10200000 | 35 | #define AMLOGIC_CORE_SIZE 0x1b000000 | |
36 | #define AMLOGIC_CORE_VBASE 0xe0000000 | 36 | #define AMLOGIC_CORE_VBASE 0xe0000000 | |
37 | 37 | |||
38 | #define AMLOGIC_CBUS_OFFSET 0x01100000 | 38 | #define AMLOGIC_CBUS_OFFSET 0x01100000 | |
39 | 39 | |||
40 | #define AMLOGIC_UART0_OFFSET 0x01102130 | 40 | #define AMLOGIC_UART0_OFFSET 0x01102130 | |
41 | #define AMLOGIC_UART1_OFFSET 0x01102137 | 41 | #define AMLOGIC_UART1_OFFSET 0x01102137 | |
42 | #define AMLOGIC_UART2_OFFSET 0x011021c0 | 42 | #define AMLOGIC_UART2_OFFSET 0x011021c0 | |
43 | #define AMLOGIC_UART0AO_OFFSET 0x081004c0 | 43 | #define AMLOGIC_UART0AO_OFFSET 0x081004c0 | |
44 | #define AMLOGIC_UART2AO_OFFSET 0x081004e0 | 44 | #define AMLOGIC_UART2AO_OFFSET 0x081004e0 | |
45 | #define AMLOGIC_UART_SIZE 0x20 | 45 | #define AMLOGIC_UART_SIZE 0x20 | |
46 | #define AMLOGIC_UART_FREQ 24000000 | 46 | #define AMLOGIC_UART_FREQ 24000000 | |
47 | 47 | |||
48 | #define AMLOGIC_MMC_OFFSET 0x01108e00 | 48 | #define AMLOGIC_MMC_OFFSET 0x01108e00 | |
49 | #define AMLOGIC_MMC_SIZE 0x30 | 49 | #define AMLOGIC_MMC_SIZE 0x30 | |
50 | 50 | |||
51 | #define AMLOGIC_PL310_OFFSET 0x04200000 | 51 | #define AMLOGIC_PL310_OFFSET 0x04200000 | |
52 | 52 | |||
53 | #define AMLOGIC_AOBUS_OFFSET 0x08100000 | |||
54 | ||||
53 | #define AMLOGIC_GPIOAO_OFFSET 0x08100024 | 55 | #define AMLOGIC_GPIOAO_OFFSET 0x08100024 | |
54 | 56 | |||
55 | #define AMLOGIC_USB0_OFFSET 0x09040000 | 57 | #define AMLOGIC_USB0_OFFSET 0x09040000 | |
56 | #define AMLOGIC_USB1_OFFSET 0x090c0000 | 58 | #define AMLOGIC_USB1_OFFSET 0x090c0000 | |
57 | #define AMLOGIC_USB_SIZE 0x40000 | 59 | #define AMLOGIC_USB_SIZE 0x40000 | |
58 | 60 | |||
61 | #define AMLOGIC_CPUCONF_OFFSET 0x1901ff80 | |||
62 | ||||
63 | #define AMLOGIC_CBUS_CPU_CLK_CNTL_REG 0x419c | |||
64 | ||||
65 | #define AMLOGIC_AOBUS_PWR_CTRL0_REG 0xe0 | |||
66 | #define AMLOGIC_AOBUS_PWR_CTRL1_REG 0xe4 | |||
67 | #define AMLOGIC_AOBUS_PWR_MEM_PD0_REG 0xf4 | |||
68 | ||||
69 | #define AMLOGIC_CPUCONF_CTRL_REG 0x00 | |||
70 | #define AMLOGIC_CPUCONF_CPU_ADDR_REG(n) (0x04 * (n)) | |||
71 | ||||
59 | #endif /* _ARM_AMLOGIC_REG_H */ | 72 | #endif /* _ARM_AMLOGIC_REG_H */ |
--- src/sys/arch/evbarm/amlogic/Attic/amlogic_machdep.c 2015/02/28 18:50:15 1.8
+++ src/sys/arch/evbarm/amlogic/Attic/amlogic_machdep.c 2015/03/01 15:07:49 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: amlogic_machdep.c,v 1.8 2015/02/28 18:50:15 jmcneill Exp $ */ | 1 | /* $NetBSD: amlogic_machdep.c,v 1.9 2015/03/01 15:07:49 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Machine dependent functions for kernel setup for TI OSK5912 board. | 4 | * Machine dependent functions for kernel setup for TI OSK5912 board. | |
5 | * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c | 5 | * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c | |
6 | * | 6 | * | |
7 | * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. | 7 | * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. | |
8 | * Written by Hiroyuki Bessho for Genetec Corporation. | 8 | * Written by Hiroyuki Bessho for Genetec Corporation. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -115,35 +115,36 @@ | @@ -115,35 +115,36 @@ | |||
115 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 115 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
116 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 116 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
117 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT, | 117 | * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT, | |
118 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 118 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
119 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 119 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
120 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 120 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
121 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 121 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
122 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 122 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
123 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 123 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
124 | * SUCH DAMAGE. | 124 | * SUCH DAMAGE. | |
125 | */ | 125 | */ | |
126 | 126 | |||
127 | #include <sys/cdefs.h> | 127 | #include <sys/cdefs.h> | |
128 | __KERNEL_RCSID(0, "$NetBSD: amlogic_machdep.c,v 1.8 2015/02/28 18:50:15 jmcneill Exp $"); | 128 | __KERNEL_RCSID(0, "$NetBSD: amlogic_machdep.c,v 1.9 2015/03/01 15:07:49 jmcneill Exp $"); | |
129 | 129 | |||
130 | #include "opt_machdep.h" | 130 | #include "opt_machdep.h" | |
131 | #include "opt_ddb.h" | 131 | #include "opt_ddb.h" | |
132 | #include "opt_kgdb.h" | 132 | #include "opt_kgdb.h" | |
133 | #include "opt_ipkdb.h" | 133 | #include "opt_ipkdb.h" | |
134 | #include "opt_md.h" | 134 | #include "opt_md.h" | |
135 | #include "opt_amlogic.h" | 135 | #include "opt_amlogic.h" | |
136 | #include "opt_arm_debug.h" | 136 | #include "opt_arm_debug.h" | |
137 | #include "opt_multiprocessor.h" | |||
137 | 138 | |||
138 | #include "amlogic_com.h" | 139 | #include "amlogic_com.h" | |
139 | #if 0 | 140 | #if 0 | |
140 | #include "prcm.h" | 141 | #include "prcm.h" | |
141 | #include "sdhc.h" | 142 | #include "sdhc.h" | |
142 | #include "ukbd.h" | 143 | #include "ukbd.h" | |
143 | #endif | 144 | #endif | |
144 | #include "arml2cc.h" | 145 | #include "arml2cc.h" | |
145 | #include "act8846pm.h" | 146 | #include "act8846pm.h" | |
146 | #include "ether.h" | 147 | #include "ether.h" | |
147 | 148 | |||
148 | #include <sys/param.h> | 149 | #include <sys/param.h> | |
149 | #include <sys/systm.h> | 150 | #include <sys/systm.h> | |
@@ -318,42 +319,44 @@ initarm(void *arg) | @@ -318,42 +319,44 @@ initarm(void *arg) | |||
318 | { | 319 | { | |
319 | psize_t ram_size = 0; | 320 | psize_t ram_size = 0; | |
320 | *(volatile int *)CONSADDR_VA = 0x40; /* output '@' */ | 321 | *(volatile int *)CONSADDR_VA = 0x40; /* output '@' */ | |
321 | 322 | |||
322 | amlogic_putchar('d'); | 323 | amlogic_putchar('d'); | |
323 | pmap_devmap_register(devmap); | 324 | pmap_devmap_register(devmap); | |
324 | 325 | |||
325 | amlogic_putchar('b'); | 326 | amlogic_putchar('b'); | |
326 | amlogic_bootstrap(); | 327 | amlogic_bootstrap(); | |
327 | 328 | |||
328 | amlogic_putchar('!'); | 329 | amlogic_putchar('!'); | |
329 | 330 | |||
330 | #ifdef MULTIPROCESSOR | 331 | #ifdef MULTIPROCESSOR | |
331 | uint32_t scu_cfg = bus_space_read_4(&amlogic_bs_tag, | 332 | const bus_addr_t cbar = armreg_cbar_read(); | |
332 | amlogic_core0_bsh, ROCKCHIP_SCU_OFFSET + SCU_CFG); | 333 | if (cbar) { | |
333 | arm_cpu_max = (scu_cfg & SCU_CFG_CPUMAX) + 1; | 334 | const bus_space_handle_t scu_bsh = | |
334 | membar_producer(); | 335 | cbar - AMLOGIC_CORE_BASE + AMLOGIC_CORE_VBASE; | |
336 | uint32_t scu_cfg = bus_space_read_4(&amlogic_bs_tag, scu_bsh, | |||
337 | SCU_CFG); | |||
338 | arm_cpu_max = (scu_cfg & SCU_CFG_CPUMAX) + 1; | |||
339 | membar_producer(); | |||
340 | } | |||
335 | #endif | 341 | #endif | |
336 | 342 | |||
337 | /* Heads up ... Setup the CPU / MMU / TLB functions. */ | 343 | /* Heads up ... Setup the CPU / MMU / TLB functions. */ | |
338 | if (set_cpufuncs()) | 344 | if (set_cpufuncs()) | |
339 | panic("cpu not recognized!"); | 345 | panic("cpu not recognized!"); | |
340 | 346 | |||
341 | init_clocks(); | 347 | init_clocks(); | |
342 | 348 | |||
343 | consinit(); | 349 | consinit(); | |
344 | #ifdef MULTIPROCESSOR | |||
345 | arm_cpu_max = 1 + __SHIFTOUT(armreg_l2ctrl_read(), L2CTRL_NUMCPU); | |||
346 | #endif | |||
347 | 350 | |||
348 | #if NARML2CC > 0 | 351 | #if NARML2CC > 0 | |
349 | /* | 352 | /* | |
350 | * Probe the PL310 L2CC | 353 | * Probe the PL310 L2CC | |
351 | */ | 354 | */ | |
352 | printf("probe the PL310 L2CC\n"); | 355 | printf("probe the PL310 L2CC\n"); | |
353 | const bus_space_handle_t pl310_bh = | 356 | const bus_space_handle_t pl310_bh = | |
354 | AMLOGIC_CORE_VBASE + AMLOGIC_PL310_OFFSET; | 357 | AMLOGIC_CORE_VBASE + AMLOGIC_PL310_OFFSET; | |
355 | arml2cc_init(&amlogic_bs_tag, pl310_bh, 0); | 358 | arml2cc_init(&amlogic_bs_tag, pl310_bh, 0); | |
356 | amlogic_putchar('l'); | 359 | amlogic_putchar('l'); | |
357 | #endif | 360 | #endif | |
358 | 361 | |||
359 | printf("\nuboot arg = %#x, %#x, %#x, %#x\n", | 362 | printf("\nuboot arg = %#x, %#x, %#x, %#x\n", | |
@@ -563,13 +566,130 @@ amlogic_device_register(device_t self, v | @@ -563,13 +566,130 @@ amlogic_device_register(device_t self, v | |||
563 | 566 | |||
564 | return; | 567 | return; | |
565 | } | 568 | } | |
566 | 569 | |||
567 | if (device_is_a(self, "arml2cc")) { | 570 | if (device_is_a(self, "arml2cc")) { | |
568 | /* | 571 | /* | |
569 | * L2 cache regs are at C4200000 and A9 periph base is | 572 | * L2 cache regs are at C4200000 and A9 periph base is | |
570 | * at C4300000; pass as a negative offset for the benefit | 573 | * at C4300000; pass as a negative offset for the benefit | |
571 | * of armperiph bus. | 574 | * of armperiph bus. | |
572 | */ | 575 | */ | |
573 | prop_dictionary_set_uint32(dict, "offset", 0xfff00000); | 576 | prop_dictionary_set_uint32(dict, "offset", 0xfff00000); | |
574 | } | 577 | } | |
575 | } | 578 | } | |
579 | ||||
580 | #if defined(MULTIPROCESSOR) | |||
581 | void amlogic_mpinit(uint32_t); | |||
582 | ||||
583 | static void | |||
584 | amlogic_mpinit_delay(u_int n) | |||
585 | { | |||
586 | for (volatile int i = 0; i < n; i++) | |||
587 | ; | |||
588 | } | |||
589 | ||||
590 | static void | |||
591 | amlogic_mpinit_cpu(int cpu) | |||
592 | { | |||
593 | const bus_addr_t cbar = armreg_cbar_read(); | |||
594 | bus_space_tag_t bst = &amlogic_bs_tag; | |||
595 | const bus_space_handle_t scu_bsh = | |||
596 | cbar - AMLOGIC_CORE_BASE + AMLOGIC_CORE_VBASE; | |||
597 | const bus_space_handle_t ao_bsh = | |||
598 | AMLOGIC_CORE_VBASE + AMLOGIC_AOBUS_OFFSET; | |||
599 | const bus_space_handle_t cbus_bsh = | |||
600 | AMLOGIC_CORE_VBASE + AMLOGIC_CBUS_OFFSET; | |||
601 | uint32_t pwr_sts, pwr_cntl0, pwr_cntl1, cpuclk, mempd0; | |||
602 | ||||
603 | pwr_sts = bus_space_read_4(bst, scu_bsh, SCU_CPU_PWR_STS); | |||
604 | pwr_sts &= ~(3 << (8 * cpu)); | |||
605 | bus_space_write_4(bst, scu_bsh, SCU_CPU_PWR_STS, pwr_sts); | |||
606 | ||||
607 | pwr_cntl0 = bus_space_read_4(bst, ao_bsh, AMLOGIC_AOBUS_PWR_CTRL0_REG); | |||
608 | pwr_cntl0 &= ~((3 << 18) << ((cpu - 1) * 2)); | |||
609 | bus_space_write_4(bst, ao_bsh, AMLOGIC_AOBUS_PWR_CTRL0_REG, pwr_cntl0); | |||
610 | ||||
611 | amlogic_mpinit_delay(5000); | |||
612 | ||||
613 | cpuclk = bus_space_read_4(bst, cbus_bsh, AMLOGIC_CBUS_CPU_CLK_CNTL_REG); | |||
614 | cpuclk |= (1 << (24 + cpu)); | |||
615 | bus_space_write_4(bst, cbus_bsh, AMLOGIC_CBUS_CPU_CLK_CNTL_REG, cpuclk); | |||
616 | ||||
617 | mempd0 = bus_space_read_4(bst, ao_bsh, AMLOGIC_AOBUS_PWR_MEM_PD0_REG); | |||
618 | mempd0 &= ~((uint32_t)(0xf << 28) >> ((cpu - 1) * 4)); | |||
619 | bus_space_write_4(bst, ao_bsh, AMLOGIC_AOBUS_PWR_MEM_PD0_REG, mempd0); | |||
620 | ||||
621 | pwr_cntl1 = bus_space_read_4(bst, ao_bsh, AMLOGIC_AOBUS_PWR_CTRL1_REG); | |||
622 | pwr_cntl1 &= ~((3 << 4) << ((cpu - 1) * 2)); | |||
623 | bus_space_write_4(bst, ao_bsh, AMLOGIC_AOBUS_PWR_CTRL1_REG, pwr_cntl1); | |||
624 | ||||
625 | amlogic_mpinit_delay(10000); | |||
626 | ||||
627 | for (;;) { | |||
628 | pwr_cntl1 = bus_space_read_4(bst, ao_bsh, | |||
629 | AMLOGIC_AOBUS_PWR_CTRL1_REG) & ((1 << 17) << (cpu - 1)); | |||
630 | if (pwr_cntl1) | |||
631 | break; | |||
632 | amlogic_mpinit_delay(10000); | |||
633 | } | |||
634 | ||||
635 | pwr_cntl0 = bus_space_read_4(bst, ao_bsh, AMLOGIC_AOBUS_PWR_CTRL0_REG); | |||
636 | pwr_cntl0 &= ~(1 << cpu); | |||
637 | bus_space_write_4(bst, ao_bsh, AMLOGIC_AOBUS_PWR_CTRL0_REG, pwr_cntl0); | |||
638 | ||||
639 | cpuclk = bus_space_read_4(bst, cbus_bsh, AMLOGIC_CBUS_CPU_CLK_CNTL_REG); | |||
640 | cpuclk &= ~(1 << (24 + cpu)); | |||
641 | bus_space_write_4(bst, cbus_bsh, AMLOGIC_CBUS_CPU_CLK_CNTL_REG, cpuclk); | |||
642 | ||||
643 | bus_space_write_4(bst, scu_bsh, SCU_CPU_PWR_STS, pwr_sts); | |||
644 | } | |||
645 | ||||
646 | void | |||
647 | amlogic_mpinit(uint32_t mpinit_vec) | |||
648 | { | |||
649 | const bus_addr_t cbar = armreg_cbar_read(); | |||
650 | bus_space_tag_t bst = &amlogic_bs_tag; | |||
651 | volatile int i; | |||
652 | uint32_t ctrl, hatched = 0; | |||
653 | int cpu; | |||
654 | ||||
655 | if (cbar == 0) | |||
656 | return; | |||
657 | ||||
658 | const bus_space_handle_t scu_bsh = | |||
659 | cbar - AMLOGIC_CORE_BASE + AMLOGIC_CORE_VBASE; | |||
660 | const bus_space_handle_t cpuconf_bsh = | |||
661 | AMLOGIC_CORE_VBASE + AMLOGIC_CPUCONF_OFFSET; | |||
662 | ||||
663 | const uint32_t scu_cfg = bus_space_read_4(bst, scu_bsh, SCU_CFG); | |||
664 | const u_int ncpus = (scu_cfg & SCU_CFG_CPUMAX) + 1; | |||
665 | if (ncpus < 2) | |||
666 | return; | |||
667 | ||||
668 | for (cpu = 1; cpu < ncpus; cpu++) { | |||
669 | bus_space_write_4(bst, cpuconf_bsh, | |||
670 | AMLOGIC_CPUCONF_CPU_ADDR_REG(cpu), mpinit_vec); | |||
671 | amlogic_mpinit_cpu(cpu); | |||
672 | hatched |= __BIT(cpu); | |||
673 | } | |||
674 | ctrl = bus_space_read_4(bst, cpuconf_bsh, AMLOGIC_CPUCONF_CTRL_REG); | |||
675 | for (cpu = 0; cpu < ncpus; cpu++) { | |||
676 | ctrl |= __BIT(cpu); | |||
677 | } | |||
678 | bus_space_write_4(bst, cpuconf_bsh, AMLOGIC_CPUCONF_CTRL_REG, ctrl); | |||
679 | ||||
680 | __asm __volatile("sev"); | |||
681 | ||||
682 | for (i = 0x10000000; i > 0; i--) { | |||
683 | __asm __volatile("dmb" ::: "memory"); | |||
684 | if (arm_cpu_hatched == hatched) | |||
685 | break; | |||
686 | } | |||
687 | ||||
688 | if (i == 0) { | |||
689 | const char *msg = "\nWARNING: Some APs failed to start\n"; | |||
690 | const char *p = msg; | |||
691 | while (*p) | |||
692 | amlogic_putchar(*p++); | |||
693 | } | |||
694 | } | |||
695 | #endif |
--- src/sys/arch/evbarm/amlogic/Attic/amlogic_start.S 2015/02/07 17:20:16 1.1
+++ src/sys/arch/evbarm/amlogic/Attic/amlogic_start.S 2015/03/01 15:07:49 1.2
@@ -33,27 +33,27 @@ | @@ -33,27 +33,27 @@ | |||
33 | #include "opt_cputypes.h" | 33 | #include "opt_cputypes.h" | |
34 | #include "opt_multiprocessor.h" | 34 | #include "opt_multiprocessor.h" | |
35 | #include "opt_arm_debug.h" | 35 | #include "opt_arm_debug.h" | |
36 | 36 | |||
37 | #include <arm/asm.h> | 37 | #include <arm/asm.h> | |
38 | #include <arm/armreg.h> | 38 | #include <arm/armreg.h> | |
39 | #include "assym.h" | 39 | #include "assym.h" | |
40 | 40 | |||
41 | #include <arm/amlogic/amlogic_reg.h> | 41 | #include <arm/amlogic/amlogic_reg.h> | |
42 | #include <evbarm/amlogic/platform.h> | 42 | #include <evbarm/amlogic/platform.h> | |
43 | 43 | |||
44 | #include <arm/cortex/scu_reg.h> | 44 | #include <arm/cortex/scu_reg.h> | |
45 | 45 | |||
46 | RCSID("$NetBSD: amlogic_start.S,v 1.1 2015/02/07 17:20:16 jmcneill Exp $") | 46 | RCSID("$NetBSD: amlogic_start.S,v 1.2 2015/03/01 15:07:49 jmcneill Exp $") | |
47 | 47 | |||
48 | #if defined(VERBOSE_INIT_ARM) | 48 | #if defined(VERBOSE_INIT_ARM) | |
49 | #define XPUTC(n) mov r0, n; bl xputc | 49 | #define XPUTC(n) mov r0, n; bl xputc | |
50 | #if KERNEL_BASE_VOFFSET == 0 | 50 | #if KERNEL_BASE_VOFFSET == 0 | |
51 | #define XPUTC2(n) mov r0, n; bl xputc | 51 | #define XPUTC2(n) mov r0, n; bl xputc | |
52 | #else | 52 | #else | |
53 | #define XPUTC2(n) mov r0, n; blx r11 | 53 | #define XPUTC2(n) mov r0, n; blx r11 | |
54 | #endif | 54 | #endif | |
55 | #ifdef __ARMEB__ | 55 | #ifdef __ARMEB__ | |
56 | #define COM_BSWAP | 56 | #define COM_BSWAP | |
57 | #endif | 57 | #endif | |
58 | #define COM_MULT 4 | 58 | #define COM_MULT 4 | |
59 | #define XPUTC_COM 1 | 59 | #define XPUTC_COM 1 | |
@@ -142,152 +142,50 @@ _C_LABEL(amlogic_start): | @@ -142,152 +142,50 @@ _C_LABEL(amlogic_start): | |||
142 | b arm_cpuinit | 142 | b arm_cpuinit | |
143 | .pushsection .text,"ax",%progbits | 143 | .pushsection .text,"ax",%progbits | |
144 | 1: | 144 | 1: | |
145 | #endif | 145 | #endif | |
146 | XPUTC2(#90) | 146 | XPUTC2(#90) | |
147 | 147 | |||
148 | #if defined(MULTIPROCESSOR) | 148 | #if defined(MULTIPROCESSOR) | |
149 | // Now spin up the second processors into the same state we are now. | 149 | // Now spin up the second processors into the same state we are now. | |
150 | XPUTC2(#77) | 150 | XPUTC2(#77) | |
151 | XPUTC2(#80) | 151 | XPUTC2(#80) | |
152 | XPUTC2(#60) | 152 | XPUTC2(#60) | |
153 | // Make sure the cache is flushed out to RAM for the other CPUs | 153 | // Make sure the cache is flushed out to RAM for the other CPUs | |
154 | bl _C_LABEL(armv7_dcache_wbinv_all) | 154 | bl _C_LABEL(armv7_dcache_wbinv_all) | |
155 | bl amlogic_mpinit | 155 | ||
156 | movw r0, #:lower16:amlogic_mpstart | |||
157 | movt r0, #:upper16:amlogic_mpstart | |||
158 | bl _C_LABEL(amlogic_mpinit) | |||
159 | ||||
156 | XPUTC2(#62) | 160 | XPUTC2(#62) | |
157 | #endif /* MULTIPROCESSOR */ | 161 | #endif /* MULTIPROCESSOR */ | |
158 | XPUTC2(#13) | 162 | XPUTC2(#13) | |
159 | XPUTC2(#10) | 163 | XPUTC2(#10) | |
160 | 164 | |||
161 | /* | 165 | /* | |
162 | * Jump to start in locore.S, which in turn will call initarm and main. | 166 | * Jump to start in locore.S, which in turn will call initarm and main. | |
163 | */ | 167 | */ | |
164 | b start | 168 | b start | |
165 | 169 | |||
166 | /* NOTREACHED */ | 170 | /* NOTREACHED */ | |
167 | 171 | |||
168 | #ifndef KERNEL_BASES_EQUAL | 172 | #ifndef KERNEL_BASES_EQUAL | |
169 | .popsection | 173 | .popsection | |
170 | #endif | 174 | #endif | |
171 | 175 | |||
172 | #include <arm/cortex/a9_mpsubr.S> | 176 | #include <arm/cortex/a9_mpsubr.S> | |
173 | 177 | |||
174 | #define PMU_PWRDN_REG 0x0008 | 178 | #ifdef MULTIPROCESSOR | |
175 | #define PMU_PWRDN_SCU __BIT(4) | |||
176 | ||||
177 | #if defined(MULTIPROCESSOR) | |||
178 | #ifndef KERNEL_BASES_EQUAL | |||
179 | .pushsection .text,"ax",%progbits | |||
180 | #endif | |||
181 | amlogic_mptramp: | |||
182 | ldr pc, 1f | |||
183 | .global amlogic_mpstart_vec | |||
184 | amlogic_mpstart_vec: | |||
185 | 1: .space 4 | |||
186 | ||||
187 | amlogic_mpinit: | |||
188 | mov r4, lr | |||
189 | /* r5: SCU, r6: PMU, r7: SRAM */ | |||
190 | movw r5, #:lower16:(ROCKCHIP_CORE0_BASE+ROCKCHIP_SCU_OFFSET) | |||
191 | movt r5, #:upper16:(ROCKCHIP_CORE0_BASE+ROCKCHIP_SCU_OFFSET) | |||
192 | movw r6, #:lower16:(ROCKCHIP_CORE1_BASE+ROCKCHIP_PMU_OFFSET) | |||
193 | movt r6, #:upper16:(ROCKCHIP_CORE1_BASE+ROCKCHIP_PMU_OFFSET) | |||
194 | movw r7, #:lower16:(ROCKCHIP_CORE0_BASE+ROCKCHIP_SRAM_OFFSET) | |||
195 | movt r7, #:upper16:(ROCKCHIP_CORE0_BASE+ROCKCHIP_SRAM_OFFSET) | |||
196 | ||||
197 | /* Set where the other CPU(s) are going to execute */ | |||
198 | XPUTC2(#118) | |||
199 | movw r1, #:lower16:amlogic_mpstart | |||
200 | movt r1, #:upper16:amlogic_mpstart | |||
201 | ldr r0, =amlogic_mpstart_vec | |||
202 | str r1, [r0] | |||
203 | ldr r0, =amlogic_mptramp | |||
204 | mov r2, #0 | |||
205 | 1: ldr r1, [r0, r2] | |||
206 | str r1, [r7, r2] | |||
207 | add r2, r2, #4 | |||
208 | cmp r2, #32 | |||
209 | blt 1b | |||
210 | dsb | |||
211 | ||||
212 | /* Invalid SCU cache tags */ | |||
213 | XPUTC2(#45) | |||
214 | movw r1, #0xffff | |||
215 | movt r1, #0 | |||
216 | str r1, [r5, #SCU_INV_ALL_REG] | |||
217 | ||||
218 | /* Get CPU count */ | |||
219 | ldr r1, [r5, #SCU_CFG] | |||
220 | and r2, r1, #SCU_CFG_CPUMAX | |||
221 | add r2, r2, #1 | |||
222 | ||||
223 | /* Convert to CPU1..N mask */ | |||
224 | mov r7, #0 | |||
225 | lsl r7, r2, #1 | |||
226 | sub r7, r7, #1 | |||
227 | and r7, r7, #~1 | |||
228 | ||||
229 | /* Power down secondary CPUs */ | |||
230 | XPUTC2(#46) | |||
231 | ldr r1, [r6, #PMU_PWRDN_REG] | |||
232 | orr r1, r1, r7 | |||
233 | str r1, [r6, #PMU_PWRDN_REG] | |||
234 | dsb | |||
235 | ||||
236 | /* Power up SCU */ | |||
237 | XPUTC2(#46) | |||
238 | ldr r1, [r6, #PMU_PWRDN_REG] | |||
239 | and r1, r1, #~PMU_PWRDN_SCU | |||
240 | str r1, [r6, #PMU_PWRDN_REG] | |||
241 | dsb | |||
242 | ||||
243 | /* Enable SCU */ | |||
244 | XPUTC2(#46) | |||
245 | ldr r1, [r5, #SCU_CTL] | |||
246 | orr r1, r1, #SCU_CTL_SCU_ENA | |||
247 | str r1, [r5, #SCU_CTL] | |||
248 | dsb | |||
249 | ||||
250 | /* Power up secondary CPUs */ | |||
251 | XPUTC2(#33) | |||
252 | ldr r1, [r6, #PMU_PWRDN_REG] | |||
253 | and r1, r1, r7 | |||
254 | str r1, [r6, #PMU_PWRDN_REG] | |||
255 | dsb | |||
256 | ||||
257 | XPUTC2(#49) | |||
258 | XPUTC2(#50) | |||
259 | XPUTC2(#51) | |||
260 | ||||
261 | // | |||
262 | // Wait up a second for CPU1 to hatch. | |||
263 | // | |||
264 | movw r2, #:lower16:arm_cpu_hatched | |||
265 | movt r2, #:upper16:arm_cpu_hatched | |||
266 | mov r1, #0x10000000 | |||
267 | 1: dmb | |||
268 | ldr r0, [r2] | |||
269 | cmp r0, r7 | |||
270 | beq .hatched | |||
271 | subs r1, r1, #1 | |||
272 | bne 1b | |||
273 | ||||
274 | .hatched: | |||
275 | bx r4 | |||
276 | ||||
277 | ASEND(amlogic_mpinit) | |||
278 | #ifndef KERNEL_BASES_EQUAL | |||
279 | .popsection | |||
280 | #endif | |||
281 | 179 | |||
282 | amlogic_mpstart: | 180 | amlogic_mpstart: | |
283 | /* invalidate cache */ | 181 | /* invalidate cache */ | |
284 | movw ip, #:lower16:_C_LABEL(armv7_dcache_inv_all) | 182 | movw ip, #:lower16:_C_LABEL(armv7_dcache_inv_all) | |
285 | movt ip, #:upper16:_C_LABEL(armv7_dcache_inv_all) | 183 | movt ip, #:upper16:_C_LABEL(armv7_dcache_inv_all) | |
286 | #ifndef KERNEL_BASES_EQUAL | 184 | #ifndef KERNEL_BASES_EQUAL | |
287 | sub ip, ip, #KERNEL_BASE_VOFFSET | 185 | sub ip, ip, #KERNEL_BASE_VOFFSET | |
288 | #endif | 186 | #endif | |
289 | blx ip | 187 | blx ip | |
290 | b _C_LABEL(cortex_mpstart) | 188 | b _C_LABEL(cortex_mpstart) | |
291 | 189 | |||
292 | #endif /* MULTIPROCESSOR */ | 190 | #endif /* MULTIPROCESSOR */ | |
293 | 191 |
--- src/sys/arch/evbarm/conf/Attic/ODROID-C1 2015/02/28 18:52:01 1.3
+++ src/sys/arch/evbarm/conf/Attic/ODROID-C1 2015/03/01 15:07:49 1.4
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | # | 1 | # | |
2 | # $NetBSD: ODROID-C1,v 1.3 2015/02/28 18:52:01 jmcneill Exp $ | 2 | # $NetBSD: ODROID-C1,v 1.4 2015/03/01 15:07:49 jmcneill Exp $ | |
3 | # | 3 | # | |
4 | # Odroid-C1 (Amlogic S805) based SBC (Single Board Computer) | 4 | # Odroid-C1 (Amlogic S805) based SBC (Single Board Computer) | |
5 | # | 5 | # | |
6 | 6 | |||
7 | include "arch/evbarm/conf/std.amlogic" | 7 | include "arch/evbarm/conf/std.amlogic" | |
8 | 8 | |||
9 | # estimated number of users | 9 | # estimated number of users | |
10 | 10 | |||
11 | maxusers 32 | 11 | maxusers 32 | |
12 | 12 | |||
13 | # Standard system options | 13 | # Standard system options | |
14 | 14 | |||
15 | options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT | 15 | options RTC_OFFSET=0 # hardware clock is this many mins. west of GMT | |
@@ -146,27 +146,27 @@ options DDB_COMMANDONENTER="bt" | @@ -146,27 +146,27 @@ options DDB_COMMANDONENTER="bt" | |||
146 | #options KGDB | 146 | #options KGDB | |
147 | makeoptions DEBUG="-g" # compile full symbol table | 147 | makeoptions DEBUG="-g" # compile full symbol table | |
148 | makeoptions COPY_SYMTAB=1 | 148 | makeoptions COPY_SYMTAB=1 | |
149 | 149 | |||
150 | options BOOT_ARGS="\"\"" | 150 | options BOOT_ARGS="\"\"" | |
151 | 151 | |||
152 | config netbsd root on ? type ? | 152 | config netbsd root on ? type ? | |
153 | 153 | |||
154 | # The main bus device | 154 | # The main bus device | |
155 | mainbus0 at root | 155 | mainbus0 at root | |
156 | 156 | |||
157 | # The boot cpu | 157 | # The boot cpu | |
158 | cpu* at mainbus? | 158 | cpu* at mainbus? | |
159 | #options MULTIPROCESSOR | 159 | options MULTIPROCESSOR | |
160 | 160 | |||
161 | # A5 core devices | 161 | # A5 core devices | |
162 | armperiph0 at mainbus? | 162 | armperiph0 at mainbus? | |
163 | arml2cc0 at armperiph? # L2 Cache Controller | 163 | arml2cc0 at armperiph? # L2 Cache Controller | |
164 | armgic0 at armperiph? # Interrupt Controller | 164 | armgic0 at armperiph? # Interrupt Controller | |
165 | a9tmr0 at armperiph? # Global Timer | 165 | a9tmr0 at armperiph? # Global Timer | |
166 | a9wdt0 at armperiph? # Watchdog | 166 | a9wdt0 at armperiph? # Watchdog | |
167 | 167 | |||
168 | # Specify the memory size in megabytes. | 168 | # Specify the memory size in megabytes. | |
169 | options MEMSIZE=1024 | 169 | options MEMSIZE=1024 | |
170 | 170 | |||
171 | # On-board I/O | 171 | # On-board I/O | |
172 | amlogicio0 at mainbus? | 172 | amlogicio0 at mainbus? |