forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-08-21 fc437ccf3419c424092701f3d883215fa4552a8b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
From a243628639e12a4bd0a737eac78a12ed240cd137 Mon Sep 17 00:00:00 2001
From: Oleksandr G Zhadan <oleks@arcturusnetworks.com>
Date: Mon, 18 Jul 2016 10:40:16 -0400
Subject: [PATCH] Arcturus uCP1020 BSP support
 
The uCP1020 product family (ucp1020) is an Arcturus Networks Inc.
System on Modules product featuring a NXP QorIQ P1020 CPU,
optionally populated with 1 or 2 Gig-Ethernet PHYs,
DDR3, NOR Flash, eMMC NAND Flash and/or SPI Flash.
 
Signed-off-by: Oleksandr G Zhadan <oleks@arcturusnetworks.com>
Signed-off-by: Michael Durrant <arcsupport@arcturusnetworks.com>
---
 arch/powerpc/boot/dts/ucp1020.dts         |  87 ++++++++++++
 arch/powerpc/boot/dts/ucp1020.dtsi        | 211 ++++++++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/Kconfig       |   7 +
 arch/powerpc/platforms/85xx/Makefile      |   1 +
 arch/powerpc/platforms/85xx/ucp1020_som.c |  92 +++++++++++++
 5 files changed, 398 insertions(+)
 create mode 100644 arch/powerpc/boot/dts/ucp1020.dts
 create mode 100644 arch/powerpc/boot/dts/ucp1020.dtsi
 create mode 100644 arch/powerpc/platforms/85xx/ucp1020_som.c
 
