0015-MIPS-lantiq-add-support-for-Lantiq-XWAY-ARX100-SoC-f.patch 31 KB

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