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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
|
From 4953294aa8f8b9023e6b5f7f39059706c72d916c Mon Sep 17 00:00:00 2001
From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Date: Sun, 9 Dec 2012 17:54:56 +0100
Subject: MIPS: lantiq: add support for Lantiq XWAY ARX100 SoC family
Signed-off-by: Luka Perkov <luka@openwrt.org>
Signed-off-by: John Crispin <blogic@openwrt.org>
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/Makefile
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2000-2011 Wolfgang Denk, DENX Software Engineering, wd@denx.de
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = $(obj)lib$(SOC).o
+
+COBJS-y += cgu.o chipid.o ebu.o mem.o pmu.o rcu.o
+SOBJS-y += cgu_init.o mem_init.o
+
+COBJS := $(COBJS-y)
+SOBJS := $(SOBJS-y)
+SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
+
+all: $(LIB)
+
+$(LIB): $(obj).depend $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/cgu.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
+ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arch/soc.h>
+#include <asm/lantiq/clk.h>
+#include <asm/lantiq/io.h>
+
+#define CGU_SYS_DDR_SEL (1 << 0)
+#define CGU_SYS_CPU_SEL (1 << 2)
+#define CGU_SYS_SYS_SHIFT 3
+#define CGU_SYS_SYS_MASK (0x3 << CGU_SYS_SYS_SHIFT)
+#define CGU_SYS_FPI_SEL (1 << 6)
+#define CGU_SYS_PPE_SEL (1 << 7)
+
+struct ltq_cgu_regs {
+ u32 rsvd0;
+ __be32 pll0_cfg; /* PLL0 config */
+ __be32 pll1_cfg; /* PLL1 config */
+ u32 rsvd2;
+ __be32 sys; /* System clock */
+ __be32 update; /* CGU update control */
+ __be32 if_clk; /* Interface clock */
+ u32 rsvd3;
+ __be32 smd; /* SDRAM Memory Control */
+ u32 rsvd4;
+ __be32 ct1_sr; /* CT status 1 */
+ __be32 ct_kval; /* CT K value */
+ __be32 pcm_cr; /* PCM control */
+};
+
+static struct ltq_cgu_regs *ltq_cgu_regs =
+ (struct ltq_cgu_regs *) CKSEG1ADDR(LTQ_CGU_BASE);
+
+static inline u32 ltq_cgu_sys_readl(u32 mask, u32 shift)
+{
+ return (ltq_readl(<q_cgu_regs->sys) & mask) >> shift;
+}
+
+static unsigned long ltq_get_system_clock(void)
+{
+ u32 sys_sel;
+ unsigned long clk;
+
+ sys_sel = ltq_cgu_sys_readl(CGU_SYS_SYS_MASK, CGU_SYS_SYS_SHIFT);
+
+ switch (sys_sel) {
+ case 0:
+ clk = CLOCK_333_MHZ;
+ break;
+ case 2:
+ clk = CLOCK_393_MHZ;
+ break;
+ default:
+ clk = 0;
+ break;
+ }
+
+ return clk;
+}
+
+unsigned long ltq_get_io_region_clock(void)
+{
+ u32 ddr_sel;
+ unsigned long clk;
+
+ ddr_sel = ltq_cgu_sys_readl(1, CGU_SYS_DDR_SEL);
+
+ if (ddr_sel)
+ clk = ltq_get_system_clock() / 3;
+ else
+ clk = ltq_get_system_clock() / 2;
+
+ return clk;
+}
+
+unsigned long ltq_get_cpu_clock(void)
+{
+ u32 cpu_sel;
+ unsigned long clk;
+
+ cpu_sel = ltq_cgu_sys_readl(1, CGU_SYS_CPU_SEL);
+
+ if (cpu_sel)
+ clk = ltq_get_io_region_clock();
+ else
+ clk = ltq_get_system_clock();
+
+ return clk;
+}
+
+unsigned long ltq_get_bus_clock(void)
+{
+ u32 fpi_sel;
+ unsigned long clk;
+
+ fpi_sel = ltq_cgu_sys_readl(1, CGU_SYS_FPI_SEL);
+
+ if (fpi_sel)
+ clk = ltq_get_io_region_clock() / 2;
+ else
+ clk = ltq_get_io_region_clock();
+
+ return clk;
+}
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/cgu_init.S
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
+ * Copyright (C) 2012-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/addrspace.h>
+#include <asm/arch/soc.h>
+
+/* CGU module register */
+#define CGU_PLL0_CFG 0x0004 /* PLL0 config */
+#define CGU_PLL1_CFG 0x0008 /* PLL1 config */
+#define CGU_SYS 0x0010 /* System clock */
+#define CGU_UPDATE 0x0014 /* Clock update control */
+
+/* Valid SYS.PPE_SEL values */
+#define CGU_SYS_PPESEL_SHIFT 7
+#define CGU_SYS_PPESEL_250_MHZ (0x1 << CGU_SYS_PPESEL_SHIFT)
+
+/* Valid SYS.SYS_SEL values */
+#define CGU_SYS_SYSSEL_SHIFT 3
+#define CGU_SYS_SYSSEL_PLL0_333_MHZ (0x0 << CGU_SYS_SYSSEL_SHIFT)
+#define CGU_SYS_SYSSEL_PLL1_393_MHZ (0x2 << CGU_SYS_SYSSEL_SHIFT)
+
+/* Valid SYS.CPU_SEL values */
+#define CGU_SYS_CPUSEL_SHIFT 2
+#define CGU_SYS_CPUSEL_EQUAL_SYSCLK (0x0 << CGU_SYS_CPUSEL_SHIFT)
+#define CGU_SYS_CPUSEL_EQUAL_DDRCLK (0x1 << CGU_SYS_CPUSEL_SHIFT)
+
+/* Valid SYS.DDR_SEL values */
+#define CGU_SYS_DDRSEL_HALF_SYSCLK 0x0
+#define CGU_SYS_DDRSEL_THIRD_SYSCLK 0x1
+
+#define CGU_UPDATE_UPD 0x1
+
+#if (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_393_DDR_197)
+#define CGU_SYS_PPESEL_CONFIG CGU_SYS_PPESEL_250_MHZ
+#define CGU_SYS_SYSSEL_CONFIG CGU_SYS_SYSSEL_PLL1_393_MHZ
+#define CGU_SYS_CPUSEL_CONFIG CGU_SYS_CPUSEL_EQUAL_SYSCLK
+#define CGU_SYS_DDRSEL_CONFIG CGU_SYS_DDRSEL_HALF_SYSCLK
+#elif (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_197_DDR_197)
+#define CGU_SYS_PPESEL_CONFIG CGU_SYS_PPESEL_250_MHZ
+#define CGU_SYS_SYSSEL_CONFIG CGU_SYS_SYSSEL_PLL1_393_MHZ
+#define CGU_SYS_CPUSEL_CONFIG CGU_SYS_CPUSEL_EQUAL_DDRCLK
+#define CGU_SYS_DDRSEL_CONFIG CGU_SYS_DDRSEL_HALF_SYSCLK
+#elif (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_333_DDR_167)
+#define CGU_SYS_PPESEL_CONFIG CGU_SYS_PPESEL_250_MHZ
+#define CGU_SYS_SYSSEL_CONFIG CGU_SYS_SYSSEL_PLL0_333_MHZ
+#define CGU_SYS_CPUSEL_CONFIG CGU_SYS_CPUSEL_EQUAL_SYSCLK
+#define CGU_SYS_DDRSEL_CONFIG CGU_SYS_DDRSEL_HALF_SYSCLK
+#elif (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_167_DDR_167)
+#define CGU_SYS_PPESEL_CONFIG CGU_SYS_PPESEL_250_MHZ
+#define CGU_SYS_SYSSEL_CONFIG CGU_SYS_SYSSEL_PLL0_333_MHZ
+#define CGU_SYS_CPUSEL_CONFIG CGU_SYS_CPUSEL_EQUAL_DDRCLK
+#define CGU_SYS_DDRSEL_CONFIG CGU_SYS_DDRSEL_HALF_SYSCLK
+#elif (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_131_DDR_131)
+#define CGU_SYS_PPESEL_CONFIG CGU_SYS_PPESEL_250_MHZ
+#define CGU_SYS_SYSSEL_CONFIG CGU_SYS_SYSSEL_PLL1_393_MHZ
+#define CGU_SYS_CPUSEL_CONFIG CGU_SYS_CPUSEL_EQUAL_DDRCLK
+#define CGU_SYS_DDRSEL_CONFIG CGU_SYS_DDRSEL_THIRD_SYSCLK
+#elif (CONFIG_SYS_CLOCK_MODE == LTQ_CLK_CPU_111_DDR_111)
+#define CGU_SYS_PPESEL_CONFIG CGU_SYS_PPESEL_250_MHZ
+#define CGU_SYS_SYSSEL_CONFIG CGU_SYS_SYSSEL_PLL0_333_MHZ
+#define CGU_SYS_CPUSEL_CONFIG CGU_SYS_CPUSEL_EQUAL_DDRCLK
+#define CGU_SYS_DDRSEL_CONFIG CGU_SYS_DDRSEL_THIRD_SYSCLK
+#else
+#error "Invalid system clock configuration!"
+#endif
+
+/* Build register values */
+#define CGU_SYS_VALUE (CGU_SYS_PPESEL_CONFIG | \
+ CGU_SYS_SYSSEL_CONFIG | \
+ CGU_SYS_CPUSEL_CONFIG | \
+ CGU_SYS_DDRSEL_CONFIG)
+
+ .set noreorder
+
+LEAF(ltq_cgu_init)
+ /* Load current CGU register value */
+ li t0, (LTQ_CGU_BASE | KSEG1)
+ lw t1, CGU_SYS(t0)
+
+ /* Load target CGU register values */
+ li t2, CGU_SYS_VALUE
+
+ /* Only update registers if values differ */
+ beq t1, t2, finished
+ nop
+
+ /* Store target register values */
+ sw t2, CGU_SYS(t0)
+
+ /* Trigger CGU update */
+ li t1, CGU_UPDATE_UPD
+ sw t1, CGU_UPDATE(t0)
+
+finished:
+ jr ra
+ nop
+
+ END(ltq_cgu_init)
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/chipid.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/lantiq/io.h>
+#include <asm/lantiq/chipid.h>
+#include <asm/arch/soc.h>
+
+#define LTQ_CHIPID_VERSION_SHIFT 28
+#define LTQ_CHIPID_VERSION_MASK (0xF << LTQ_CHIPID_VERSION_SHIFT)
+#define LTQ_CHIPID_PNUM_SHIFT 12
+#define LTQ_CHIPID_PNUM_MASK (0xFFFF << LTQ_CHIPID_PNUM_SHIFT)
+
+struct ltq_chipid_regs {
+ u32 manid; /* Manufacturer identification */
+ u32 chipid; /* Chip identification */
+};
+
+static struct ltq_chipid_regs *ltq_chipid_regs =
+ (struct ltq_chipid_regs *) CKSEG1ADDR(LTQ_CHIPID_BASE);
+
+unsigned int ltq_chip_version_get(void)
+{
+ u32 chipid;
+
+ chipid = ltq_readl(<q_chipid_regs->chipid);
+
+ return (chipid & LTQ_CHIPID_VERSION_MASK) >> LTQ_CHIPID_VERSION_SHIFT;
+}
+
+unsigned int ltq_chip_partnum_get(void)
+{
+ u32 chipid;
+
+ chipid = ltq_readl(<q_chipid_regs->chipid);
+
+ return (chipid & LTQ_CHIPID_PNUM_MASK) >> LTQ_CHIPID_PNUM_SHIFT;
+}
+
+const char *ltq_chip_partnum_str(void)
+{
+ enum ltq_chip_partnum partnum = ltq_chip_partnum_get();
+
+ switch (partnum) {
+ case LTQ_SOC_ARX188:
+ return "ARX188";
+ case LTQ_SOC_ARX186:
+ case LTQ_SOC_ARX186_2:
+ return "ARX186";
+ case LTQ_SOC_ARX182:
+ return "ARX182";
+ default:
+ printf("Unknown partnum: %x\n", partnum);
+ }
+
+ return "";
+}
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/config.mk
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2011-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+PF_CPPFLAGS_XRX := $(call cc-option,-mtune=34kc,)
+PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_XRX)
+
+ifdef CONFIG_SPL_BUILD
+PF_ABICALLS := -mno-abicalls
+PF_PIC := -fno-pic
+PF_PIE :=
+USE_PRIVATE_LIBGCC := yes
+endif
+
+LIBS-y += $(CPUDIR)/lantiq-common/liblantiq-common.o
+
+ifndef CONFIG_SPL_BUILD
+ifdef CONFIG_SYS_BOOT_SFSPL
+ALL-y += $(obj)u-boot.ltq.sfspl
+ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.sfspl
+ALL-$(CONFIG_SPL_LZMA_SUPPORT) += $(obj)u-boot.ltq.lzma.sfspl
+endif
+ifdef CONFIG_SYS_BOOT_NORSPL
+ALL-y += $(obj)u-boot.ltq.norspl
+ALL-$(CONFIG_SPL_LZO_SUPPORT) += $(obj)u-boot.ltq.lzo.norspl
+ALL-$(CONFIG_SPL_LZMA_SUPPORT) += $(obj)u-boot.ltq.lzma.norspl
+endif
+endif
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/ebu.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2011-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arch/soc.h>
+#include <asm/lantiq/io.h>
+
+#define EBU_ADDRSEL_MASK(mask) ((mask & 0xf) << 4)
+#define EBU_ADDRSEL_REGEN (1 << 0)
+
+#define EBU_CON_WRDIS (1 << 31)
+#define EBU_CON_AGEN_DEMUX (0x0 << 24)
+#define EBU_CON_AGEN_MUX (0x2 << 24)
+#define EBU_CON_SETUP (1 << 22)
+#define EBU_CON_WAIT_DIS (0x0 << 20)
+#define EBU_CON_WAIT_ASYNC (0x1 << 20)
+#define EBU_CON_WAIT_SYNC (0x2 << 20)
+#define EBU_CON_WINV (1 << 19)
+#define EBU_CON_PW_8BIT (0x0 << 16)
+#define EBU_CON_PW_16BIT (0x1 << 16)
+#define EBU_CON_ALEC(cycles) ((cycles & 0x3) << 14)
+#define EBU_CON_BCGEN_CS (0x0 << 12)
+#define EBU_CON_BCGEN_INTEL (0x1 << 12)
+#define EBU_CON_BCGEN_MOTOROLA (0x2 << 12)
+#define EBU_CON_WAITWRC(cycles) ((cycles & 0x7) << 8)
+#define EBU_CON_WAITRDC(cycles) ((cycles & 0x3) << 6)
+#define EBU_CON_HOLDC(cycles) ((cycles & 0x3) << 4)
+#define EBU_CON_RECOVC(cycles) ((cycles & 0x3) << 2)
+#define EBU_CON_CMULT_1 0x0
+#define EBU_CON_CMULT_4 0x1
+#define EBU_CON_CMULT_8 0x2
+#define EBU_CON_CMULT_16 0x3
+
+#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
+#define ebu_region0_enable 1
+#else
+#define ebu_region0_enable 0
+#endif
+
+#if defined(CONFIG_LTQ_SUPPORT_NAND_FLASH)
+#define ebu_region1_enable 1
+#else
+#define ebu_region1_enable 0
+#endif
+
+struct ltq_ebu_regs {
+ u32 clc;
+ u32 rsvd0;
+ u32 id;
+ u32 rsvd1;
+ u32 con;
+ u32 rsvd2[3];
+ u32 addr_sel_0;
+ u32 addr_sel_1;
+ u32 addr_sel_2;
+ u32 addr_sel_3;
+ u32 rsvd3[12];
+ u32 con_0;
+ u32 con_1;
+ u32 con_2;
+ u32 con_3;
+};
+
+static struct ltq_ebu_regs *ltq_ebu_regs =
+ (struct ltq_ebu_regs *) CKSEG1ADDR(LTQ_EBU_BASE);
+
+void ltq_ebu_init(void)
+{
+ if (ebu_region0_enable) {
+ /*
+ * Map EBU region 0 to range 0x10000000-0x13ffffff and enable
+ * region control. This supports up to 32 MiB NOR flash in
+ * bank 0.
+ */
+ ltq_writel(<q_ebu_regs->addr_sel_0, LTQ_EBU_REGION0_BASE |
+ EBU_ADDRSEL_MASK(1) | EBU_ADDRSEL_REGEN);
+
+ ltq_writel(<q_ebu_regs->con_0, EBU_CON_AGEN_DEMUX |
+ EBU_CON_WAIT_DIS | EBU_CON_PW_16BIT |
+ EBU_CON_ALEC(3) | EBU_CON_BCGEN_INTEL |
+ EBU_CON_WAITWRC(7) | EBU_CON_WAITRDC(3) |
+ EBU_CON_HOLDC(3) | EBU_CON_RECOVC(3) |
+ EBU_CON_CMULT_16);
+ } else
+ ltq_clrbits(<q_ebu_regs->addr_sel_0, EBU_ADDRSEL_REGEN);
+
+ if (ebu_region1_enable) {
+ /*
+ * Map EBU region 1 to range 0x14000000-0x13ffffff and enable
+ * region control. This supports NAND flash in bank 1.
+ */
+ ltq_writel(<q_ebu_regs->addr_sel_1, LTQ_EBU_REGION1_BASE |
+ EBU_ADDRSEL_MASK(3) | EBU_ADDRSEL_REGEN);
+
+ ltq_writel(<q_ebu_regs->con_1, EBU_CON_AGEN_DEMUX |
+ EBU_CON_SETUP | EBU_CON_WAIT_DIS | EBU_CON_PW_8BIT |
+ EBU_CON_ALEC(3) | EBU_CON_BCGEN_INTEL |
+ EBU_CON_WAITWRC(2) | EBU_CON_WAITRDC(2) |
+ EBU_CON_HOLDC(1) | EBU_CON_RECOVC(1) |
+ EBU_CON_CMULT_4);
+ } else
+ ltq_clrbits(<q_ebu_regs->addr_sel_1, EBU_ADDRSEL_REGEN);
+}
+
+void *flash_swap_addr(unsigned long addr)
+{
+ return (void *)(addr ^ 2);
+}
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/mem.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arch/soc.h>
+#include <asm/lantiq/io.h>
+
+static void *ltq_mc_ddr_base = (void *) CKSEG1ADDR(LTQ_MC_DDR_BASE);
+
+static inline u32 ltq_mc_dc_read(u32 index)
+{
+ return ltq_readl(ltq_mc_ddr_base + LTQ_MC_DDR_DC_OFFSET(index));
+}
+
+phys_size_t initdram(int board_type)
+{
+ u32 col, row, dc04, dc19, dc20;
+
+ dc04 = ltq_mc_dc_read(4);
+ dc19 = ltq_mc_dc_read(19);
+ dc20 = ltq_mc_dc_read(20);
+
+ row = (dc04 & 0xF) - ((dc19 & 0x700) >> 8);
+ col = ((dc04 & 0xF00) >> 8) - (dc20 & 0x7);
+
+ return (1 << (row + col)) * 4 * 2;
+}
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/mem_init.S
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
+ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <config.h>
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/addrspace.h>
+#include <asm/arch/soc.h>
+
+/* Must be configured in BOARDDIR */
+#include <ddr_settings.h>
+
+#define LTQ_MC_GEN_ERRCAUSE 0x0010
+#define LTQ_MC_GEN_ERRADDR 0x0020
+#define LTQ_MC_GEN_CON 0x0060
+#define LTQ_MC_GEN_STAT 0x0070
+#define LTQ_MC_GEN_CON_SRAM_DDR_ENABLE 0xD
+#define LTQ_MC_GEN_STAT_DLCK_PWRON 0xC
+
+#define LTQ_MC_DDR_DC03_MC_START 0x100
+
+ /* Store given value in MC DDR CCRx register */
+ .macro dc_sw num, val
+ li t2, \val
+ sw t2, LTQ_MC_DDR_DC_OFFSET(\num)(t1)
+ .endm
+
+LEAF(ltq_mem_init)
+ /* Load MC General and MC DDR module base */
+ li t0, (LTQ_MC_GEN_BASE | KSEG1)
+ li t1, (LTQ_MC_DDR_BASE | KSEG1)
+
+ /* Clear access error log registers */
+ sw zero, LTQ_MC_GEN_ERRCAUSE(t0)
+ sw zero, LTQ_MC_GEN_ERRADDR(t0)
+
+ /* Enable DDR and SRAM module in memory controller */
+ li t2, LTQ_MC_GEN_CON_SRAM_DDR_ENABLE
+ sw t2, LTQ_MC_GEN_CON(t0)
+
+ /* Clear start bit of DDR memory controller */
+ sw zero, LTQ_MC_DDR_DC_OFFSET(3)(t1)
+
+ /* Init memory controller registers with values ddr_settings.h */
+ dc_sw 0, MC_DC00_VALUE
+ dc_sw 1, MC_DC01_VALUE
+ dc_sw 2, MC_DC02_VALUE
+ dc_sw 4, MC_DC04_VALUE
+ dc_sw 5, MC_DC05_VALUE
+ dc_sw 6, MC_DC06_VALUE
+ dc_sw 7, MC_DC07_VALUE
+ dc_sw 8, MC_DC08_VALUE
+ dc_sw 9, MC_DC09_VALUE
+
+ dc_sw 10, MC_DC10_VALUE
+ dc_sw 11, MC_DC11_VALUE
+ dc_sw 12, MC_DC12_VALUE
+ dc_sw 13, MC_DC13_VALUE
+ dc_sw 14, MC_DC14_VALUE
+ dc_sw 15, MC_DC15_VALUE
+ dc_sw 16, MC_DC16_VALUE
+ dc_sw 17, MC_DC17_VALUE
+ dc_sw 18, MC_DC18_VALUE
+ dc_sw 19, MC_DC19_VALUE
+
+ dc_sw 20, MC_DC20_VALUE
+ dc_sw 21, MC_DC21_VALUE
+ dc_sw 22, MC_DC22_VALUE
+ dc_sw 23, MC_DC23_VALUE
+ dc_sw 24, MC_DC24_VALUE
+ dc_sw 25, MC_DC25_VALUE
+ dc_sw 26, MC_DC26_VALUE
+ dc_sw 27, MC_DC27_VALUE
+ dc_sw 28, MC_DC28_VALUE
+ dc_sw 29, MC_DC29_VALUE
+
+ dc_sw 30, MC_DC30_VALUE
+ dc_sw 31, MC_DC31_VALUE
+ dc_sw 32, MC_DC32_VALUE
+ dc_sw 33, MC_DC33_VALUE
+ dc_sw 34, MC_DC34_VALUE
+ dc_sw 35, MC_DC35_VALUE
+ dc_sw 36, MC_DC36_VALUE
+ dc_sw 37, MC_DC37_VALUE
+ dc_sw 38, MC_DC38_VALUE
+ dc_sw 39, MC_DC39_VALUE
+
+ dc_sw 40, MC_DC40_VALUE
+ dc_sw 41, MC_DC41_VALUE
+ dc_sw 42, MC_DC42_VALUE
+ dc_sw 43, MC_DC43_VALUE
+ dc_sw 44, MC_DC44_VALUE
+ dc_sw 45, MC_DC45_VALUE
+ dc_sw 46, MC_DC46_VALUE
+
+ /* Set start bit of DDR memory controller */
+ li t2, LTQ_MC_DDR_DC03_MC_START
+ sw t2, LTQ_MC_DDR_DC_OFFSET(3)(t1)
+
+ /* Wait until DLL has locked and core is ready for data transfers */
+wait_ready:
+ lw t2, LTQ_MC_GEN_STAT(t0)
+ li t3, LTQ_MC_GEN_STAT_DLCK_PWRON
+ and t2, t3
+ bne t2, t3, wait_ready
+
+finished:
+ jr ra
+
+ END(ltq_mem_init)
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/pmu.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/lantiq/io.h>
+#include <asm/lantiq/pm.h>
+#include <asm/arch/soc.h>
+
+#define LTQ_PMU_PWDCR_RESERVED 0xE00C200C
+
+#define LTQ_PMU_PWDCR_SWITCH (1 << 28)
+#define LTQ_PMU_PWDCR_USB1 (1 << 27)
+#define LTQ_PMU_PWDCR_USB1_PHY (1 << 26)
+#define LTQ_PMU_PWDCR_TDM (1 << 25)
+#define LTQ_PMU_PWDCR_DDR_MEM (1 << 24)
+#define LTQ_PMU_PWDCR_PPE_DP (1 << 23)
+#define LTQ_PMU_PWDCR_PPE_EMA (1 << 22)
+#define LTQ_PMU_PWDCR_PPE_TC (1 << 21)
+#define LTQ_PMU_PWDCR_DEU (1 << 20)
+#define LTQ_PMU_PWDCR_UART1 (1 << 17)
+#define LTQ_PMU_PWDCR_SDIO (1 << 16)
+#define LTQ_PMU_PWDCR_AHB (1 << 15)
+#define LTQ_PMU_PWDCR_FPI0 (1 << 14)
+#define LTQ_PMU_PWDCR_GPTC (1 << 12)
+#define LTQ_PMU_PWDCR_LEDC (1 << 11)
+#define LTQ_PMU_PWDCR_EBU (1 << 10)
+#define LTQ_PMU_PWDCR_DSL (1 << 9)
+#define LTQ_PMU_PWDCR_SPI (1 << 8)
+#define LTQ_PMU_PWDCR_UART0 (1 << 7)
+#define LTQ_PMU_PWDCR_USB (1 << 6)
+#define LTQ_PMU_PWDCR_DMA (1 << 5)
+#define LTQ_PMU_PWDCR_PCI (1 << 4)
+#define LTQ_PMU_PWDCR_FPI1 (1 << 1)
+#define LTQ_PMU_PWDCR_USB0_PHY (1 << 0)
+
+struct ltq_pmu_regs {
+ u32 rsvd0[7];
+ __be32 pwdcr;
+ __be32 sr;
+};
+
+static struct ltq_pmu_regs *ltq_pmu_regs =
+ (struct ltq_pmu_regs *) CKSEG1ADDR(LTQ_PMU_BASE);
+
+u32 ltq_pm_map(enum ltq_pm_modules module)
+{
+ u32 val;
+
+ switch (module) {
+ case LTQ_PM_CORE:
+ val = LTQ_PMU_PWDCR_DDR_MEM | LTQ_PMU_PWDCR_UART1 |
+ LTQ_PMU_PWDCR_FPI0 | LTQ_PMU_PWDCR_LEDC |
+ LTQ_PMU_PWDCR_EBU;
+ break;
+ case LTQ_PM_DMA:
+ val = LTQ_PMU_PWDCR_DMA;
+ break;
+ case LTQ_PM_ETH:
+ val = LTQ_PMU_PWDCR_SWITCH | LTQ_PMU_PWDCR_PPE_DP |
+ LTQ_PMU_PWDCR_PPE_EMA | LTQ_PMU_PWDCR_PPE_TC;
+ break;
+ case LTQ_PM_SPI:
+ val = LTQ_PMU_PWDCR_SPI;
+ break;
+ default:
+ val = 0;
+ break;
+ }
+
+ return val;
+}
+
+int ltq_pm_enable(enum ltq_pm_modules module)
+{
+ const unsigned long timeout = 1000;
+ unsigned long timebase;
+ u32 sr, val;
+
+ val = ltq_pm_map(module);
+ if (unlikely(!val))
+ return 1;
+
+ ltq_clrbits(<q_pmu_regs->pwdcr, val);
+
+ timebase = get_timer(0);
+
+ do {
+ sr = ltq_readl(<q_pmu_regs->sr);
+ if (~sr & val)
+ return 0;
+ } while (get_timer(timebase) < timeout);
+
+ return 1;
+}
+
+int ltq_pm_disable(enum ltq_pm_modules module)
+{
+ u32 val;
+
+ val = ltq_pm_map(module);
+ if (unlikely(!val))
+ return 1;
+
+ ltq_setbits(<q_pmu_regs->pwdcr, val);
+
+ return 0;
+}
+
+void ltq_pmu_init(void)
+{
+ u32 set, clr;
+
+ clr = ltq_pm_map(LTQ_PM_CORE);
+ set = ~(LTQ_PMU_PWDCR_RESERVED | clr);
+
+ ltq_clrsetbits(<q_pmu_regs->pwdcr, clr, set);
+}
--- /dev/null
+++ b/arch/mips/cpu/mips32/arx100/rcu.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/lantiq/io.h>
+#include <asm/lantiq/reset.h>
+#include <asm/lantiq/cpu.h>
+#include <asm/arch/soc.h>
+
+#define LTQ_RCU_RD_SRST (1 << 30) /* Global SW Reset */
+#define LTQ_RCU_RD_USB1 (1 << 28) /* USB1 MAC and PHY */
+#define LTQ_RCU_RD_REG25_PD (1 << 26) /* Power down 2.5V regulator */
+#define LTQ_RCU_RD_PPE_ATM_TC (1 << 22) /* PPE ATM TC */
+#define LTQ_RCU_RD_ETHSW (1 << 21) /* Ethernet switch */
+#define LTQ_RCU_RD_DSP_DEN (1 << 20) /* Enable DSP JTAG */
+#define LTQ_RCU_RD_TDM (1 << 19) /* TDM module interface */
+#define LTQ_RCU_RD_MC (1 << 14) /* Memory Controller */
+#define LTQ_RCU_RD_PCI (1 << 13) /* PCI core */
+#define LTQ_RCU_RD_SDIO (1 << 10) /* SDIO core */
+#define LTQ_RCU_RD_DMA (1 << 9) /* DMA core */
+#define LTQ_RCU_RD_PPE (1 << 8) /* PPE core */
+#define LTQ_RCU_RD_ARC_DFE (1 << 7) /* ARC/DFE core */
+#define LTQ_RCU_RD_AHB (1 << 6) /* AHB bus */
+#define LTQ_RCU_RD_USB (1 << 4) /* USB and Phy core */
+#define LTQ_RCU_RD_FPI (1 << 2) /* FPI bus */
+#define LTQ_RCU_RD_CPU0 (1 << 1) /* CPU0 subsystem */
+#define LTQ_RCU_RD_HRST (1 << 0) /* HW reset via HRST pin */
+
+#define LTQ_RCU_STAT_BOOT_SHIFT 17
+#define LTQ_RCU_STAT_BOOT_MASK (0xf << LTQ_RCU_STAT_BOOT_SHIFT)
+
+struct ltq_rcu_regs {
+ u32 rsvd0[4];
+ __be32 req; /* Reset request */
+ __be32 stat; /* Reset status */
+ __be32 usb0_cfg; /* USB0 config */
+ u32 rsvd1[2];
+ __be32 pci_rdy; /* PCI boot ready */
+ __be32 ppe_conf; /* PPE config */
+ u32 rsvd2;
+ __be32 usb1_cfg; /* USB1 config */
+};
+
+static struct ltq_rcu_regs *ltq_rcu_regs =
+ (struct ltq_rcu_regs *) CKSEG1ADDR(LTQ_RCU_BASE);
+
+u32 ltq_reset_map(enum ltq_reset_modules module)
+{
+ u32 val;
+
+ switch (module) {
+ case LTQ_RESET_CORE:
+ case LTQ_RESET_SOFT:
+ val = LTQ_RCU_RD_SRST | LTQ_RCU_RD_CPU0;
+ break;
+ case LTQ_RESET_DMA:
+ val = LTQ_RCU_RD_DMA;
+ break;
+ case LTQ_RESET_ETH:
+ val = LTQ_RCU_RD_PPE | LTQ_RCU_RD_ETHSW;
+ break;
+ case LTQ_RESET_HARD:
+ val = LTQ_RCU_RD_HRST;
+ break;
+ default:
+ val = 0;
+ break;
+ }
+
+ return val;
+}
+
+int ltq_reset_activate(enum ltq_reset_modules module)
+{
+ u32 val;
+
+ val = ltq_reset_map(module);
+ if (unlikely(!val))
+ return 1;
+
+ ltq_setbits(<q_rcu_regs->req, val);
+
+ return 0;
+}
+
+int ltq_reset_deactivate(enum ltq_reset_modules module)
+{
+ u32 val;
+
+ val = ltq_reset_map(module);
+ if (unlikely(!val))
+ return 1;
+
+ ltq_clrbits(<q_rcu_regs->req, val);
+
+ return 0;
+}
+
+enum ltq_boot_select ltq_boot_select(void)
+{
+ u32 stat;
+ unsigned int bootstrap;
+
+ stat = ltq_readl(<q_rcu_regs->stat);
+ bootstrap = (stat & LTQ_RCU_STAT_BOOT_MASK) >> LTQ_RCU_STAT_BOOT_SHIFT;
+
+ switch (bootstrap) {
+ case 0:
+ return BOOT_NOR_NO_BOOTROM;
+ case 1:
+ return BOOT_RGMII0;
+ case 2:
+ return BOOT_NOR;
+ case 3:
+ return BOOT_MII0;
+ case 5:
+ return BOOT_RMII0;
+ case 6:
+ return BOOT_PCI;
+ case 8:
+ return BOOT_UART;
+ case 10:
+ return BOOT_SPI;
+ default:
+ return BOOT_UNKNOWN;
+ }
+}
--- a/arch/mips/cpu/mips32/lantiq-common/cpu.c
+++ b/arch/mips/cpu/mips32/lantiq-common/cpu.c
@@ -20,6 +20,7 @@ static const char ltq_bootsel_strings[][
"PCI",
"MII0",
"RMII0",
+ "RGMII0",
"RGMII1",
"unknown",
};
--- a/arch/mips/cpu/mips32/lantiq-common/start.S
+++ b/arch/mips/cpu/mips32/lantiq-common/start.S
@@ -64,6 +64,11 @@
#define STATUS_LANTIQ (STATUS_MIPS24K | STATUS_MIPS32_64)
#endif
+#ifdef CONFIG_SOC_XWAY_ARX100
+#define CONFIG0_LANTIQ (CONFIG0_MIPS34K | CONFIG0_MIPS32_64)
+#define STATUS_LANTIQ (STATUS_MIPS34K | STATUS_MIPS32_64)
+#endif
+
#ifdef CONFIG_SOC_XWAY_VRX200
#define CONFIG0_LANTIQ (CONFIG0_MIPS34K | CONFIG0_MIPS32_64)
#define STATUS_LANTIQ (STATUS_MIPS34K | STATUS_MIPS32_64)
--- /dev/null
+++ b/arch/mips/include/asm/arch-arx100/config.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
+ * Copyright (C) 2011-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ * Common board configuration for Lantiq XWAY ARX100 family
+ *
+ * Use following defines in your board config to enable specific features
+ * and drivers for this SoC:
+ *
+ * CONFIG_LTQ_SUPPORT_UART
+ * - support the Danube ASC/UART interface and console
+ *
+ * CONFIG_LTQ_SUPPORT_NOR_FLASH
+ * - support a parallel NOR flash via the CFI interface in flash bank 0
+ *
+ * CONFIG_LTQ_SUPPORT_ETHERNET
+ * - support the Danube ETOP and MAC interface
+ *
+ * CONFIG_LTQ_SUPPORT_SPI_FLASH
+ * - support the Danube SPI interface and serial flash drivers
+ * - specific SPI flash drivers must be configured separately
+ */
+
+#ifndef __ARX100_CONFIG_H__
+#define __ARX100_CONFIG_H__
+
+/* CPU and SoC type */
+#define CONFIG_SOC_LANTIQ
+#define CONFIG_SOC_XWAY_ARX100
+
+/* Cache configuration */
+#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
+#define CONFIG_SYS_DCACHE_SIZE (16 * 1024)
+#define CONFIG_SYS_ICACHE_SIZE (32 * 1024)
+#define CONFIG_SYS_CACHELINE_SIZE 32
+#define CONFIG_SYS_MIPS_CACHE_EXT_INIT
+
+/*
+ * Supported clock modes
+ * PLL0: rational PLL running at 500 MHz
+ * PLL1: fractional PLL running at 393.219 MHz
+ */
+#define LTQ_CLK_CPU_393_DDR_197 0
+#define LTQ_CLK_CPU_197_DDR_197 1
+#define LTQ_CLK_CPU_333_DDR_167 2
+#define LTQ_CLK_CPU_167_DDR_167 3
+#define LTQ_CLK_CPU_131_DDR_131 4
+#define LTQ_CLK_CPU_111_DDR_111 5
+
+/* CPU speed */
+#define CONFIG_SYS_CLOCK_MODE LTQ_CLK_CPU_333_DDR_167
+#define CONFIG_SYS_MIPS_TIMER_FREQ 166666667
+#define CONFIG_SYS_HZ 1000
+
+/* RAM */
+#define CONFIG_NR_DRAM_BANKS 1
+#define CONFIG_SYS_SDRAM_BASE 0x80000000
+#define CONFIG_SYS_SDRAM_BASE_UC 0xa0000000
+#define CONFIG_SYS_MEMTEST_START 0x81000000
+#define CONFIG_SYS_MEMTEST_END 0x82000000
+#define CONFIG_SYS_LOAD_ADDR 0x81000000
+#define CONFIG_SYS_INIT_SP_OFFSET (32 * 1024)
+
+/* SRAM */
+#define CONFIG_SYS_SRAM_BASE 0xBE1A0000
+#define CONFIG_SYS_SRAM_SIZE 0x10000
+
+/* ASC/UART driver and console */
+#define CONFIG_LANTIQ_SERIAL
+#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
+
+/* GPIO */
+#define CONFIG_LANTIQ_GPIO
+#define CONFIG_LTQ_GPIO_MAX_BANKS 3
+#define CONFIG_LTQ_HAS_GPIO_BANK3
+
+/* FLASH driver */
+#if defined(CONFIG_LTQ_SUPPORT_NOR_FLASH)
+#define CONFIG_SYS_MAX_FLASH_BANKS 1
+#define CONFIG_SYS_MAX_FLASH_SECT 256
+#define CONFIG_SYS_FLASH_BASE 0xB0000000
+#define CONFIG_FLASH_16BIT
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
+#define CONFIG_SYS_FLASH_USE_BUFFER_WRITE
+#define CONFIG_FLASH_SHOW_PROGRESS 50
+#define CONFIG_SYS_FLASH_PROTECTION
+#define CONFIG_CFI_FLASH_USE_WEAK_ADDR_SWAP
+
+#define CONFIG_CMD_FLASH
+#else
+#define CONFIG_SYS_NO_FLASH
+#endif /* CONFIG_NOR_FLASH */
+
+#if defined(CONFIG_LTQ_SUPPORT_SPI_FLASH)
+#define CONFIG_LANTIQ_SPI
+#define CONFIG_SPI_FLASH
+
+#define CONFIG_CMD_SF
+#define CONFIG_CMD_SPI
+#endif
+
+#if defined(CONFIG_LTQ_SUPPORT_NAND_FLASH)
+#define CONFIG_NAND_LANTIQ
+#define CONFIG_SYS_MAX_NAND_DEVICE 1
+#define CONFIG_SYS_NAND_BASE 0xB4000000
+
+#define CONFIG_CMD_NAND
+#endif
+
+#if defined(CONFIG_LTQ_SUPPORT_ETHERNET)
+#define CONFIG_LANTIQ_DMA
+#define CONFIG_LANTIQ_ARX100_SWITCH
+
+#define CONFIG_PHYLIB
+#define CONFIG_MII
+#define CONFIG_UDP_CHECKSUM
+
+#define CONFIG_CMD_MII
+#define CONFIG_CMD_NET
+#endif
+
+#define CONFIG_SPL_MAX_SIZE (32 * 1024)
+#define CONFIG_SPL_BSS_MAX_SIZE (8 * 1024)
+#define CONFIG_SPL_STACK_MAX_SIZE (8 * 1024)
+#define CONFIG_SPL_MALLOC_MAX_SIZE (32 * 1024)
+#define CONFIG_SPL_STACK_BSS_IN_SRAM
+
+#if defined(CONFIG_SPL_STACK_BSS_IN_SRAM)
+#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SRAM_BASE + \
+ CONFIG_SPL_MAX_SIZE + \
+ CONFIG_SPL_STACK_MAX_SIZE - 1)
+#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
+#define CONFIG_SPL_MALLOC_BASE (CONFIG_SYS_SDRAM_BASE + \
+ CONFIG_SYS_INIT_SP_OFFSET)
+#else
+#define CONFIG_SPL_STACK_BASE (CONFIG_SYS_SDRAM_BASE + \
+ CONFIG_SYS_INIT_SP_OFFSET + \
+ CONFIG_SPL_STACK_MAX_SIZE - 1)
+#define CONFIG_SPL_BSS_BASE (CONFIG_SPL_STACK_BASE + 1)
+#define CONFIG_SPL_MALLOC_BASE (CONFIG_SPL_BSS_BASE + \
+ CONFIG_SPL_BSS_MAX_SIZE)
+#endif
+
+#if defined(CONFIG_SYS_BOOT_RAM)
+#define CONFIG_SYS_TEXT_BASE 0xA0100000
+#define CONFIG_SKIP_LOWLEVEL_INIT
+#define CONFIG_SYS_DISABLE_CACHE
+#endif
+
+#if defined(CONFIG_SYS_BOOT_NOR)
+#define CONFIG_SYS_TEXT_BASE 0xB0000000
+#endif
+
+#if defined(CONFIG_SYS_BOOT_SFSPL) || defined(CONFIG_SYS_BOOT_NANDSPL)
+#define CONFIG_SYS_TEXT_BASE 0x80100000
+#define CONFIG_SPL_TEXT_BASE 0xBE1A0000
+#endif
+
+#if defined(CONFIG_SYS_BOOT_NORSPL)
+#define CONFIG_SYS_TEXT_BASE 0x80100000
+#define CONFIG_SPL_TEXT_BASE 0xB0000000
+#endif
+
+#if defined(CONFIG_SYS_BOOT_NOR) || defined(CONFIG_SYS_BOOT_NORSPL)
+#define CONFIG_SYS_XWAY_EBU_BOOTCFG 0x688C688C
+#define CONFIG_XWAY_SWAP_BYTES
+#endif
+
+#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE
+
+#endif /* __ARX100_CONFIG_H__ */
--- /dev/null
+++ b/arch/mips/include/asm/arch-arx100/gpio.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __ARX100_GPIO_H__
+#define __ARX100_GPIO_H__
+
+#include <asm/lantiq/gpio.h>
+
+#endif /* __ARX100_GPIO_H__ */
--- /dev/null
+++ b/arch/mips/include/asm/arch-arx100/nand.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012-2013 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __VRX200_NAND_H__
+#define __VRX200_NAND_H__
+
+struct nand_chip;
+int ltq_nand_init(struct nand_chip *nand);
+
+#endif /* __VRX200_NAND_H__ */
--- /dev/null
+++ b/arch/mips/include/asm/arch-arx100/soc.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2007-2010 Lantiq Deutschland GmbH
+ * Copyright (C) 2012 Daniel Schwierzeck, daniel.schwierzeck@gmail.com
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __ARX100_SOC_H__
+#define __ARX100_SOC_H__
+
+#define LTQ_ASC0_BASE 0x1E100400
+#define LTQ_SPI_BASE 0x1E100800
+#define LTQ_GPIO_BASE 0x1E100B00
+#define LTQ_SSIO_BASE 0x1E100BB0
+#define LTQ_ASC1_BASE 0x1E100C00
+#define LTQ_DMA_BASE 0x1E104100
+
+#define LTQ_EBU_BASE 0x1E105300
+#define LTQ_EBU_REGION0_BASE 0x10000000
+#define LTQ_EBU_REGION1_BASE 0x14000000
+#define LTQ_EBU_NAND_BASE (LTQ_EBU_BASE + 0xB0)
+
+#define LTQ_PPE_BASE 0x1E180000
+#define LTQ_SWITCH_BASE 0x1E108000
+
+#define LTQ_PMU_BASE 0x1F102000
+#define LTQ_CGU_BASE 0x1F103000
+#define LTQ_MPS_BASE 0x1F107000
+#define LTQ_CHIPID_BASE (LTQ_MPS_BASE + 0x340)
+#define LTQ_RCU_BASE 0x1F203000
+
+#define LTQ_MC_GEN_BASE 0x1F800000
+#define LTQ_MC_SDR_BASE 0x1F800200
+#define LTQ_MC_DDR_BASE 0x1F801000
+#define LTQ_MC_DDR_DC_OFFSET(x) (x * 0x10)
+
+#endif /* __ARX100_SOC_H__ */
--- a/arch/mips/include/asm/lantiq/chipid.h
+++ b/arch/mips/include/asm/lantiq/chipid.h
@@ -15,6 +15,10 @@ enum ltq_chip_partnum {
LTQ_SOC_DANUBE = 0x0129,
LTQ_SOC_DANUBE_S = 0x012B,
LTQ_SOC_TWINPASS = 0x012D,
+ LTQ_SOC_ARX188 = 0x016C, /* ARX188 */
+ LTQ_SOC_ARX186 = 0x016D, /* ARX186 v1.1 */
+ LTQ_SOC_ARX186_2 = 0x016E, /* ARX186 v1.2 */
+ LTQ_SOC_ARX182 = 0x016F, /* ARX182 */
LTQ_SOC_VRX288 = 0x01C0, /* VRX288 v1.1 */
LTQ_SOC_VRX268 = 0x01C2, /* VRX268 v1.1 */
LTQ_SOC_GRX288 = 0x01C9, /* GRX288 v1.1 */
@@ -36,6 +40,38 @@ static inline int ltq_soc_is_danube(void
{
return 0;
}
+#endif
+
+#ifdef CONFIG_SOC_XWAY_ARX100
+static inline int ltq_soc_is_arx100(void)
+{
+ return 1;
+}
+
+static inline int ltq_soc_is_arx100_v1(void)
+{
+ return ltq_chip_version_get() == 1;
+}
+
+static inline int ltq_soc_is_arx100_v2(void)
+{
+ return ltq_chip_version_get() == 2;
+}
+#else
+static inline int ltq_soc_is_arx100(void)
+{
+ return 0;
+}
+
+static inline int ltq_soc_is_arx100_v1(void)
+{
+ return 0;
+}
+
+static inline int ltq_soc_is_arx100_v2(void)
+{
+ return 0;
+}
#endif
#ifdef CONFIG_SOC_XWAY_VRX200
--- a/arch/mips/include/asm/lantiq/clk.h
+++ b/arch/mips/include/asm/lantiq/clk.h
@@ -13,9 +13,10 @@ enum ltq_clk {
CLOCK_83_MHZ = 83333333,
CLOCK_111_MHZ = 111111111,
CLOCK_125_MHZ = 125000000,
+ CLOCK_131_MHZ = 131073000,
CLOCK_133_MHZ = 133333333,
CLOCK_166_MHZ = 166666667,
- CLOCK_197_MHZ = 197000000,
+ CLOCK_197_MHZ = 196609500,
CLOCK_333_MHZ = 333333333,
CLOCK_393_MHZ = 393219000,
CLOCK_500_MHZ = 500000000,
--- a/arch/mips/include/asm/lantiq/cpu.h
+++ b/arch/mips/include/asm/lantiq/cpu.h
@@ -17,6 +17,7 @@ enum ltq_boot_select {
BOOT_PCI,
BOOT_MII0,
BOOT_RMII0,
+ BOOT_RGMII0,
BOOT_RGMII1,
BOOT_UNKNOWN,
};
|