diff --git a/arch/powerpc/boot/dts/ucp1020.dts b/arch/powerpc/boot/dts/ucp1020.dts
new file mode 100644
index 0000000..291e70a
--- /dev/null
+++ b/arch/powerpc/boot/dts/ucp1020.dts
@@ -0,0 +1,87 @@
+/*
+ * uCP1020 Tree Source (32-bit address map)
+ *
+ * Copyright 2013-2016 Arcturus Networks Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Freescale Semiconductor nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/include/ "fsl/p1020si-pre.dtsi"
+/ {
+    model = "arcturus,uCP1020";
+    compatible = "arcturus,uCP1020";
+
+    memory {
+        device_type = "memory";
+    };
+
+    lbc: localbus@ffe05000 {
+        reg = <0 0xffe05000 0 0x1000>;
+
+        /* NOR Flash */
+        ranges = <0x0 0x0 0x0 0xec000000 0x04000000>;
+    };
+
+    soc: soc@ffe00000 {
+        ranges = <0x0 0x0 0xffe00000 0x100000>;
+    };
+
+    pci0: pcie@ffe09000 {
+        ranges = <0x2000000 0x0 0xa0000000 0 0xa0000000 0x0 0x20000000
+              0x1000000 0x0 0x00000000 0 0xffc10000 0x0 0x10000>;
+        reg = <0 0xffe09000 0 0x1000>;
+        pcie@0 {
+            ranges = <0x2000000 0x0 0xa0000000
+                  0x2000000 0x0 0xa0000000
+                  0x0 0x20000000
+
+                  0x1000000 0x0 0x0
+                  0x1000000 0x0 0x0
+                  0x0 0x100000>;
+        };
+    };
+
+    pci1: pcie@ffe0a000 {
+        reg = <0 0xffe0a000 0 0x1000>;
+        ranges = <0x2000000 0x0 0x80000000 0 0x80000000 0x0 0x20000000
+              0x1000000 0x0 0x00000000 0 0xffc00000 0x0 0x10000>;
+        pcie@0 {
+            ranges = <0x2000000 0x0 0x80000000
+                  0x2000000 0x0 0x80000000
+                  0x0 0x20000000
+
+                  0x1000000 0x0 0x0
+                  0x1000000 0x0 0x0
+                  0x0 0x100000>;
+        };
+    };
+};
+
+/include/ "ucp1020.dtsi"
+/include/ "fsl/p1020si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/ucp1020.dtsi b/arch/powerpc/boot/dts/ucp1020.dtsi
new file mode 100644
index 0000000..7cff949
--- /dev/null
+++ b/arch/powerpc/boot/dts/ucp1020.dtsi
@@ -0,0 +1,211 @@
+/*
+ * uCP1020 Device Tree Source stub (no addresses or top-level ranges)
+ *
+ * Copyright 2013-2016 Arcturus Networks Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of Freescale Semiconductor nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+&lbc {
+    nor@0,0 {
+        #address-cells = <1>;
+        #size-cells = <1>;
+        compatible = "cfi-flash";
+        reg = <0x0 0x0 0x04000000>;
+        bank-width = <2>;
+        device-width = <1>;
+
+        partition@100000 {
+            /* 7MB - PART 0 */
+            reg = <0x00100000 0x00700000>;
+            label = "0";
+        };
+
+        partition@800000 {
+            /* 32MB - PART 1 */
+            reg = <0x0800000 0x02000000>;
+            label = "1";
+        };
+
+        partition@2800000 {
+            /* 8MB - PART 2 */
+            reg = <0x02800000 0x00800000>;
+            label = "2";
+        };
+
+        partition@3000000 {
+            /* (16MB - 512K) - PART 3 JFFS 2 */
+            reg = <0x03000000 0x00f80000>;
+            label = "3";
+        };
+
+        partition@0 {
+            /* 512KB - bootloader[u-boot, uCbootloader] */
+            reg = <0x0 0x00080000>;
+            label = "BOOT_SPI";
+        };
+
+        partition@3f80000 {
+            /* 512KB - bootloade NOR r[u-boot, uCbootloader] */
+            reg = <0x03f80000 0x00080000>;
+            label = "B";
+        };
+
+        partition@80000 {
+            /* 256KB - bootloaders environment (uCenv) */
+            reg = <0x00080000 0x00040000>;
+    
+            label = "E";
+        };
+
+        partition@C0000 {
+            /* 256KB - bootloaders environment (u-boot) */
+            reg = <0x000C0000 0x00040000>;
+            label = "UENV";
+        };
+    };
+};
+
+&soc {
+    i2c@3000 {
+        spoc@14 {
+            compatible = "conexant,cx2070x";
+            reg = <0x14>;
+        };
+    };
+
+    i2c@3100 {
+            dtt@4C {
+                compatible = "national,lm90";
+                reg = <0x4C>;
+            };
+    };
+
+    spi@7000 {
+        flash@0 {
+            #address-cells = <1>;
+            #size-cells = <1>;
+            compatible = "winbond,w25q80bl";
+            reg = <0>;
+            spi-max-frequency = <40000000>; /* input clock */
+
+            partition@0 {
+                label = "SPI MBR";
+                reg = <0x00000000 0x00002000>;
+                read-only;
+            };
+            partition@2000 {
+                label = "SPI ENV";
+                reg = <0x00002000 0x00006000>;
+                read-only;
+            };
+            partition@8000 {
+                label = "SPI FS";
+                reg = <0x00008000 0x000F8000>;
+            };
+        };
+        flash@3 {
+            #address-cells = <1>;
+            #size-cells = <1>;
+            compatible = "spansion,s25fl008k";
+            reg = <3>;
+            spi-max-frequency = <40000000>; /* input clock */
+            partition@0 {
+                label = "SPI USER";
+                reg = <0x00000000 0x00100000>;
+            };
+        };
+    };
+
+    usb@22000 {
+        phy_type = "ulpi";
+        dr_mode = "host";
+    };
+
+    mdio@24000 {
+        phy0: ethernet-phy@4 {
+            interrupt-parent = <&mpic>;
+            interrupts = <4 1>;
+            reg = <0x04>;
+        };
+
+        phy1: ethernet-phy@6 {
+            interrupt-parent = <&mpic>;
+            interrupts = <8 1>;
+            reg = <0x6>;
+        };
+    };
+
+    enet0: ethernet@b0000 {
+        phy-handle = <&phy0>;
+        phy-connection-type = "rgmii-id";
+    };
+
+    enet1: ethernet@b1000 {
+        status = "disabled";
+    };
+
+    enet2: ethernet@b2000 {
+        phy-handle = <&phy1>;
+        phy-connection-type = "rgmii-id";
+    };
+
+    gpio0: gpio@f000 {
+        compatible = "fsl,mpc8572-gpio", "fsl,pq3-gpio";
+        reg = <0xf000 0x1000>;
+        interrupts = <47 2>;
+        interrupt-parent = <&mpic>;
+        #gpio-cells = <2>;
+        gpio-controller;
+    };
+
+    gpio-leds {
+        compatible = "gpio-leds";
+        gpio5 {
+            label = "led1";        /* LED15 */
+            gpios = <&gpio0 5 0>;
+        };
+        gpio12 {
+            label = "led2";        /* LED16 */
+            gpios = <&gpio0 12 0>;
+        };
+        gpio13 {
+            label = "led3";        /* LED17 */
+            gpios = <&gpio0 13 0>;
+        };
+        gpio7 {
+            label = "led4";        /* LED18 */
+            gpios = <&gpio0 7 0>;
+        };
+        gpio6 {
+            label = "led5";        /* LED19 */
+            gpios = <&gpio0 6 0>;
+        };
+    };
+};
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index 2fb4b24..81a944f 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -241,6 +241,13 @@ config SGY_CTS1000
     help
       Enable this to support functionality in Servergy's CTS-1000 systems.
 
