diff options
author | Jayachandran C <jchandra@broadcom.com> | 2013-06-10 02:41:00 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2013-06-13 11:46:42 -0400 |
commit | aceee09d4f09dd7a6be48d04d329c140a5caaaf7 (patch) | |
tree | 8082720757c04de138ef8d38c61d82a1121c4076 | |
parent | 8f0b043045d0b19d7eb8b510bfe279c9bb05d952 (diff) |
MIPS: Netlogic: Split XLP device tree code to dt.c
Create new flle arch/mips/netlogic/xlp/dt.c and move the device
tree related code there.
Signed-off-by: Jayachandran C <jchandra@broadcom.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5422/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/netlogic/xlp-hal/xlp.h | 1 | ||||
-rw-r--r-- | arch/mips/netlogic/xlp/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/netlogic/xlp/dt.c | 99 | ||||
-rw-r--r-- | arch/mips/netlogic/xlp/setup.c | 73 |
4 files changed, 105 insertions, 70 deletions
diff --git a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h index 7e47209327a5..f4ea0f7f3965 100644 --- a/arch/mips/include/asm/netlogic/xlp-hal/xlp.h +++ b/arch/mips/include/asm/netlogic/xlp-hal/xlp.h | |||
@@ -59,6 +59,7 @@ void xlp_wakeup_secondary_cpus(void); | |||
59 | 59 | ||
60 | void xlp_mmu_init(void); | 60 | void xlp_mmu_init(void); |
61 | void nlm_hal_init(void); | 61 | void nlm_hal_init(void); |
62 | void *xlp_dt_init(void *fdtp); | ||
62 | 63 | ||
63 | #endif /* !__ASSEMBLY__ */ | 64 | #endif /* !__ASSEMBLY__ */ |
64 | #endif /* _ASM_NLM_XLP_H */ | 65 | #endif /* _ASM_NLM_XLP_H */ |
diff --git a/arch/mips/netlogic/xlp/Makefile b/arch/mips/netlogic/xlp/Makefile index e8dd14c38cb6..85ac4a892ced 100644 --- a/arch/mips/netlogic/xlp/Makefile +++ b/arch/mips/netlogic/xlp/Makefile | |||
@@ -1,3 +1,3 @@ | |||
1 | obj-y += setup.o nlm_hal.o cop2-ex.o | 1 | obj-y += setup.o nlm_hal.o cop2-ex.o dt.o |
2 | obj-$(CONFIG_SMP) += wakeup.o | 2 | obj-$(CONFIG_SMP) += wakeup.o |
3 | obj-$(CONFIG_USB) += usb-init.o | 3 | obj-$(CONFIG_USB) += usb-init.o |
diff --git a/arch/mips/netlogic/xlp/dt.c b/arch/mips/netlogic/xlp/dt.c new file mode 100644 index 000000000000..a15cdbb8d0bd --- /dev/null +++ b/arch/mips/netlogic/xlp/dt.c | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * Copyright 2003-2013 Broadcom Corporation. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This software is available to you under a choice of one of two | ||
6 | * licenses. You may choose to be licensed under the terms of the GNU | ||
7 | * General Public License (GPL) Version 2, available from the file | ||
8 | * COPYING in the main directory of this source tree, or the Broadcom | ||
9 | * license below: | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer. | ||
17 | * 2. Redistributions in binary form must reproduce the above copyright | ||
18 | * notice, this list of conditions and the following disclaimer in | ||
19 | * the documentation and/or other materials provided with the | ||
20 | * distribution. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR | ||
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
25 | * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE | ||
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
29 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
30 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
31 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | ||
32 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | */ | ||
34 | |||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/bootmem.h> | ||
37 | |||
38 | #include <linux/of_fdt.h> | ||
39 | #include <linux/of_platform.h> | ||
40 | #include <linux/of_device.h> | ||
41 | |||
42 | extern u32 __dtb_xlp_evp_begin[], __dtb_xlp_svp_begin[], __dtb_start[]; | ||
43 | |||
44 | void __init *xlp_dt_init(void *fdtp) | ||
45 | { | ||
46 | if (!fdtp) { | ||
47 | switch (current_cpu_data.processor_id & 0xff00) { | ||
48 | #ifdef CONFIG_DT_XLP_SVP | ||
49 | case PRID_IMP_NETLOGIC_XLP3XX: | ||
50 | fdtp = __dtb_xlp_svp_begin; | ||
51 | break; | ||
52 | #endif | ||
53 | #ifdef CONFIG_DT_XLP_EVP | ||
54 | case PRID_IMP_NETLOGIC_XLP8XX: | ||
55 | fdtp = __dtb_xlp_evp_begin; | ||
56 | break; | ||
57 | #endif | ||
58 | default: | ||
59 | /* Pick a built-in if any, and hope for the best */ | ||
60 | fdtp = __dtb_start; | ||
61 | break; | ||
62 | } | ||
63 | } | ||
64 | initial_boot_params = fdtp; | ||
65 | return fdtp; | ||
66 | } | ||
67 | |||
68 | void __init device_tree_init(void) | ||
69 | { | ||
70 | unsigned long base, size; | ||
71 | |||
72 | if (!initial_boot_params) | ||
73 | return; | ||
74 | |||
75 | base = virt_to_phys((void *)initial_boot_params); | ||
76 | size = be32_to_cpu(initial_boot_params->totalsize); | ||
77 | |||
78 | /* Before we do anything, lets reserve the dt blob */ | ||
79 | reserve_bootmem(base, size, BOOTMEM_DEFAULT); | ||
80 | |||
81 | unflatten_device_tree(); | ||
82 | |||
83 | /* free the space reserved for the dt blob */ | ||
84 | free_bootmem(base, size); | ||
85 | } | ||
86 | |||
87 | static struct of_device_id __initdata xlp_ids[] = { | ||
88 | { .compatible = "simple-bus", }, | ||
89 | {}, | ||
90 | }; | ||
91 | |||
92 | int __init xlp8xx_ds_publish_devices(void) | ||
93 | { | ||
94 | if (!of_have_populated_dt()) | ||
95 | return 0; | ||
96 | return of_platform_bus_probe(NULL, xlp_ids, NULL); | ||
97 | } | ||
98 | |||
99 | device_initcall(xlp8xx_ds_publish_devices); | ||
diff --git a/arch/mips/netlogic/xlp/setup.c b/arch/mips/netlogic/xlp/setup.c index eaa99d28cb8e..7b6694998cdc 100644 --- a/arch/mips/netlogic/xlp/setup.c +++ b/arch/mips/netlogic/xlp/setup.c | |||
@@ -33,19 +33,13 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
36 | #include <linux/serial_8250.h> | 36 | #include <linux/of_fdt.h> |
37 | #include <linux/pm.h> | ||
38 | #include <linux/bootmem.h> | ||
39 | 37 | ||
40 | #include <asm/idle.h> | 38 | #include <asm/idle.h> |
41 | #include <asm/reboot.h> | 39 | #include <asm/reboot.h> |
42 | #include <asm/time.h> | 40 | #include <asm/time.h> |
43 | #include <asm/bootinfo.h> | 41 | #include <asm/bootinfo.h> |
44 | 42 | ||
45 | #include <linux/of_fdt.h> | ||
46 | #include <linux/of_platform.h> | ||
47 | #include <linux/of_device.h> | ||
48 | |||
49 | #include <asm/netlogic/haldefs.h> | 43 | #include <asm/netlogic/haldefs.h> |
50 | #include <asm/netlogic/common.h> | 44 | #include <asm/netlogic/common.h> |
51 | 45 | ||
@@ -57,7 +51,6 @@ uint64_t nlm_io_base; | |||
57 | struct nlm_soc_info nlm_nodes[NLM_NR_NODES]; | 51 | struct nlm_soc_info nlm_nodes[NLM_NR_NODES]; |
58 | cpumask_t nlm_cpumask = CPU_MASK_CPU0; | 52 | cpumask_t nlm_cpumask = CPU_MASK_CPU0; |
59 | unsigned int nlm_threads_per_core; | 53 | unsigned int nlm_threads_per_core; |
60 | extern u32 __dtb_xlp_evp_begin[], __dtb_xlp_svp_begin[], __dtb_start[]; | ||
61 | 54 | ||
62 | static void nlm_linux_exit(void) | 55 | static void nlm_linux_exit(void) |
63 | { | 56 | { |
@@ -70,39 +63,13 @@ static void nlm_linux_exit(void) | |||
70 | 63 | ||
71 | void __init plat_mem_setup(void) | 64 | void __init plat_mem_setup(void) |
72 | { | 65 | { |
73 | void *fdtp; | ||
74 | |||
75 | panic_timeout = 5; | 66 | panic_timeout = 5; |
76 | _machine_restart = (void (*)(char *))nlm_linux_exit; | 67 | _machine_restart = (void (*)(char *))nlm_linux_exit; |
77 | _machine_halt = nlm_linux_exit; | 68 | _machine_halt = nlm_linux_exit; |
78 | pm_power_off = nlm_linux_exit; | 69 | pm_power_off = nlm_linux_exit; |
79 | 70 | ||
80 | /* | 71 | /* memory and bootargs from DT */ |
81 | * If no FDT pointer is passed in, use the built-in FDT. | 72 | early_init_devtree(initial_boot_params); |
82 | * device_tree_init() does not handle CKSEG0 pointers in | ||
83 | * 64-bit, so convert pointer. | ||
84 | */ | ||
85 | fdtp = (void *)(long)fw_arg0; | ||
86 | if (!fdtp) { | ||
87 | switch (current_cpu_data.processor_id & 0xff00) { | ||
88 | #ifdef CONFIG_DT_XLP_SVP | ||
89 | case PRID_IMP_NETLOGIC_XLP3XX: | ||
90 | fdtp = __dtb_xlp_svp_begin; | ||
91 | break; | ||
92 | #endif | ||
93 | #ifdef CONFIG_DT_XLP_EVP | ||
94 | case PRID_IMP_NETLOGIC_XLP8XX: | ||
95 | fdtp = __dtb_xlp_evp_begin; | ||
96 | break; | ||
97 | #endif | ||
98 | default: | ||
99 | /* Pick a built-in if any, and hope for the best */ | ||
100 | fdtp = __dtb_start; | ||
101 | break; | ||
102 | } | ||
103 | } | ||
104 | fdtp = phys_to_virt(__pa(fdtp)); | ||
105 | early_init_devtree(fdtp); | ||
106 | } | 73 | } |
107 | 74 | ||
108 | const char *get_system_type(void) | 75 | const char *get_system_type(void) |
@@ -134,6 +101,7 @@ void __init prom_init(void) | |||
134 | nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); | 101 | nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE); |
135 | xlp_mmu_init(); | 102 | xlp_mmu_init(); |
136 | nlm_node_init(0); | 103 | nlm_node_init(0); |
104 | xlp_dt_init((void *)(long)fw_arg0); | ||
137 | 105 | ||
138 | #ifdef CONFIG_SMP | 106 | #ifdef CONFIG_SMP |
139 | cpumask_setall(&nlm_cpumask); | 107 | cpumask_setall(&nlm_cpumask); |
@@ -145,36 +113,3 @@ void __init prom_init(void) | |||
145 | register_smp_ops(&nlm_smp_ops); | 113 | register_smp_ops(&nlm_smp_ops); |
146 | #endif | 114 | #endif |
147 | } | 115 | } |
148 | |||
149 | void __init device_tree_init(void) | ||
150 | { | ||
151 | unsigned long base, size; | ||
152 | |||
153 | if (!initial_boot_params) | ||
154 | return; | ||
155 | |||
156 | base = virt_to_phys((void *)initial_boot_params); | ||
157 | size = be32_to_cpu(initial_boot_params->totalsize); | ||
158 | |||
159 | /* Before we do anything, lets reserve the dt blob */ | ||
160 | reserve_bootmem(base, size, BOOTMEM_DEFAULT); | ||
161 | |||
162 | unflatten_device_tree(); | ||
163 | |||
164 | /* free the space reserved for the dt blob */ | ||
165 | free_bootmem(base, size); | ||
166 | } | ||
167 | |||
168 | static struct of_device_id __initdata xlp_ids[] = { | ||
169 | { .compatible = "simple-bus", }, | ||
170 | {}, | ||
171 | }; | ||
172 | |||
173 | int __init xlp8xx_ds_publish_devices(void) | ||
174 | { | ||
175 | if (!of_have_populated_dt()) | ||
176 | return 0; | ||
177 | return of_platform_bus_probe(NULL, xlp_ids, NULL); | ||
178 | } | ||
179 | |||
180 | device_initcall(xlp8xx_ds_publish_devices); | ||