[lantiq]
[openwrt.git] / target / linux / lantiq / patches-3.0 / 0023-MIPS-lantiq-adds-basic-vr9-support.patch
1 From 780a64cd52209fad15c7133f950b2b2d6b9b59e2 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sat, 27 Aug 2011 21:44:32 +0200
4 Subject: [PATCH 23/24] MIPS: lantiq: adds basic vr9 support
5
6 ---
7  .../mips/include/asm/mach-lantiq/xway/lantiq_soc.h |    2 +
8  arch/mips/lantiq/Kconfig                           |    9 ++
9  arch/mips/lantiq/Platform                          |    1 +
10  arch/mips/lantiq/machtypes.h                       |    3 +
11  arch/mips/lantiq/xway/Kconfig                      |   12 +++
12  arch/mips/lantiq/xway/Makefile                     |    2 +
13  arch/mips/lantiq/xway/clk-vr9.c                    |   78 ++++++++++++++++++++
14  arch/mips/lantiq/xway/mach-fritz.c                 |   74 +++++++++++++++++++
15  arch/mips/lantiq/xway/prom-vr9.c                   |   55 ++++++++++++++
16  arch/mips/pci/Makefile                             |    2 +-
17  10 files changed, 237 insertions(+), 1 deletions(-)
18  create mode 100644 arch/mips/lantiq/xway/clk-vr9.c
19  create mode 100644 arch/mips/lantiq/xway/mach-fritz.c
20  create mode 100644 arch/mips/lantiq/xway/prom-vr9.c
21
22 Index: linux-3.0.3/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h
23 ===================================================================
24 --- linux-3.0.3.orig/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h        2011-10-04 20:05:48.000000000 +0200
25 +++ linux-3.0.3/arch/mips/include/asm/mach-lantiq/xway/lantiq_soc.h     2011-10-04 20:05:54.234312800 +0200
26 @@ -21,6 +21,7 @@
27  #define SOC_ID_ARX188          0x16C
28  #define SOC_ID_ARX168          0x16D
29  #define SOC_ID_ARX182          0x16F
30 +#define SOC_ID_VRX288          0x1C0
31  
32  /* SoC Types */
33  #define SOC_TYPE_DANUBE                0x01
34 @@ -91,6 +92,7 @@
35  
36  /* ETOP - ethernet */
37  #define LTQ_ETOP_BASE_ADDR     0x1E180000
38 +#define LTQ_ETOP_BASE_ADDR_VR9 0x1E200000
39  #define LTQ_ETOP_SIZE          0x40000
40  
41  /* GBIT - gigabit switch */
42 Index: linux-3.0.3/arch/mips/lantiq/Kconfig
43 ===================================================================
44 --- linux-3.0.3.orig/arch/mips/lantiq/Kconfig   2011-10-04 20:03:54.000000000 +0200
45 +++ linux-3.0.3/arch/mips/lantiq/Kconfig        2011-10-04 20:05:54.238312800 +0200
46 @@ -1,5 +1,8 @@
47  if LANTIQ
48  
49 +config LANTIQ_PCIE
50 +       bool
51 +
52  config SOC_TYPE_XWAY
53         bool
54         default n
55 @@ -17,6 +20,12 @@
56         select SOC_TYPE_XWAY
57         select HW_HAS_PCI
58  
59 +config SOC_VR9
60 +       bool "VR9"
61 +       select SOC_TYPE_XWAY
62 +       select HW_HAS_PCI
63 +       select LANTIQ_PCIE
64 +
65  config SOC_FALCON
66         bool "FALCON"
67  endchoice
68 Index: linux-3.0.3/arch/mips/lantiq/Platform
69 ===================================================================
70 --- linux-3.0.3.orig/arch/mips/lantiq/Platform  2011-10-04 20:03:54.000000000 +0200
71 +++ linux-3.0.3/arch/mips/lantiq/Platform       2011-10-04 20:05:54.238312800 +0200
72 @@ -6,4 +6,5 @@
73  cflags-$(CONFIG_LANTIQ)                += -I$(srctree)/arch/mips/include/asm/mach-lantiq
74  load-$(CONFIG_LANTIQ)          = 0xffffffff80002000
75  cflags-$(CONFIG_SOC_TYPE_XWAY) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/xway
76 +cflags-$(CONFIG_SOC_TYPE_VR9)  += -I$(srctree)/arch/mips/include/asm/mach-lantiq/xway
77  cflags-$(CONFIG_SOC_FALCON)    += -I$(srctree)/arch/mips/include/asm/mach-lantiq/falcon
78 Index: linux-3.0.3/arch/mips/lantiq/machtypes.h
79 ===================================================================
80 --- linux-3.0.3.orig/arch/mips/lantiq/machtypes.h       2011-10-04 20:03:54.000000000 +0200
81 +++ linux-3.0.3/arch/mips/lantiq/machtypes.h    2011-10-04 20:05:54.238312800 +0200
82 @@ -20,6 +20,9 @@
83         LANTIQ_MACH_EASY98000,          /* Falcon Eval Board, NOR Flash */
84         LANTIQ_MACH_EASY98000SF,        /* Falcon Eval Board, Serial Flash */
85         LANTIQ_MACH_EASY98000NAND,      /* Falcon Eval Board, NAND Flash */
86 +
87 +       /* FRITZ!BOX */
88 +       LANTIQ_MACH_FRITZ3370,          /* FRITZ!BOX 3370 vdsl cpe */
89  };
90  
91  #endif
92 Index: linux-3.0.3/arch/mips/lantiq/xway/Kconfig
93 ===================================================================
94 --- linux-3.0.3.orig/arch/mips/lantiq/xway/Kconfig      2011-08-17 19:57:16.000000000 +0200
95 +++ linux-3.0.3/arch/mips/lantiq/xway/Kconfig   2011-10-04 20:05:54.238312800 +0200
96 @@ -21,3 +21,15 @@
97  endmenu
98  
99  endif
100 +
101 +if SOC_VR9
102 +
103 +menu "MIPS Machine"
104 +
105 +config LANTIQ_MACH_FRITZ3370
106 +       bool "Fritz!Box 3370"
107 +       default y
108 +
109 +endmenu
110 +
111 +endif
112 Index: linux-3.0.3/arch/mips/lantiq/xway/Makefile
113 ===================================================================
114 --- linux-3.0.3.orig/arch/mips/lantiq/xway/Makefile     2011-10-04 20:05:50.000000000 +0200
115 +++ linux-3.0.3/arch/mips/lantiq/xway/Makefile  2011-10-04 20:05:54.238312800 +0200
116 @@ -2,6 +2,8 @@
117  
118  obj-$(CONFIG_SOC_XWAY) += clk-xway.o prom-xway.o
119  obj-$(CONFIG_SOC_AMAZON_SE) += clk-ase.o prom-ase.o
120 +obj-$(CONFIG_SOC_VR9) += clk-vr9.o prom-vr9.o
121  
122  obj-$(CONFIG_LANTIQ_MACH_EASY50712) += mach-easy50712.o
123  obj-$(CONFIG_LANTIQ_MACH_EASY50601) += mach-easy50601.o
124 +obj-$(CONFIG_LANTIQ_MACH_FRITZ3370) += mach-fritz.o
125 Index: linux-3.0.3/arch/mips/lantiq/xway/clk-vr9.c
126 ===================================================================
127 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
128 +++ linux-3.0.3/arch/mips/lantiq/xway/clk-vr9.c 2011-10-04 20:05:54.238312800 +0200
129 @@ -0,0 +1,78 @@
130 +/*
131 + *  This program is free software; you can redistribute it and/or modify it
132 + *  under the terms of the GNU General Public License version 2 as published
133 + *  by the Free Software Foundation.
134 + *
135 + *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
136 + */
137 +
138 +#include <linux/io.h>
139 +#include <linux/module.h>
140 +#include <linux/init.h>
141 +#include <linux/clk.h>
142 +
143 +#include <asm/time.h>
144 +#include <asm/irq.h>
145 +#include <asm/div64.h>
146 +
147 +#include <lantiq_soc.h>
148 +
149 +#define CLOCK_62_5M                         62500000
150 +#define CLOCK_83_5M                         83500000
151 +#define CLOCK_125M                          125000000
152 +#define CLOCK_200M                          200000000
153 +#define CLOCK_250M                          250000000
154 +#define CLOCK_300M                          300000000
155 +#define CLOCK_98_304M                       98304000
156 +#define CLOCK_150M                          150000000
157 +#define CLOCK_196_608M                      196608000
158 +#define CLOCK_600M                          600000000
159 +#define CLOCK_500M                          500000000
160 +#define CLOCK_393M                          393215332
161 +#define CLOCK_166M                          166666666
162 +
163 +#define LTQ_CGU_SYS    0x0c
164 +#define LTQ_CGU_IF_CLK 0x24
165 +
166 +unsigned int ltq_get_cpu_hz(void)
167 +{
168 +       int clks[] = {
169 +               CLOCK_600M, CLOCK_500M, CLOCK_393M, CLOCK_333M, CLOCK_125M,
170 +               CLOCK_125M, CLOCK_196_608M, CLOCK_166M, CLOCK_125M, CLOCK_125M };
171 +       int val = (ltq_cgu_r32(LTQ_CGU_SYS) >> 4) & 0xf;
172 +
173 +       if (val > 9)
174 +               panic("bad cpu speed\n");
175 +       if (val == 2)
176 +               panic("missing workaround\n");
177 +               //cgu_get_pll1_fosc(); //CLOCK_393M;
178 +       return clks[val];
179 +}
180 +EXPORT_SYMBOL(ltq_get_cpu_hz);
181 +
182 +unsigned int ltq_get_fpi_hz(void)
183 +{
184 +       int clks[] = {
185 +               CLOCK_62_5M, CLOCK_62_5M, CLOCK_83_5M, CLOCK_125M, CLOCK_125M,
186 +               CLOCK_125M, CLOCK_167M, CLOCK_200M, CLOCK_250M, CLOCK_300M,
187 +               CLOCK_62_5M, CLOCK_98_304M, CLOCK_150M, CLOCK_196_608M };
188 +       int val = ((ltq_cgu_r32(LTQ_CGU_IF_CLK) >> 25) & 0xf);
189 +
190 +       if (val > 13)
191 +               panic("bad fpi speed\n");
192 +
193 +       return clks[val];
194 +}
195 +EXPORT_SYMBOL(ltq_get_fpi_hz);
196 +
197 +unsigned int ltq_get_io_region_clock(void)
198 +{
199 +       return ltq_get_fpi_hz() / 2;
200 +}
201 +EXPORT_SYMBOL(ltq_get_io_region_clock);
202 +
203 +unsigned int ltq_get_fpi_bus_clock(int fpi)
204 +{
205 +       return ltq_get_fpi_hz();
206 +}
207 +EXPORT_SYMBOL(ltq_get_fpi_bus_clock);
208 Index: linux-3.0.3/arch/mips/lantiq/xway/prom-vr9.c
209 ===================================================================
210 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
211 +++ linux-3.0.3/arch/mips/lantiq/xway/prom-vr9.c        2011-10-04 20:05:54.238312800 +0200
212 @@ -0,0 +1,55 @@
213 +/*
214 + *  This program is free software; you can redistribute it and/or modify it
215 + *  under the terms of the GNU General Public License version 2 as published
216 + *  by the Free Software Foundation.
217 + *
218 + *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
219 + */
220 +
221 +#include <linux/module.h>
222 +#include <linux/clk.h>
223 +#include <asm/bootinfo.h>
224 +#include <asm/time.h>
225 +
226 +#include <lantiq_soc.h>
227 +
228 +#include "devices.h"
229 +#include "../prom.h"
230 +
231 +#define SOC_VRX288     "VRX288"
232 +
233 +#define PART_SHIFT     12
234 +#define PART_MASK      0x0FFFFFFF
235 +#define REV_SHIFT      28
236 +#define REV_MASK       0xF0000000
237 +
238 +void __init ltq_soc_detect(struct ltq_soc_info *i)
239 +{
240 +       i->partnum = (ltq_r32(LTQ_MPS_CHIPID) & PART_MASK) >> PART_SHIFT;
241 +       i->rev = (ltq_r32(LTQ_MPS_CHIPID) & REV_MASK) >> REV_SHIFT;
242 +       sprintf(i->rev_type, "1.%d", i->rev);
243 +       switch (i->partnum) {
244 +       case SOC_ID_VRX288:
245 +               i->name = SOC_VRX288;
246 +               i->type = SOC_TYPE_VR9;
247 +               break;
248 +
249 +       default:
250 +               unreachable();
251 +               break;
252 +       }
253 +       printk("%08X\n", i->partnum);
254 +}
255 +
256 +void __init ltq_soc_setup(void)
257 +{
258 +       /*
259 +               reg = IFX_REG_R32(IFX_XBAR_ALWAYS_LAST);
260 +               reg &= ~ IFX_XBAR_FPI_BURST_EN;
261 +               IFX_REG_W32(reg, IFX_XBAR_ALWAYS_LAST);
262 +       */
263 +
264 +       ltq_register_asc(1);
265 +       ltq_register_gpio();
266 +       ltq_register_wdt();
267 +}
268 Index: linux-3.0.3/arch/mips/pci/Makefile
269 ===================================================================
270 --- linux-3.0.3.orig/arch/mips/pci/Makefile     2011-08-17 19:57:16.000000000 +0200
271 +++ linux-3.0.3/arch/mips/pci/Makefile  2011-10-04 20:05:54.238312800 +0200
272 @@ -41,7 +41,7 @@
273  obj-$(CONFIG_SIBYTE_BCM112X)   += fixup-sb1250.o pci-sb1250.o
274  obj-$(CONFIG_SIBYTE_BCM1x80)   += pci-bcm1480.o pci-bcm1480ht.o
275  obj-$(CONFIG_SNI_RM)           += fixup-sni.o ops-sni.o
276 -obj-$(CONFIG_SOC_XWAY)         += pci-lantiq.o ops-lantiq.o
277 +obj-$(CONFIG_LANTIQ)           += pci-lantiq.o ops-lantiq.o
278  obj-$(CONFIG_TANBAC_TB0219)    += fixup-tb0219.o
279  obj-$(CONFIG_TANBAC_TB0226)    += fixup-tb0226.o
280  obj-$(CONFIG_TANBAC_TB0287)    += fixup-tb0287.o