+config UCP1020_SOM
+    bool "Arcturus uCP1020 Rev.1.3 System on Module"
+    select DEFAULT_UIMAGE
+    help
+      This option enables support for the Arcturus Networks Inc. 
+      uCP1020 System on Module.
+
 config MVME2500
     bool "Artesyn MVME2500"
     select DEFAULT_UIMAGE
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 1fe7fb9..84f2b9a 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -31,4 +31,5 @@ obj-$(CONFIG_XES_MPC85xx) += xes_mpc85xx.o
 obj-$(CONFIG_GE_IMP3A)      += ge_imp3a.o
 obj-$(CONFIG_PPC_QEMU_E500) += qemu_e500.o
 obj-$(CONFIG_SGY_CTS1000) += sgy_cts1000.o
+obj-$(CONFIG_UCP1020_SOM) += ucp1020_som.o
 obj-$(CONFIG_MVME2500)      += mvme2500.o
diff --git a/arch/powerpc/platforms/85xx/ucp1020_som.c b/arch/powerpc/platforms/85xx/ucp1020_som.c
new file mode 100644
index 0000000..777e8ad
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/ucp1020_som.c
@@ -0,0 +1,92 @@
+/*
+ * Arcturus Networks Inc. uCP1020 module Setup
+ *
+ * Copyright 2014-2016 Arcturus Networks Inc.
+ *
+ * by Oleksandr G Zhadan & Michael Durrant (www.ArcturusNetworks.com)
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/kdev_t.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+#include <linux/interrupt.h>
+#include <linux/of_platform.h>
+
+#include <asm/time.h>
+#include <asm/machdep.h>
+#include <asm/pci-bridge.h>
+#include <mm/mmu_decl.h>
+#include <asm/prom.h>
+#include <asm/udbg.h>
+#include <asm/mpic.h>
+#include <asm/fsl_guts.h>
+
+#include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
+#include "smp.h"
+
+#include "mpc85xx.h"
+
+void __init ucp1020_som_pic_init(void)
+{
+    struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
+      MPIC_SINGLE_DEST_CPU,
+      0, 256, " OpenPIC  ");
+
+    BUG_ON(mpic == NULL);
+
+    mpic_init(mpic);
+}
+
+/*
+ * Setup the architecture
+ */
+static void __init ucp1020_som_setup_arch(void)
+{
+    if (ppc_md.progress)
+        ppc_md.progress("uCP1020_SoM_setup_arch()", 0);
+
+    mpc85xx_smp_init();
+
+    fsl_pci_assign_primary();
+    pr_info("\n\t%s (http://www.arcturusnetworks.com)\n", ppc_md.name);
+}
+
+machine_arch_initcall(ucp1020, mpc85xx_common_publish_devices);
+machine_arch_initcall(ucp1020, swiotlb_setup_bus_notifier);
+
+/*
+ * Called very early, device-tree isn't unflattened
+ */
+static int __init ucp1020_probe(void)
+{
+    unsigned long root = of_get_flat_dt_root();
+
+    if (of_flat_dt_is_compatible(root, "arcturus,uCP1020"))
+        return 1;
+    return 0;
+}
+
+define_machine(ucp1020) {
+    .name            = "uCP1020 SoM - Arcturus Networks Inc.",
+    .probe            = ucp1020_probe,
+    .setup_arch        = ucp1020_som_setup_arch,
+    .init_IRQ        = ucp1020_som_pic_init,
+#ifdef CONFIG_PCI
+    .pcibios_fixup_bus    = fsl_pcibios_fixup_bus,
+#endif
+    .get_irq        = mpic_get_irq,
+    .restart        = fsl_rstcr_restart,
+    .calibrate_decr        = generic_calibrate_decr,
+#ifdef DEBUG 
+    .progress        = udbg_progress,
+#endif
+};
-- 
2.1.4