add u-boot argument parser for Marvell ARMADA XP/370. use 'ethaddr' and 'eth1addr' in u-boot argument to setup MAC address of mvgbe.diff -r1.8 -r1.9 src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c
(hsuenaga)
--- src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c 2014/03/29 15:00:07 1.8
+++ src/sys/arch/evbarm/armadaxp/armadaxp_machdep.c 2015/04/15 10:15:40 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: armadaxp_machdep.c,v 1.8 2014/03/29 15:00:07 matt Exp $ */ | 1 | /* $NetBSD: armadaxp_machdep.c,v 1.9 2015/04/15 10:15:40 hsuenaga Exp $ */ | |
2 | /******************************************************************************* | 2 | /******************************************************************************* | |
3 | Copyright (C) Marvell International Ltd. and its affiliates | 3 | Copyright (C) Marvell International Ltd. and its affiliates | |
4 | 4 | |||
5 | Developed by Semihalf | 5 | Developed by Semihalf | |
6 | 6 | |||
7 | ******************************************************************************** | 7 | ******************************************************************************** | |
8 | Marvell BSD License | 8 | Marvell BSD License | |
9 | 9 | |||
10 | If you received this File from Marvell, you may opt to use, redistribute and/or | 10 | If you received this File from Marvell, you may opt to use, redistribute and/or | |
11 | modify this File under the following licensing terms. | 11 | modify this File under the following licensing terms. | |
12 | Redistribution and use in source and binary forms, with or without modification, | 12 | Redistribution and use in source and binary forms, with or without modification, | |
13 | are permitted provided that the following conditions are met: | 13 | are permitted provided that the following conditions are met: | |
14 | 14 | |||
@@ -27,27 +27,27 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIG | @@ -27,27 +27,27 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIG | |||
27 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 27 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 28 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
29 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | 29 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | |
30 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 30 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 31 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
32 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | 32 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |
33 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 33 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
35 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 35 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
36 | 36 | |||
37 | *******************************************************************************/ | 37 | *******************************************************************************/ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | __KERNEL_RCSID(0, "$NetBSD: armadaxp_machdep.c,v 1.8 2014/03/29 15:00:07 matt Exp $"); | 40 | __KERNEL_RCSID(0, "$NetBSD: armadaxp_machdep.c,v 1.9 2015/04/15 10:15:40 hsuenaga Exp $"); | |
41 | 41 | |||
42 | #include "opt_machdep.h" | 42 | #include "opt_machdep.h" | |
43 | #include "opt_mvsoc.h" | 43 | #include "opt_mvsoc.h" | |
44 | #include "opt_evbarm_boardtype.h" | 44 | #include "opt_evbarm_boardtype.h" | |
45 | #include "opt_com.h" | 45 | #include "opt_com.h" | |
46 | #include "opt_ddb.h" | 46 | #include "opt_ddb.h" | |
47 | #include "opt_kgdb.h" | 47 | #include "opt_kgdb.h" | |
48 | #include "opt_pci.h" | 48 | #include "opt_pci.h" | |
49 | #include "opt_ipkdb.h" | 49 | #include "opt_ipkdb.h" | |
50 | 50 | |||
51 | #include <sys/bus.h> | 51 | #include <sys/bus.h> | |
52 | #include <sys/param.h> | 52 | #include <sys/param.h> | |
53 | #include <sys/device.h> | 53 | #include <sys/device.h> | |
@@ -90,36 +90,45 @@ __KERNEL_RCSID(0, "$NetBSD: armadaxp_mac | @@ -90,36 +90,45 @@ __KERNEL_RCSID(0, "$NetBSD: armadaxp_mac | |||
90 | #include <arm/marvell/mvsocvar.h> | 90 | #include <arm/marvell/mvsocvar.h> | |
91 | #include <arm/marvell/armadaxpreg.h> | 91 | #include <arm/marvell/armadaxpreg.h> | |
92 | 92 | |||
93 | #include <evbarm/marvell/marvellreg.h> | 93 | #include <evbarm/marvell/marvellreg.h> | |
94 | #include <evbarm/marvell/marvellvar.h> | 94 | #include <evbarm/marvell/marvellvar.h> | |
95 | 95 | |||
96 | #include "mvpex.h" | 96 | #include "mvpex.h" | |
97 | #include "com.h" | 97 | #include "com.h" | |
98 | #if NCOM > 0 | 98 | #if NCOM > 0 | |
99 | #include <dev/ic/comreg.h> | 99 | #include <dev/ic/comreg.h> | |
100 | #include <dev/ic/comvar.h> | 100 | #include <dev/ic/comvar.h> | |
101 | #endif | 101 | #endif | |
102 | 102 | |||
103 | #include <net/if_ether.h> | |||
104 | ||||
103 | /* | 105 | /* | |
104 | * Address to call from cpu_reset() to reset the machine. | 106 | * Address to call from cpu_reset() to reset the machine. | |
105 | * This is machine architecture dependent as it varies depending | 107 | * This is machine architecture dependent as it varies depending | |
106 | * on where the ROM appears when you turn the MMU off. | 108 | * on where the ROM appears when you turn the MMU off. | |
107 | */ | 109 | */ | |
108 | 110 | |||
109 | BootConfig bootconfig; /* Boot config storage */ | 111 | BootConfig bootconfig; /* Boot config storage */ | |
110 | char *boot_args = NULL; | 112 | char *boot_args = NULL; | |
111 | char *boot_file = NULL; | 113 | char *boot_file = NULL; | |
112 | 114 | |||
115 | /* | |||
116 | * U-Boot argument buffer | |||
117 | */ | |||
118 | extern unsigned int uboot_regs_pa[]; /* saved r0, r1, r2, r3 */ | |||
119 | unsigned int *uboot_regs_va; | |||
120 | char boot_argbuf[MAX_BOOT_STRING]; | |||
121 | ||||
113 | extern int KERNEL_BASE_phys[]; | 122 | extern int KERNEL_BASE_phys[]; | |
114 | 123 | |||
115 | /* | 124 | /* | |
116 | * Put some bogus settings of the MEMSTART and MEMSIZE | 125 | * Put some bogus settings of the MEMSTART and MEMSIZE | |
117 | * if they are not defined in kernel configuration file. | 126 | * if they are not defined in kernel configuration file. | |
118 | */ | 127 | */ | |
119 | #ifndef MEMSTART | 128 | #ifndef MEMSTART | |
120 | #define MEMSTART 0x00000000UL | 129 | #define MEMSTART 0x00000000UL | |
121 | #endif | 130 | #endif | |
122 | #ifndef MEMSIZE | 131 | #ifndef MEMSIZE | |
123 | #define MEMSIZE 0x40000000UL | 132 | #define MEMSIZE 0x40000000UL | |
124 | #endif | 133 | #endif | |
125 | 134 | |||
@@ -383,26 +392,33 @@ initarm(void *arg) | @@ -383,26 +392,33 @@ initarm(void *arg) | |||
383 | bootconfig.dram[0].address = MEMSTART; | 392 | bootconfig.dram[0].address = MEMSTART; | |
384 | bootconfig.dram[0].pages = memsize / PAGE_SIZE; | 393 | bootconfig.dram[0].pages = memsize / PAGE_SIZE; | |
385 | 394 | |||
386 | physical_start = bootconfig.dram[0].address; | 395 | physical_start = bootconfig.dram[0].address; | |
387 | physical_end = physical_start + (bootconfig.dram[0].pages * PAGE_SIZE); | 396 | physical_end = physical_start + (bootconfig.dram[0].pages * PAGE_SIZE); | |
388 | 397 | |||
389 | arm32_bootmem_init(0, physical_end, (uintptr_t) KERNEL_BASE_phys); | 398 | arm32_bootmem_init(0, physical_end, (uintptr_t) KERNEL_BASE_phys); | |
390 | arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_LOW, 0, | 399 | arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_LOW, 0, | |
391 | devmap, mapallmem_p); | 400 | devmap, mapallmem_p); | |
392 | 401 | |||
393 | /* we've a specific device_register routine */ | 402 | /* we've a specific device_register routine */ | |
394 | evbarm_device_register = axp_device_register; | 403 | evbarm_device_register = axp_device_register; | |
395 | 404 | |||
405 | /* copy U-Boot args from U-Boot heap to kernel memory */ | |||
406 | uboot_regs_va = (int *)((unsigned int)uboot_regs_pa + KERNEL_BASE); | |||
407 | boot_args = (char *)(uboot_regs_va[3] + KERNEL_BASE); | |||
408 | strlcpy(boot_argbuf, (char *)boot_args, sizeof(boot_argbuf)); | |||
409 | boot_args = boot_argbuf; | |||
410 | parse_mi_bootargs(boot_args); | |||
411 | ||||
396 | return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0); | 412 | return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0); | |
397 | } | 413 | } | |
398 | 414 | |||
399 | #ifndef CONSADDR | 415 | #ifndef CONSADDR | |
400 | #error Specify the address of the UART with the CONSADDR option. | 416 | #error Specify the address of the UART with the CONSADDR option. | |
401 | #endif | 417 | #endif | |
402 | #ifndef CONSPEED | 418 | #ifndef CONSPEED | |
403 | #define CONSPEED B115200 | 419 | #define CONSPEED B115200 | |
404 | #endif | 420 | #endif | |
405 | #ifndef CONMODE | 421 | #ifndef CONMODE | |
406 | #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ | 422 | #define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ | |
407 | #endif | 423 | #endif | |
408 | #ifndef CONSFREQ | 424 | #ifndef CONSFREQ | |
@@ -574,15 +590,40 @@ axp_device_register(device_t dev, void * | @@ -574,15 +590,40 @@ axp_device_register(device_t dev, void * | |||
574 | KASSERT(pc != NULL); | 590 | KASSERT(pc != NULL); | |
575 | prop_dictionary_set(dict, "pci-chipset", pc); | 591 | prop_dictionary_set(dict, "pci-chipset", pc); | |
576 | prop_object_release(pc); | 592 | prop_object_release(pc); | |
577 | 593 | |||
578 | marvell_startend_by_tag(iotag, &start, &end); | 594 | marvell_startend_by_tag(iotag, &start, &end); | |
579 | prop_dictionary_set_uint64(dict, "iostart", start); | 595 | prop_dictionary_set_uint64(dict, "iostart", start); | |
580 | prop_dictionary_set_uint64(dict, "ioend", end); | 596 | prop_dictionary_set_uint64(dict, "ioend", end); | |
581 | marvell_startend_by_tag(memtag, &start, &end); | 597 | marvell_startend_by_tag(memtag, &start, &end); | |
582 | prop_dictionary_set_uint64(dict, "memstart", start); | 598 | prop_dictionary_set_uint64(dict, "memstart", start); | |
583 | prop_dictionary_set_uint64(dict, "memend", end); | 599 | prop_dictionary_set_uint64(dict, "memend", end); | |
584 | prop_dictionary_set_uint32(dict, | 600 | prop_dictionary_set_uint32(dict, | |
585 | "cache-line-size", arm_dcache_align); | 601 | "cache-line-size", arm_dcache_align); | |
586 | } | 602 | } | |
603 | if (device_is_a(dev, "mvgbec")) { | |||
604 | uint8_t enaddr[ETHER_ADDR_LEN]; | |||
605 | char optname[9]; | |||
606 | int unit = device_unit(dev); | |||
607 | ||||
608 | if (unit > 9) | |||
609 | return; | |||
610 | switch (unit) { | |||
611 | case 0: | |||
612 | strlcpy(optname, "ethaddr", sizeof(optname)); | |||
613 | break; | |||
614 | default: | |||
615 | /* eth1addr ... eth9addr */ | |||
616 | snprintf(optname, sizeof(optname), | |||
617 | "eth%daddr", unit); | |||
618 | break; | |||
619 | } | |||
620 | if (get_bootconf_option(boot_args, optname, | |||
621 | BOOTOPT_TYPE_MACADDR, enaddr)) { | |||
622 | prop_data_t pd = | |||
623 | prop_data_create_data(enaddr, sizeof(enaddr)); | |||
624 | ||||
625 | prop_dictionary_set(dict, "mac-address", pd); | |||
626 | } | |||
627 | } | |||
587 | #endif | 628 | #endif | |
588 | } | 629 | } |
--- src/sys/arch/evbarm/armadaxp/armadaxp_start.S 2014/03/29 14:53:57 1.3
+++ src/sys/arch/evbarm/armadaxp/armadaxp_start.S 2015/04/15 10:15:40 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: armadaxp_start.S,v 1.3 2014/03/29 14:53:57 matt Exp $ */ | 1 | /* $NetBSD: armadaxp_start.S,v 1.4 2015/04/15 10:15:40 hsuenaga Exp $ */ | |
2 | /******************************************************************************* | 2 | /******************************************************************************* | |
3 | Copyright (C) Marvell International Ltd. and its affiliates | 3 | Copyright (C) Marvell International Ltd. and its affiliates | |
4 | 4 | |||
5 | Developed by Semihalf | 5 | Developed by Semihalf | |
6 | 6 | |||
7 | ******************************************************************************** | 7 | ******************************************************************************** | |
8 | Marvell BSD License | 8 | Marvell BSD License | |
9 | 9 | |||
10 | If you received this File from Marvell, you may opt to use, redistribute and/or | 10 | If you received this File from Marvell, you may opt to use, redistribute and/or | |
11 | modify this File under the following licensing terms. | 11 | modify this File under the following licensing terms. | |
12 | Redistribution and use in source and binary forms, with or without modification, | 12 | Redistribution and use in source and binary forms, with or without modification, | |
13 | are permitted provided that the following conditions are met: | 13 | are permitted provided that the following conditions are met: | |
14 | 14 | |||
@@ -34,27 +34,27 @@ ANY THEORY OF LIABILITY, WHETHER IN CONT | @@ -34,27 +34,27 @@ ANY THEORY OF LIABILITY, WHETHER IN CONT | |||
34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
35 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 35 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
36 | 36 | |||
37 | *******************************************************************************/ | 37 | *******************************************************************************/ | |
38 | 38 | |||
39 | #include "opt_cputypes.h" | 39 | #include "opt_cputypes.h" | |
40 | 40 | |||
41 | #include <machine/asm.h> | 41 | #include <machine/asm.h> | |
42 | #include <arm/armreg.h> | 42 | #include <arm/armreg.h> | |
43 | #include <evbarm/marvell/marvellreg.h> | 43 | #include <evbarm/marvell/marvellreg.h> | |
44 | #include <evbarm/marvell/marvellvar.h> | 44 | #include <evbarm/marvell/marvellvar.h> | |
45 | #include "assym.h" | 45 | #include "assym.h" | |
46 | 46 | |||
47 | RCSID("$NetBSD: armadaxp_start.S,v 1.3 2014/03/29 14:53:57 matt Exp $") | 47 | RCSID("$NetBSD: armadaxp_start.S,v 1.4 2015/04/15 10:15:40 hsuenaga Exp $") | |
48 | 48 | |||
49 | #ifdef KERNEL_BASES_EQUAL | 49 | #ifdef KERNEL_BASES_EQUAL | |
50 | #error KERNEL_BASE_VIRT should not equal KERNEL_BASE_PHYS | 50 | #error KERNEL_BASE_VIRT should not equal KERNEL_BASE_PHYS | |
51 | #endif | 51 | #endif | |
52 | 52 | |||
53 | /* | 53 | /* | |
54 | * We don't want to hard-code some basic things like RAM start etc. | 54 | * We don't want to hard-code some basic things like RAM start etc. | |
55 | * Hence, it is important to set the following options to resanoable values | 55 | * Hence, it is important to set the following options to resanoable values | |
56 | * in std.armadaxp configuration file. | 56 | * in std.armadaxp configuration file. | |
57 | */ | 57 | */ | |
58 | #if !defined(STARTUP_PAGETABLE_ADDR) | 58 | #if !defined(STARTUP_PAGETABLE_ADDR) | |
59 | #error STARTUP_PAGETABLE_ADDR not defined. Please define it in std.armadaxp | 59 | #error STARTUP_PAGETABLE_ADDR not defined. Please define it in std.armadaxp | |
60 | #elif !defined(MEMSTART) | 60 | #elif !defined(MEMSTART) | |
@@ -68,26 +68,30 @@ _C_LABEL(armadaxp_start): | @@ -68,26 +68,30 @@ _C_LABEL(armadaxp_start): | |||
68 | /* Move into supervisor mode and disable IRQs/FIQs. */ | 68 | /* Move into supervisor mode and disable IRQs/FIQs. */ | |
69 | cpsid if, #PSR_SVC32_MODE | 69 | cpsid if, #PSR_SVC32_MODE | |
70 | 70 | |||
71 | /* Disable MMU for a while */ | 71 | /* Disable MMU for a while */ | |
72 | mrc p15, 0, r2, c1, c0, 0 | 72 | mrc p15, 0, r2, c1, c0, 0 | |
73 | movw r1, #(CPU_CONTROL_MMU_ENABLE | CPU_CONTROL_DC_ENABLE |\ | 73 | movw r1, #(CPU_CONTROL_MMU_ENABLE | CPU_CONTROL_DC_ENABLE |\ | |
74 | CPU_CONTROL_WBUF_ENABLE | CPU_CONTROL_IC_ENABLE |\ | 74 | CPU_CONTROL_WBUF_ENABLE | CPU_CONTROL_IC_ENABLE |\ | |
75 | CPU_CONTROL_BPRD_ENABLE) | 75 | CPU_CONTROL_BPRD_ENABLE) | |
76 | bic r2, r2, r1 | 76 | bic r2, r2, r1 | |
77 | mcr p15, 0, r2, c1, c0, 0 | 77 | mcr p15, 0, r2, c1, c0, 0 | |
78 | dsb | 78 | dsb | |
79 | isb | 79 | isb | |
80 | 80 | |||
81 | /* Save U-Boot arguments */ | |||
82 | adr r4, uboot_regs_pa | |||
83 | stmia r4!, {r0, r1, r2, r3} | |||
84 | ||||
81 | /* build page table from scratch */ | 85 | /* build page table from scratch */ | |
82 | movw r0, #:lower16:STARTUP_PAGETABLE_ADDR | 86 | movw r0, #:lower16:STARTUP_PAGETABLE_ADDR | |
83 | movt r0, #:upper16:STARTUP_PAGETABLE_ADDR | 87 | movt r0, #:upper16:STARTUP_PAGETABLE_ADDR | |
84 | adr r4, mmu_init_table | 88 | adr r4, mmu_init_table | |
85 | b 3f | 89 | b 3f | |
86 | 90 | |||
87 | 2: str r3, [r0, r2] | 91 | 2: str r3, [r0, r2] | |
88 | add r2, r2, #4 | 92 | add r2, r2, #4 | |
89 | add r3, r3, #(L1_S_SIZE) | 93 | add r3, r3, #(L1_S_SIZE) | |
90 | adds r1, r1, #-1 | 94 | adds r1, r1, #-1 | |
91 | bhi 2b | 95 | bhi 2b | |
92 | 3: | 96 | 3: | |
93 | ldmia r4!, {r1,r2,r3} /* # of sections, VA, PA|attr */ | 97 | ldmia r4!, {r1,r2,r3} /* # of sections, VA, PA|attr */ | |
@@ -123,26 +127,30 @@ _C_LABEL(armadaxp_start): | @@ -123,26 +127,30 @@ _C_LABEL(armadaxp_start): | |||
123 | #endif | 127 | #endif | |
124 | orr r0, r0, r1 | 128 | orr r0, r0, r1 | |
125 | mcr p15, 0, r0, c1, c0, 0 | 129 | mcr p15, 0, r0, c1, c0, 0 | |
126 | isb | 130 | isb | |
127 | dsb | 131 | dsb | |
128 | 132 | |||
129 | /* Jump to kernel code in TRUE VA */ | 133 | /* Jump to kernel code in TRUE VA */ | |
130 | movw ip, #:lower16:start | 134 | movw ip, #:lower16:start | |
131 | movt ip, #:upper16:start | 135 | movt ip, #:upper16:start | |
132 | bx ip | 136 | bx ip | |
133 | 137 | |||
134 | /* NOTREACHED */ | 138 | /* NOTREACHED */ | |
135 | 139 | |||
140 | .global _C_LABEL(uboot_regs_pa) | |||
141 | uboot_regs_pa: | |||
142 | .space 16 /* r0, r1, r2, r3 */ | |||
143 | ||||
136 | #define MMU_INIT(va,pa,n_sec,attr) \ | 144 | #define MMU_INIT(va,pa,n_sec,attr) \ | |
137 | .word n_sec ; \ | 145 | .word n_sec ; \ | |
138 | .word 4*((va)>>L1_S_SHIFT) ; \ | 146 | .word 4*((va)>>L1_S_SHIFT) ; \ | |
139 | .word (pa)|(attr) ; | 147 | .word (pa)|(attr) ; | |
140 | 148 | |||
141 | mmu_init_table: | 149 | mmu_init_table: | |
142 | /* fill all table VA==PA */ | 150 | /* fill all table VA==PA */ | |
143 | /* map SDRAM VA==PA, WT cacheable */ | 151 | /* map SDRAM VA==PA, WT cacheable */ | |
144 | MMU_INIT(MEMSTART, MEMSTART, 64, L1_TYPE_S|L1_S_C|L1_S_AP_KRW) | 152 | MMU_INIT(MEMSTART, MEMSTART, 64, L1_TYPE_S|L1_S_C|L1_S_AP_KRW) | |
145 | 153 | |||
146 | /* map VA 0x80000000..0x83ffffff to PA */ | 154 | /* map VA 0x80000000..0x83ffffff to PA */ | |
147 | MMU_INIT(KERNEL_BASE_EXT, MEMSTART, 64, L1_TYPE_S|L1_S_C|L1_S_AP_KRW) | 155 | MMU_INIT(KERNEL_BASE_EXT, MEMSTART, 64, L1_TYPE_S|L1_S_C|L1_S_AP_KRW) | |
148 | 156 |
--- src/sys/dev/marvell/if_mvgbe.c 2015/04/13 16:33:24 1.40
+++ src/sys/dev/marvell/if_mvgbe.c 2015/04/15 10:15:40 1.41
@@ -1,41 +1,41 @@ | @@ -1,41 +1,41 @@ | |||
1 | /* $NetBSD: if_mvgbe.c,v 1.40 2015/04/13 16:33:24 riastradh Exp $ */ | 1 | /* $NetBSD: if_mvgbe.c,v 1.41 2015/04/15 10:15:40 hsuenaga Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2007, 2008, 2013 KIYOHARA Takashi | 3 | * Copyright (c) 2007, 2008, 2013 KIYOHARA Takashi | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
23 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | 23 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
24 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
25 | * POSSIBILITY OF SUCH DAMAGE. | 25 | * POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | #include <sys/cdefs.h> | 27 | #include <sys/cdefs.h> | |
28 | __KERNEL_RCSID(0, "$NetBSD: if_mvgbe.c,v 1.40 2015/04/13 16:33:24 riastradh Exp $"); | 28 | __KERNEL_RCSID(0, "$NetBSD: if_mvgbe.c,v 1.41 2015/04/15 10:15:40 hsuenaga Exp $"); | |
29 | 29 | |||
30 | #include "opt_multiprocessor.h" | 30 | #include "opt_multiprocessor.h" | |
31 | 31 | |||
32 | #if defined MULTIPROCESSOR | 32 | #if defined MULTIPROCESSOR | |
33 | #warning Queue Management Method 'Counters' not support yet | 33 | #warning Queue Management Method 'Counters' not support yet | |
34 | #endif | 34 | #endif | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/bus.h> | 37 | #include <sys/bus.h> | |
38 | #include <sys/callout.h> | 38 | #include <sys/callout.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | #include <sys/endian.h> | 40 | #include <sys/endian.h> | |
41 | #include <sys/errno.h> | 41 | #include <sys/errno.h> | |
@@ -664,56 +664,72 @@ mvgbec_wininit(struct mvgbec_softc *sc, | @@ -664,56 +664,72 @@ mvgbec_wininit(struct mvgbec_softc *sc, | |||
664 | /* allow to access decode window */ | 664 | /* allow to access decode window */ | |
665 | MVGBE_WRITE(sc, MVGBE_EPAP, ac); | 665 | MVGBE_WRITE(sc, MVGBE_EPAP, ac); | |
666 | 666 | |||
667 | MVGBE_WRITE(sc, MVGBE_BARE, en); | 667 | MVGBE_WRITE(sc, MVGBE_BARE, en); | |
668 | } | 668 | } | |
669 | 669 | |||
670 | 670 | |||
671 | /* ARGSUSED */ | 671 | /* ARGSUSED */ | |
672 | static int | 672 | static int | |
673 | mvgbe_match(device_t parent, cfdata_t match, void *aux) | 673 | mvgbe_match(device_t parent, cfdata_t match, void *aux) | |
674 | { | 674 | { | |
675 | struct marvell_attach_args *mva = aux; | 675 | struct marvell_attach_args *mva = aux; | |
676 | uint32_t pbase, maddrh, maddrl; | 676 | uint32_t pbase, maddrh, maddrl; | |
677 | prop_dictionary_t dict; | |||
678 | ||||
679 | dict = device_properties(parent); | |||
680 | if (dict) { | |||
681 | if (prop_dictionary_get(dict, "mac-address")) | |||
682 | return 1; | |||
683 | } | |||
677 | 684 | |||
678 | pbase = MVGBE_PORTR_BASE + mva->mva_unit * MVGBE_PORTR_SIZE; | 685 | pbase = MVGBE_PORTR_BASE + mva->mva_unit * MVGBE_PORTR_SIZE; | |
679 | maddrh = | 686 | maddrh = | |
680 | bus_space_read_4(mva->mva_iot, mva->mva_ioh, pbase + MVGBE_MACAH); | 687 | bus_space_read_4(mva->mva_iot, mva->mva_ioh, pbase + MVGBE_MACAH); | |
681 | maddrl = | 688 | maddrl = | |
682 | bus_space_read_4(mva->mva_iot, mva->mva_ioh, pbase + MVGBE_MACAL); | 689 | bus_space_read_4(mva->mva_iot, mva->mva_ioh, pbase + MVGBE_MACAL); | |
683 | if ((maddrh | maddrl) == 0) | 690 | if ((maddrh | maddrl) == 0) | |
684 | return 0; | 691 | return 0; | |
685 | 692 | |||
686 | return 1; | 693 | return 1; | |
687 | } | 694 | } | |
688 | 695 | |||
689 | /* ARGSUSED */ | 696 | /* ARGSUSED */ | |
690 | static void | 697 | static void | |
691 | mvgbe_attach(device_t parent, device_t self, void *aux) | 698 | mvgbe_attach(device_t parent, device_t self, void *aux) | |
692 | { | 699 | { | |
693 | struct mvgbec_softc *csc = device_private(parent); | 700 | struct mvgbec_softc *csc = device_private(parent); | |
694 | struct mvgbe_softc *sc = device_private(self); | 701 | struct mvgbe_softc *sc = device_private(self); | |
695 | struct marvell_attach_args *mva = aux; | 702 | struct marvell_attach_args *mva = aux; | |
696 | struct mvgbe_txmap_entry *entry; | 703 | struct mvgbe_txmap_entry *entry; | |
704 | prop_dictionary_t dict; | |||
705 | prop_data_t enaddrp; | |||
697 | struct ifnet *ifp; | 706 | struct ifnet *ifp; | |
698 | bus_dma_segment_t seg; | 707 | bus_dma_segment_t seg; | |
699 | bus_dmamap_t dmamap; | 708 | bus_dmamap_t dmamap; | |
700 | int rseg, i; | 709 | int rseg, i; | |
701 | uint32_t maddrh, maddrl; | 710 | uint32_t maddrh, maddrl; | |
711 | uint8_t enaddr[ETHER_ADDR_LEN]; | |||
702 | void *kva; | 712 | void *kva; | |
703 | 713 | |||
704 | aprint_naive("\n"); | 714 | aprint_naive("\n"); | |
705 | aprint_normal("\n"); | 715 | aprint_normal("\n"); | |
706 | 716 | |||
717 | dict = device_properties(parent); | |||
718 | if (dict) | |||
719 | enaddrp = prop_dictionary_get(dict, "mac-address"); | |||
720 | else | |||
721 | enaddrp = NULL; | |||
722 | ||||
707 | sc->sc_dev = self; | 723 | sc->sc_dev = self; | |
708 | sc->sc_port = mva->mva_unit; | 724 | sc->sc_port = mva->mva_unit; | |
709 | sc->sc_iot = mva->mva_iot; | 725 | sc->sc_iot = mva->mva_iot; | |
710 | callout_init(&sc->sc_tick_ch, 0); | 726 | callout_init(&sc->sc_tick_ch, 0); | |
711 | callout_setfunc(&sc->sc_tick_ch, mvgbe_tick, sc); | 727 | callout_setfunc(&sc->sc_tick_ch, mvgbe_tick, sc); | |
712 | if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, | 728 | if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, | |
713 | MVGBE_PORTR_BASE + mva->mva_unit * MVGBE_PORTR_SIZE, | 729 | MVGBE_PORTR_BASE + mva->mva_unit * MVGBE_PORTR_SIZE, | |
714 | MVGBE_PORTR_SIZE, &sc->sc_ioh)) { | 730 | MVGBE_PORTR_SIZE, &sc->sc_ioh)) { | |
715 | aprint_error_dev(self, "Cannot map registers\n"); | 731 | aprint_error_dev(self, "Cannot map registers\n"); | |
716 | return; | 732 | return; | |
717 | } | 733 | } | |
718 | if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, | 734 | if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, | |
719 | MVGBE_PORTDAFR_BASE + mva->mva_unit * MVGBE_PORTDAFR_SIZE, | 735 | MVGBE_PORTDAFR_BASE + mva->mva_unit * MVGBE_PORTDAFR_SIZE, | |
@@ -741,26 +757,38 @@ mvgbe_attach(device_t parent, device_t s | @@ -741,26 +757,38 @@ mvgbe_attach(device_t parent, device_t s | |||
741 | return; | 757 | return; | |
742 | } | 758 | } | |
743 | sc->sc_linkup.bit = MVGBE_PS0_LINKUP; | 759 | sc->sc_linkup.bit = MVGBE_PS0_LINKUP; | |
744 | csc->sc_flags |= FLAGS_IPG2; | 760 | csc->sc_flags |= FLAGS_IPG2; | |
745 | } else { | 761 | } else { | |
746 | if (bus_space_subregion(mva->mva_iot, sc->sc_ioh, | 762 | if (bus_space_subregion(mva->mva_iot, sc->sc_ioh, | |
747 | MVGBE_PS, sizeof(uint32_t), &sc->sc_linkup.ioh)) { | 763 | MVGBE_PS, sizeof(uint32_t), &sc->sc_linkup.ioh)) { | |
748 | aprint_error_dev(self, "Cannot map linkup register\n"); | 764 | aprint_error_dev(self, "Cannot map linkup register\n"); | |
749 | return; | 765 | return; | |
750 | } | 766 | } | |
751 | sc->sc_linkup.bit = MVGBE_PS_LINKUP; | 767 | sc->sc_linkup.bit = MVGBE_PS_LINKUP; | |
752 | } | 768 | } | |
753 | 769 | |||
770 | if (enaddrp) { | |||
771 | memcpy(enaddr, prop_data_data_nocopy(enaddrp), ETHER_ADDR_LEN); | |||
772 | maddrh = enaddr[0] << 24; | |||
773 | maddrh |= enaddr[1] << 16; | |||
774 | maddrh |= enaddr[2] << 8; | |||
775 | maddrh |= enaddr[3]; | |||
776 | maddrl = enaddr[4] << 8; | |||
777 | maddrl |= enaddr[5]; | |||
778 | MVGBE_WRITE(sc, MVGBE_MACAH, maddrh); | |||
779 | MVGBE_WRITE(sc, MVGBE_MACAL, maddrl); | |||
780 | } | |||
781 | ||||
754 | maddrh = MVGBE_READ(sc, MVGBE_MACAH); | 782 | maddrh = MVGBE_READ(sc, MVGBE_MACAH); | |
755 | maddrl = MVGBE_READ(sc, MVGBE_MACAL); | 783 | maddrl = MVGBE_READ(sc, MVGBE_MACAL); | |
756 | sc->sc_enaddr[0] = maddrh >> 24; | 784 | sc->sc_enaddr[0] = maddrh >> 24; | |
757 | sc->sc_enaddr[1] = maddrh >> 16; | 785 | sc->sc_enaddr[1] = maddrh >> 16; | |
758 | sc->sc_enaddr[2] = maddrh >> 8; | 786 | sc->sc_enaddr[2] = maddrh >> 8; | |
759 | sc->sc_enaddr[3] = maddrh >> 0; | 787 | sc->sc_enaddr[3] = maddrh >> 0; | |
760 | sc->sc_enaddr[4] = maddrl >> 8; | 788 | sc->sc_enaddr[4] = maddrl >> 8; | |
761 | sc->sc_enaddr[5] = maddrl >> 0; | 789 | sc->sc_enaddr[5] = maddrl >> 0; | |
762 | aprint_normal_dev(self, "Ethernet address %s\n", | 790 | aprint_normal_dev(self, "Ethernet address %s\n", | |
763 | ether_sprintf(sc->sc_enaddr)); | 791 | ether_sprintf(sc->sc_enaddr)); | |
764 | 792 | |||
765 | /* clear all ethernet port interrupts */ | 793 | /* clear all ethernet port interrupts */ | |
766 | MVGBE_WRITE(sc, MVGBE_IC, 0); | 794 | MVGBE_WRITE(sc, MVGBE_IC, 0); |