brcm63xx: 3.10: backport multi-board support
[openwrt.git] / target / linux / brcm63xx / patches-3.10 / 341-MIPS-BCM63XX-add-support-for-BCM6318.patch
1 From 60c29522a8c77d96145d965589c56befda7d4c3d Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sun, 8 Dec 2013 01:24:09 +0100
4 Subject: [PATCH 51/53] MIPS: BCM63XX: add support for BCM6318
5
6 ---
7  arch/mips/bcm63xx/Kconfig                         |   5 +
8  arch/mips/bcm63xx/boards/board_bcm963xx.c         |   2 +-
9  arch/mips/bcm63xx/clk.c                           |   8 +-
10  arch/mips/bcm63xx/cpu.c                           |  53 +++++++++++
11  arch/mips/bcm63xx/dev-flash.c                     |   3 +
12  arch/mips/bcm63xx/dev-spi.c                       |   2 +-
13  arch/mips/bcm63xx/irq.c                           |  10 ++
14  arch/mips/bcm63xx/prom.c                          |   2 +-
15  arch/mips/bcm63xx/reset.c                         |  24 +++++
16  arch/mips/bcm63xx/setup.c                         |   5 +-
17  arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h  | 107 ++++++++++++++++++++++
18  arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h |  75 ++++++++++++++-
19  arch/mips/include/asm/mach-bcm63xx/ioremap.h      |   1 +
20  13 files changed, 291 insertions(+), 6 deletions(-)
21
22 --- a/arch/mips/bcm63xx/Kconfig
23 +++ b/arch/mips/bcm63xx/Kconfig
24 @@ -18,6 +18,11 @@ config BCM63XX_EHCI
25         select USB_EHCI_BIG_ENDIAN_DESC if USB_EHCI_HCD
26         select USB_EHCI_BIG_ENDIAN_MMIO if USB_EHCI_HCD
27  
28 +config BCM63XX_CPU_6318
29 +       bool "support 6318 CPU"
30 +       select SYS_HAS_CPU_BMIPS32_3300
31 +       select HW_HAS_PCI
32 +
33  config BCM63XX_CPU_6328
34         bool "support 6328 CPU"
35         select SYS_HAS_CPU_BMIPS4350
36 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
37 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
38 @@ -765,7 +765,7 @@ void __init board_prom_init(void)
39         /* read base address of boot chip select (0)
40          * 6328/6362 do not have MPI but boot from a fixed address
41          */
42 -       if (BCMCPU_IS_6328() || BCMCPU_IS_6362() || BCMCPU_IS_63268()) {
43 +       if (BCMCPU_IS_6318() || BCMCPU_IS_6328() || BCMCPU_IS_6362() || BCMCPU_IS_63268()) {
44                 val = 0x18000000;
45         } else {
46                 val = bcm_mpi_readl(MPI_CSBASE_REG(0));
47 --- a/arch/mips/bcm63xx/clk.c
48 +++ b/arch/mips/bcm63xx/clk.c
49 @@ -252,7 +252,9 @@ static void hsspi_set(struct clk *clk, i
50  {
51         u32 mask;
52  
53 -       if (BCMCPU_IS_6328())
54 +       if (BCMCPU_IS_6318())
55 +               mask = CKCTL_6318_HSSPI_EN;
56 +       else if (BCMCPU_IS_6328())
57                 mask = CKCTL_6328_HSSPI_EN;
58         else if (BCMCPU_IS_6362())
59                 mask = CKCTL_6362_HSSPI_EN;
60 @@ -405,12 +407,16 @@ void clk_put(struct clk *clk)
61  
62  EXPORT_SYMBOL(clk_put);
63  
64 +#define HSSPI_PLL_HZ_6318      250000000
65  #define HSSPI_PLL_HZ_6328      133333333
66  #define HSSPI_PLL_HZ_6362      400000000
67  
68  static int __init bcm63xx_clk_init(void)
69  {
70         switch (bcm63xx_get_cpu_id()) {
71 +       case BCM6318_CPU_ID:
72 +               clk_hsspi.rate = HSSPI_PLL_HZ_6318;
73 +               break;
74         case BCM6328_CPU_ID:
75                 clk_hsspi.rate = HSSPI_PLL_HZ_6328;
76                 break;
77 --- a/arch/mips/bcm63xx/cpu.c
78 +++ b/arch/mips/bcm63xx/cpu.c
79 @@ -41,6 +41,14 @@ static const int bcm3368_irqs[] = {
80         __GEN_CPU_IRQ_TABLE(3368)
81  };
82  
83 +static const unsigned long bcm6318_regs_base[] = {
84 +       __GEN_CPU_REGS_TABLE(6318)
85 +};
86 +
87 +static const int bcm6318_irqs[] = {
88 +       __GEN_CPU_IRQ_TABLE(6318)
89 +};
90 +
91  static const unsigned long bcm6328_regs_base[] = {
92         __GEN_CPU_REGS_TABLE(6328)
93  };
94 @@ -134,12 +142,38 @@ unsigned int bcm63xx_get_memory_size(voi
95         return bcm63xx_memory_size;
96  }
97  
98 +#define STRAP_OVERRIDE_BUS_REG         0x0
99 +#define OVERRIDE_BUS_MIPS_FREQ_SHIFT   23
100 +#define OVERRIDE_BUS_MIPS_FREQ_MASK    (0x3 << OVERRIDE_BUS_MIPS_FREQ_SHIFT)
101 +
102  static unsigned int detect_cpu_clock(void)
103  {
104         switch (bcm63xx_get_cpu_id()) {
105         case BCM3368_CPU_ID:
106                 return 300000000;
107  
108 +       case BCM6318_CPU_ID:
109 +       {
110 +               unsigned int tmp, mips_pll_fcvo;
111 +
112 +               tmp = bcm_readl(BCM_6318_STRAP_BASE + STRAP_OVERRIDE_BUS_REG);
113 +
114 +               pr_info("strap_override_bus = %08x\n", tmp);
115 +
116 +               mips_pll_fcvo = (tmp & OVERRIDE_BUS_MIPS_FREQ_MASK)
117 +                               >> OVERRIDE_BUS_MIPS_FREQ_SHIFT;
118 +
119 +               switch (mips_pll_fcvo) {
120 +               case 0:
121 +                       return 166000000;
122 +               case 1:
123 +                       return 400000000;
124 +               case 2:
125 +                       return 250000000;
126 +               case 3:
127 +                       return 333000000;
128 +               };
129 +       }
130         case BCM6328_CPU_ID:
131         {
132                 unsigned int tmp, mips_pll_fcvo;
133 @@ -295,6 +329,13 @@ static unsigned int detect_memory_size(v
134         unsigned int cols = 0, rows = 0, is_32bits = 0, banks = 0;
135         u32 val;
136  
137 +       if (BCMCPU_IS_6318()) {
138 +               val = bcm_sdram_readl(SDRAM_CFG_REG);
139 +               val = val & SDRAM_CFG_6318_SPACE_MASK;
140 +               val >>= SDRAM_CFG_6318_SPACE_SHIFT;
141 +               return 1 << (val + 20);
142 +       }
143 +
144         if (BCMCPU_IS_6328() || BCMCPU_IS_6362() || BCMCPU_IS_63268())
145                 return bcm_ddr_readl(DDR_CSEND_REG) << 24;
146  
147 @@ -342,6 +383,12 @@ void __init bcm63xx_cpu_init(void)
148  
149         switch (c->cputype) {
150         case CPU_BMIPS3300:
151 +               if ((read_c0_prid() & 0xff) >= 0x33) {
152 +                       /* BCM6318 */
153 +                       chipid_reg = BCM_6368_PERF_BASE;
154 +                       break;
155 +               }
156 +
157                 if ((read_c0_prid() & 0xff00) != PRID_IMP_BMIPS3300_ALT)
158                         __cpu_name[cpu] = "Broadcom BCM6338";
159                 /* fall-through */
160 @@ -389,6 +436,10 @@ void __init bcm63xx_cpu_init(void)
161         bcm63xx_cpu_variant = bcm63xx_cpu_id;
162  
163         switch (bcm63xx_cpu_id) {
164 +       case BCM6318_CPU_ID:
165 +               bcm63xx_regs_base = bcm6318_regs_base;
166 +               bcm63xx_irqs = bcm6318_irqs;
167 +               break;
168         case BCM3368_CPU_ID:
169                 bcm63xx_regs_base = bcm3368_regs_base;
170                 bcm63xx_irqs = bcm3368_irqs;
171 --- a/arch/mips/bcm63xx/dev-flash.c
172 +++ b/arch/mips/bcm63xx/dev-flash.c
173 @@ -60,6 +60,9 @@ static int __init bcm63xx_detect_flash_t
174         u32 val;
175  
176         switch (bcm63xx_get_cpu_id()) {
177 +       case BCM6318_CPU_ID:
178 +               /* only support serial flash */
179 +               return BCM63XX_FLASH_TYPE_SERIAL;
180         case BCM6328_CPU_ID:
181                 val = bcm_misc_readl(MISC_STRAPBUS_6328_REG);
182                 if (val & STRAPBUS_6328_BOOT_SEL_SERIAL)
183 --- a/arch/mips/bcm63xx/dev-spi.c
184 +++ b/arch/mips/bcm63xx/dev-spi.c
185 @@ -70,7 +70,7 @@ static struct platform_device bcm63xx_sp
186  
187  int __init bcm63xx_spi_register(void)
188  {
189 -       if (BCMCPU_IS_6328() || BCMCPU_IS_6345())
190 +       if (BCMCPU_IS_6318() || BCMCPU_IS_6328() || BCMCPU_IS_6345())
191                 return -ENODEV;
192  
193         spi_resources[0].start = bcm63xx_regset_address(RSET_SPI);
194 --- a/arch/mips/bcm63xx/irq.c
195 +++ b/arch/mips/bcm63xx/irq.c
196 @@ -441,6 +441,16 @@ static void bcm63xx_init_irq(void)
197                 ext_irq_count = 4;
198                 ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_3368;
199                 break;
200 +       case BCM6318_CPU_ID:
201 +               irq_stat_addr[0] += PERF_IRQSTAT_6318_REG;
202 +               irq_mask_addr[0] += PERF_IRQMASK_6318_REG;
203 +               irq_bits = 128;
204 +               ext_irq_count = 4;
205 +               is_ext_irq_cascaded = 1;
206 +               ext_irq_start = BCM_6318_EXT_IRQ0 - IRQ_INTERNAL_BASE;
207 +               ext_irq_end = BCM_6318_EXT_IRQ3 - IRQ_INTERNAL_BASE;
208 +               ext_irq_cfg_reg1 = PERF_EXTIRQ_CFG_REG_6318;
209 +               break;
210         case BCM6328_CPU_ID:
211                 irq_stat_addr[0] += PERF_IRQSTAT_6328_REG(0);
212                 irq_mask_addr[0] += PERF_IRQMASK_6328_REG(0);
213 --- a/arch/mips/bcm63xx/prom.c
214 +++ b/arch/mips/bcm63xx/prom.c
215 @@ -72,7 +72,7 @@ void __init prom_init(void)
216  
217                         if (reg & OTP_6328_REG3_TP1_DISABLED)
218                                 bmips_smp_enabled = 0;
219 -               } else if (BCMCPU_IS_3368() || BCMCPU_IS_6358()) {
220 +               } else if (BCMCPU_IS_6318() || BCMCPU_IS_3368() || BCMCPU_IS_6358()) {
221                         bmips_smp_enabled = 0;
222                 }
223  
224 --- a/arch/mips/bcm63xx/reset.c
225 +++ b/arch/mips/bcm63xx/reset.c
226 @@ -43,6 +43,23 @@
227  #define BCM3368_RESET_PCIE     0
228  #define BCM3368_RESET_PCIE_EXT 0
229  
230 +
231 +#define BCM6318_RESET_SPI      SOFTRESET_6318_SPI_MASK
232 +#define BCM6318_RESET_ENET     0
233 +#define BCM6318_RESET_USBH     SOFTRESET_6318_USBH_MASK
234 +#define BCM6318_RESET_USBD     SOFTRESET_6318_USBS_MASK
235 +#define BCM6318_RESET_DSL      0
236 +#define BCM6318_RESET_SAR      SOFTRESET_6318_SAR_MASK
237 +#define BCM6318_RESET_EPHY     SOFTRESET_6318_EPHY_MASK
238 +#define BCM6318_RESET_ENETSW   SOFTRESET_6318_ENETSW_MASK
239 +#define BCM6318_RESET_PCM      0
240 +#define BCM6318_RESET_MPI      0
241 +#define BCM6318_RESET_PCIE     \
242 +                               (SOFTRESET_6318_PCIE_MASK |             \
243 +                                SOFTRESET_6318_PCIE_CORE_MASK |        \
244 +                                SOFTRESET_6318_PCIE_HARD_MASK)
245 +#define BCM6318_RESET_PCIE_EXT SOFTRESET_6318_PCIE_EXT_MASK
246 +
247  #define BCM6328_RESET_SPI      SOFTRESET_6328_SPI_MASK
248  #define BCM6328_RESET_ENET     0
249  #define BCM6328_RESET_USBH     SOFTRESET_6328_USBH_MASK
250 @@ -147,6 +164,10 @@ static const u32 bcm3368_reset_bits[] =
251         __GEN_RESET_BITS_TABLE(3368)
252  };
253  
254 +static const u32 bcm6318_reset_bits[] = {
255 +       __GEN_RESET_BITS_TABLE(6318)
256 +};
257 +
258  static const u32 bcm6328_reset_bits[] = {
259         __GEN_RESET_BITS_TABLE(6328)
260  };
261 @@ -183,6 +204,9 @@ static int __init bcm63xx_reset_bits_ini
262         if (BCMCPU_IS_3368()) {
263                 reset_reg = PERF_SOFTRESET_6358_REG;
264                 bcm63xx_reset_bits = bcm3368_reset_bits;
265 +       } else if (BCMCPU_IS_6318()) {
266 +               reset_reg = PERF_SOFTRESET_6318_REG;
267 +               bcm63xx_reset_bits = bcm6318_reset_bits;
268         } else if (BCMCPU_IS_6328()) {
269                 reset_reg = PERF_SOFTRESET_6328_REG;
270                 bcm63xx_reset_bits = bcm6328_reset_bits;
271 --- a/arch/mips/bcm63xx/setup.c
272 +++ b/arch/mips/bcm63xx/setup.c
273 @@ -71,6 +71,9 @@ void bcm63xx_machine_reboot(void)
274         case BCM3368_CPU_ID:
275                 perf_regs[0] = PERF_EXTIRQ_CFG_REG_3368;
276                 break;
277 +       case BCM6318_CPU_ID:
278 +               perf_regs[0] = PERF_EXTIRQ_CFG_REG_6318;
279 +               break;
280         case BCM6328_CPU_ID:
281                 perf_regs[0] = PERF_EXTIRQ_CFG_REG_6328;
282                 break;
283 @@ -110,7 +113,7 @@ void bcm63xx_machine_reboot(void)
284                 bcm6348_a1_reboot();
285  
286         printk(KERN_INFO "triggering watchdog soft-reset...\n");
287 -       if (BCMCPU_IS_6328()) {
288 +       if (BCMCPU_IS_6318() || BCMCPU_IS_6328()) {
289                 bcm_wdt_writel(1, WDT_SOFTRESET_REG);
290         } else {
291                 reg = bcm_perf_readl(PERF_SYS_PLL_CTL_REG);
292 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
293 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
294 @@ -10,6 +10,7 @@
295   * arm mach-types)
296   */
297  #define BCM3368_CPU_ID         0x3368
298 +#define BCM6318_CPU_ID         0x6318
299  #define BCM6328_CPU_ID         0x6328
300  #define BCM63281_CPU_ID                0x63281
301  #define BCM63283_CPU_ID                0x63283
302 @@ -38,6 +39,10 @@ static inline u32 __pure __bcm63xx_get_c
303                 case BCM3368_CPU_ID:
304  #endif
305  
306 +#ifdef CONFIG_BCM63XX_CPU_6318
307 +               case BCM6318_CPU_ID:
308 +#endif
309 +
310  #ifdef CONFIG_BCM63XX_CPU_6328
311                 case BCM6328_CPU_ID:
312  #endif
313 @@ -87,6 +92,7 @@ static inline u32 __pure bcm63xx_get_cpu
314  }
315  
316  #define BCMCPU_IS_3368()       (bcm63xx_get_cpu_id() == BCM3368_CPU_ID)
317 +#define BCMCPU_IS_6318()       (bcm63xx_get_cpu_id() == BCM6318_CPU_ID)
318  #define BCMCPU_IS_6328()       (bcm63xx_get_cpu_id() == BCM6328_CPU_ID)
319  #define BCMCPU_IS_6338()       (bcm63xx_get_cpu_id() == BCM6338_CPU_ID)
320  #define BCMCPU_IS_6345()       (bcm63xx_get_cpu_id() == BCM6345_CPU_ID)
321 @@ -98,6 +104,8 @@ static inline u32 __pure bcm63xx_get_cpu
322  
323  #define BCMCPU_VARIANT_IS_3368() \
324         (bcm63xx_get_cpu_variant() == BCM3368_CPU_ID)
325 +#define BCMCPU_VARIANT_IS_6318() \
326 +       (bcm63xx_get_cpu_variant() == BCM6318_CPU_ID)
327  #define BCMCPU_VARIANT_IS_63281() \
328         (bcm63xx_get_cpu_variant() == BCM63281_CPU_ID)
329  #define BCMCPU_VARIANT_IS_63283() \
330 @@ -252,6 +260,56 @@ enum bcm63xx_regs_set {
331  #define BCM_3368_MISC_BASE             (0xdeadbeef)
332  
333  /*
334 + * 6318 register sets base address
335 + */
336 +#define BCM_6318_DSL_LMEM_BASE         (0xdeadbeef)
337 +#define BCM_6318_PERF_BASE             (0xb0000000)
338 +#define BCM_6318_TIMER_BASE            (0xb0000040)
339 +#define BCM_6318_WDT_BASE              (0xb0000068)
340 +#define BCM_6318_UART0_BASE            (0xb0000100)
341 +#define BCM_6318_UART1_BASE            (0xdeadbeef)
342 +#define BCM_6318_GPIO_BASE             (0xb0000080)
343 +#define BCM_6318_SPI_BASE              (0xdeadbeef)
344 +#define BCM_6318_HSSPI_BASE            (0xb0003000)
345 +#define BCM_6318_UDC0_BASE             (0xdeadbeef)
346 +#define BCM_6318_USBDMA_BASE           (0xb0006800)
347 +#define BCM_6318_OHCI0_BASE            (0xb0005100)
348 +#define BCM_6318_OHCI_PRIV_BASE                (0xdeadbeef)
349 +#define BCM_6318_USBH_PRIV_BASE                (0xb0005200)
350 +#define BCM_6318_USBD_BASE             (0xb0006000)
351 +#define BCM_6318_MPI_BASE              (0xdeadbeef)
352 +#define BCM_6318_PCMCIA_BASE           (0xdeadbeef)
353 +#define BCM_6318_PCIE_BASE             (0xb0010000)
354 +#define BCM_6318_SDRAM_REGS_BASE       (0xdeadbeef)
355 +#define BCM_6318_DSL_BASE              (0xdeadbeef)
356 +#define BCM_6318_UBUS_BASE             (0xdeadbeef)
357 +#define BCM_6318_ENET0_BASE            (0xdeadbeef)
358 +#define BCM_6318_ENET1_BASE            (0xdeadbeef)
359 +#define BCM_6318_ENETDMA_BASE          (0xb0088000)
360 +#define BCM_6318_ENETDMAC_BASE         (0xb0088200)
361 +#define BCM_6318_ENETDMAS_BASE         (0xb0088400)
362 +#define BCM_6318_ENETSW_BASE           (0xb0080000)
363 +#define BCM_6318_EHCI0_BASE            (0xb0005000)
364 +#define BCM_6318_SDRAM_BASE            (0xb0004000)
365 +#define BCM_6318_MEMC_BASE             (0xdeadbeef)
366 +#define BCM_6318_DDR_BASE              (0xdeadbeef)
367 +#define BCM_6318_M2M_BASE              (0xdeadbeef)
368 +#define BCM_6318_ATM_BASE              (0xdeadbeef)
369 +#define BCM_6318_XTM_BASE              (0xdeadbeef)
370 +#define BCM_6318_XTMDMA_BASE           (0xb000c000)
371 +#define BCM_6318_XTMDMAC_BASE          (0xdeadbeef)
372 +#define BCM_6318_XTMDMAS_BASE          (0xdeadbeef)
373 +#define BCM_6318_PCM_BASE              (0xdeadbeef)
374 +#define BCM_6318_PCMDMA_BASE           (0xdeadbeef)
375 +#define BCM_6318_PCMDMAC_BASE          (0xdeadbeef)
376 +#define BCM_6318_PCMDMAS_BASE          (0xdeadbeef)
377 +#define BCM_6318_RNG_BASE              (0xdeadbeef)
378 +#define BCM_6318_MISC_BASE             (0xb0000280)
379 +#define BCM_6318_OTP_BASE              (0xdeadbeef)
380 +
381 +#define BCM_6318_STRAP_BASE            (0xb0000900)
382 +
383 +/*
384   * 6328 register sets base address
385   */
386  #define BCM_6328_DSL_LMEM_BASE         (0xdeadbeef)
387 @@ -819,6 +877,55 @@ enum bcm63xx_irq {
388  #define BCM_3368_EXT_IRQ2              (IRQ_INTERNAL_BASE + 27)
389  #define BCM_3368_EXT_IRQ3              (IRQ_INTERNAL_BASE + 28)
390  
391 +/*
392 + * 6318 irqs
393 + */
394 +#define BCM_6318_HIGH_IRQ_BASE         (IRQ_INTERNAL_BASE + 32)
395 +#define BCM_6318_VERY_HIGH_IRQ_BASE    (BCM_6318_HIGH_IRQ_BASE + 32)
396 +
397 +#define BCM_6318_TIMER_IRQ             (IRQ_INTERNAL_BASE + 31)
398 +#define BCM_6318_SPI_IRQ               0
399 +#define BCM_6318_UART0_IRQ             (IRQ_INTERNAL_BASE + 28)
400 +#define BCM_6318_UART1_IRQ             0
401 +#define BCM_6318_DSL_IRQ               (IRQ_INTERNAL_BASE + 21)
402 +#define BCM_6318_UDC0_IRQ              0
403 +#define BCM_6318_ENET0_IRQ             0
404 +#define BCM_6318_ENET1_IRQ             0
405 +#define BCM_6318_ENET_PHY_IRQ          (IRQ_INTERNAL_BASE + 12)
406 +#define BCM_6318_HSSPI_IRQ             (IRQ_INTERNAL_BASE + 29)
407 +#define BCM_6318_OHCI0_IRQ             (BCM_6318_HIGH_IRQ_BASE + 9)
408 +#define BCM_6318_EHCI0_IRQ             (BCM_6318_HIGH_IRQ_BASE + 10)
409 +#define BCM_6318_USBD_IRQ              (IRQ_INTERNAL_BASE + 4)
410 +#define BCM_6318_USBD_RXDMA0_IRQ       (IRQ_INTERNAL_BASE + 5)
411 +#define BCM_6318_USBD_TXDMA0_IRQ       (IRQ_INTERNAL_BASE + 6)
412 +#define BCM_6318_USBD_RXDMA1_IRQ       (IRQ_INTERNAL_BASE + 7)
413 +#define BCM_6318_USBD_TXDMA1_IRQ       (IRQ_INTERNAL_BASE + 8)
414 +#define BCM_6318_USBD_RXDMA2_IRQ       (IRQ_INTERNAL_BASE + 9)
415 +#define BCM_6318_USBD_TXDMA2_IRQ       (IRQ_INTERNAL_BASE + 10)
416 +#define BCM_6318_PCMCIA_IRQ            0
417 +#define BCM_6318_ENET0_RXDMA_IRQ       0
418 +#define BCM_6318_ENET0_TXDMA_IRQ       0
419 +#define BCM_6318_ENET1_RXDMA_IRQ       0
420 +#define BCM_6318_ENET1_TXDMA_IRQ       0
421 +#define BCM_6318_PCI_IRQ               (IRQ_INTERNAL_BASE + 23)
422 +#define BCM_6318_ATM_IRQ               0
423 +#define BCM_6318_ENETSW_RXDMA0_IRQ     (BCM_6318_HIGH_IRQ_BASE + 0)
424 +#define BCM_6318_ENETSW_RXDMA1_IRQ     (BCM_6318_HIGH_IRQ_BASE + 1)
425 +#define BCM_6318_ENETSW_RXDMA2_IRQ     (BCM_6318_HIGH_IRQ_BASE + 2)
426 +#define BCM_6318_ENETSW_RXDMA3_IRQ     (BCM_6318_HIGH_IRQ_BASE + 3)
427 +#define BCM_6318_ENETSW_TXDMA0_IRQ     (BCM_6318_VERY_HIGH_IRQ_BASE + 10)
428 +#define BCM_6318_ENETSW_TXDMA1_IRQ     (BCM_6318_VERY_HIGH_IRQ_BASE + 11)
429 +#define BCM_6318_ENETSW_TXDMA2_IRQ     (BCM_6318_VERY_HIGH_IRQ_BASE + 12)
430 +#define BCM_6318_ENETSW_TXDMA3_IRQ     (BCM_6318_VERY_HIGH_IRQ_BASE + 13)
431 +#define BCM_6318_XTM_IRQ               (BCM_6318_HIGH_IRQ_BASE + 31)
432 +#define BCM_6318_XTM_DMA0_IRQ          (BCM_6318_HIGH_IRQ_BASE + 11)
433 +
434 +#define BCM_6318_PCM_DMA0_IRQ          (IRQ_INTERNAL_BASE + 2)
435 +#define BCM_6318_PCM_DMA1_IRQ          (IRQ_INTERNAL_BASE + 3)
436 +#define BCM_6318_EXT_IRQ0              (IRQ_INTERNAL_BASE + 24)
437 +#define BCM_6318_EXT_IRQ1              (IRQ_INTERNAL_BASE + 25)
438 +#define BCM_6318_EXT_IRQ2              (IRQ_INTERNAL_BASE + 26)
439 +#define BCM_6318_EXT_IRQ3              (IRQ_INTERNAL_BASE + 27)
440  
441  /*
442   * 6328 irqs
443 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
444 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
445 @@ -52,6 +52,39 @@
446                                          CKCTL_3368_EMUSB_EN | \
447                                          CKCTL_3368_USBU_EN)
448  
449 +#define CKCTL_6318_ADSL_ASB_EN         (1 << 0)
450 +#define CKCTL_6318_USB_ASB_EN          (1 << 1)
451 +#define CKCTL_6318_MIPS_ASB_EN         (1 << 2)
452 +#define CKCTL_6318_PCIE_ASB_EN         (1 << 3)
453 +#define CKCTL_6318_PHYMIPS_ASB_EN      (1 << 4)
454 +#define CKCTL_6318_ROBOSW_ASB_EN       (1 << 5)
455 +#define CKCTL_6318_SAR_ASB_EN          (1 << 6)
456 +#define CKCTL_6318_SDR_ASB_EN          (1 << 7)
457 +#define CKCTL_6318_SWREG_ASB_EN                (1 << 8)
458 +#define CKCTL_6318_PERIPH_ASB_EN       (1 << 9)
459 +#define CKCTL_6318_CPUBUS160_EN                (1 << 10)
460 +#define CKCTL_6318_ADSL_EN             (1 << 11)
461 +#define CKCTL_6318_SAR125_EN           (1 << 12)
462 +#define CKCTL_6318_MIPS_EN             (1 << 13)
463 +#define CKCTL_6318_PCIE_EN             (1 << 14)
464 +#define CKCTL_6318_ROBOSW250_EN                (1 << 16)
465 +#define CKCTL_6318_ROBOSW025_EN                (1 << 17)
466 +#define CKCTL_6318_SDR_EN              (1 << 19)
467 +#define CKCTL_6318_USB_EN              (1 << 20) /* both device and host */
468 +#define CKCTL_6318_HSSPI_EN            (1 << 25)
469 +#define CKCTL_6318_PCIE25_EN           (1 << 27)
470 +#define CKCTL_6318_PHYMIPS_EN          (1 << 28)
471 +#define CKCTL_6318_ADSL_AFE_EN         (1 << 29)
472 +#define CKCTL_6318_ADSL_QPROC_EN       (1 << 30)
473 +
474 +#define CKCTL_6318_ALL_SAFE_EN         (CKCTL_6318_PHYMIPS_EN |        \
475 +                                       CKCTL_6318_ADSL_QPROC_EN |      \
476 +                                       CKCTL_6318_ADSL_AFE_EN |        \
477 +                                       CKCTL_6318_ADSL_EN |            \
478 +                                       CKCTL_6318_SAR_EN  |            \
479 +                                       CKCTL_6318_USB_EN |             \
480 +                                       CKCTL_6318_PCIE_EN)
481 +
482  #define CKCTL_6328_PHYMIPS_EN          (1 << 0)
483  #define CKCTL_6328_ADSL_QPROC_EN       (1 << 1)
484  #define CKCTL_6328_ADSL_AFE_EN         (1 << 2)
485 @@ -259,12 +292,27 @@
486                                         CKCTL_63268_TBUS_EN |           \
487                                         CKCTL_63268_ROBOSW250_EN)
488  
489 +/* UBUS Clock Control register */
490 +#define PERF_UB_CKCTL_REG              0x10
491 +
492 +#define UB_CKCTL_6318_ADSL_EN          (1 << 0)
493 +#define UB_CKCTL_6318_ARB_EN           (1 << 1)
494 +#define UB_CKCTL_6318_MIPS_EN          (1 << 2)
495 +#define UB_CKCTL_6318_PCIE_EN          (1 << 3)
496 +#define UB_CKCTL_6318_PERIPH_EN                (1 << 4)
497 +#define UB_CKCTL_6318_PHYMIPS_EN       (1 << 5)
498 +#define UB_CKCTL_6318_ROBOSW_EN                (1 << 6)
499 +#define UB_CKCTL_6318_SAR_EN           (1 << 7)
500 +#define UB_CKCTL_6318_SDR_EN           (1 << 8)
501 +#define UB_CKCTL_6318_USB_EN           (1 << 9)
502 +
503  /* System PLL Control register */
504  #define PERF_SYS_PLL_CTL_REG           0x8
505  #define SYS_PLL_SOFT_RESET             0x1
506  
507  /* Interrupt Mask register */
508  #define PERF_IRQMASK_3368_REG          0xc
509 +#define PERF_IRQMASK_6318_REG          0x20
510  #define PERF_IRQMASK_6328_REG(x)       (0x20 + (x) * 0x10)
511  #define PERF_IRQMASK_6338_REG          0xc
512  #define PERF_IRQMASK_6345_REG          0xc
513 @@ -276,6 +324,7 @@
514  
515  /* Interrupt Status register */
516  #define PERF_IRQSTAT_3368_REG          0x10
517 +#define PERF_IRQSTAT_6318_REG          0x30
518  #define PERF_IRQSTAT_6328_REG(x)       (0x28 + (x) * 0x10)
519  #define PERF_IRQSTAT_6338_REG          0x10
520  #define PERF_IRQSTAT_6345_REG          0x10
521 @@ -287,6 +336,7 @@
522  
523  /* External Interrupt Configuration register */
524  #define PERF_EXTIRQ_CFG_REG_3368       0x14
525 +#define PERF_EXTIRQ_CFG_REG_6318       0x18
526  #define PERF_EXTIRQ_CFG_REG_6328       0x18
527  #define PERF_EXTIRQ_CFG_REG_6338       0x14
528  #define PERF_EXTIRQ_CFG_REG_6345       0x14
529 @@ -320,6 +370,7 @@
530  
531  /* Soft Reset register */
532  #define PERF_SOFTRESET_REG             0x28
533 +#define PERF_SOFTRESET_6318_REG                0x10
534  #define PERF_SOFTRESET_6328_REG                0x10
535  #define PERF_SOFTRESET_6358_REG                0x34
536  #define PERF_SOFTRESET_6362_REG                0x10
537 @@ -333,6 +384,18 @@
538  #define SOFTRESET_3368_USBS_MASK       (1 << 11)
539  #define SOFTRESET_3368_PCM_MASK                (1 << 13)
540  
541 +#define SOFTRESET_6318_SPI_MASK                (1 << 0)
542 +#define SOFTRESET_6318_EPHY_MASK       (1 << 1)
543 +#define SOFTRESET_6318_SAR_MASK                (1 << 2)
544 +#define SOFTRESET_6318_ENETSW_MASK     (1 << 3)
545 +#define SOFTRESET_6318_USBS_MASK       (1 << 4)
546 +#define SOFTRESET_6318_USBH_MASK       (1 << 5)
547 +#define SOFTRESET_6318_PCIE_CORE_MASK  (1 << 6)
548 +#define SOFTRESET_6318_PCIE_MASK       (1 << 7)
549 +#define SOFTRESET_6318_PCIE_EXT_MASK   (1 << 8)
550 +#define SOFTRESET_6318_PCIE_HARD_MASK  (1 << 9)
551 +#define SOFTRESET_6318_ADSL_MASK       (1 << 10)
552 +
553  #define SOFTRESET_6328_SPI_MASK                (1 << 0)
554  #define SOFTRESET_6328_EPHY_MASK       (1 << 1)
555  #define SOFTRESET_6328_SAR_MASK                (1 << 2)
556 @@ -504,8 +567,17 @@
557  #define TIMER_IRQSTAT_TIMER1_IR_EN     (1 << 9)
558  #define TIMER_IRQSTAT_TIMER2_IR_EN     (1 << 10)
559  
560 +#define TIMER_IRQMASK_6318_REG         0x0
561 +#define TIMER_IRQSTAT_6318_REG         0x4
562 +#define IRQSTATMASK_TIMER0             (1 << 0)
563 +#define IRQSTATMASK_TIMER1             (1 << 1)
564 +#define IRQSTATMASK_TIMER2             (1 << 2)
565 +#define IRQSTATMASK_TIMER3             (1 << 3)
566 +#define IRQSTATMASK_WDT                        (1 << 4)
567 +
568  /* Timer control register */
569  #define TIMER_CTLx_REG(x)              (0x4 + (x * 4))
570 +#define TIMER_CTRx_6318_REG(x)         (0x8 + (x * 4))
571  #define TIMER_CTL0_REG                 0x4
572  #define TIMER_CTL1_REG                 0x8
573  #define TIMER_CTL2_REG                 0xC
574 @@ -1372,6 +1444,8 @@
575  #define SDRAM_CFG_32B_MASK             (1 << SDRAM_CFG_32B_SHIFT)
576  #define SDRAM_CFG_BANK_SHIFT           13
577  #define SDRAM_CFG_BANK_MASK            (1 << SDRAM_CFG_BANK_SHIFT)
578 +#define SDRAM_CFG_6318_SPACE_SHIFT     4
579 +#define SDRAM_CFG_6318_SPACE_MASK      (0xf << SDRAM_CFG_6318_SPACE_SHIFT)
580  
581  #define SDRAM_MBASE_REG                        0xc
582  
583 --- a/arch/mips/include/asm/mach-bcm63xx/ioremap.h
584 +++ b/arch/mips/include/asm/mach-bcm63xx/ioremap.h
585 @@ -22,6 +22,7 @@ static inline int is_bcm63xx_internal_re
586                 if (offset >= 0xfff00000)
587                         return 1;
588                 break;
589 +       case BCM6318_CPU_ID:
590         case BCM6328_CPU_ID:
591         case BCM6362_CPU_ID:
592         case BCM6368_CPU_ID:
593 --- a/arch/mips/bcm63xx/dev-hsspi.c
594 +++ b/arch/mips/bcm63xx/dev-hsspi.c
595 @@ -35,7 +35,8 @@ static struct platform_device bcm63xx_hs
596  
597  int __init bcm63xx_hsspi_register(void)
598  {
599 -       if (!BCMCPU_IS_6328() && !BCMCPU_IS_6362() && !BCMCPU_IS_63268())
600 +       if (!BCMCPU_IS_6318() && !BCMCPU_IS_6328() && !BCMCPU_IS_6362() &&
601 +               !BCMCPU_IS_63268())
602                 return -ENODEV;
603  
604         spi_resources[0].start = bcm63xx_regset_address(RSET_HSSPI);
605 --- a/arch/mips/bcm63xx/dev-usb-usbd.c
606 +++ b/arch/mips/bcm63xx/dev-usb-usbd.c
607 @@ -41,7 +41,7 @@ int __init bcm63xx_usbd_register(const s
608                 IRQ_USBD_RXDMA2, IRQ_USBD_TXDMA2 };
609         int i;
610  
611 -       if (!BCMCPU_IS_6328() && !BCMCPU_IS_6368())
612 +       if (!BCMCPU_IS_6318() && !BCMCPU_IS_6328() && !BCMCPU_IS_6368())
613                 return 0;
614  
615         usbd_resources[0].start = bcm63xx_regset_address(RSET_USBD);
616 --- a/arch/mips/bcm63xx/dev-enet.c
617 +++ b/arch/mips/bcm63xx/dev-enet.c
618 @@ -176,8 +176,8 @@ static int __init register_shared(void)
619         else
620                 shared_res[0].end += (RSET_ENETDMA_SIZE)  - 1;
621  
622 -       if (BCMCPU_IS_6328() || BCMCPU_IS_6362() || BCMCPU_IS_6368() ||
623 -               BCMCPU_IS_63268())
624 +       if (BCMCPU_IS_6318() || BCMCPU_IS_6328() || BCMCPU_IS_6362() ||
625 +               BCMCPU_IS_6368() || BCMCPU_IS_63268())
626                 chan_count = 32;
627         else if (BCMCPU_IS_6345())
628                 chan_count = 8;
629 @@ -277,8 +277,8 @@ bcm63xx_enetsw_register(const struct bcm
630  {
631         int ret;
632  
633 -       if (!BCMCPU_IS_6328() && !BCMCPU_IS_6362() && !BCMCPU_IS_6368() &&
634 -               !BCMCPU_IS_63268())
635 +       if (!BCMCPU_IS_6318() && !BCMCPU_IS_6328() && !BCMCPU_IS_6362() &&
636 +               !BCMCPU_IS_6368() && !BCMCPU_IS_63268())
637                 return -ENODEV;
638  
639         ret = register_shared();
640 @@ -295,7 +295,7 @@ bcm63xx_enetsw_register(const struct bcm
641  
642         memcpy(bcm63xx_enetsw_device.dev.platform_data, pd, sizeof(*pd));
643  
644 -       if (BCMCPU_IS_6328())
645 +       if (BCMCPU_IS_6318() || BCMCPU_IS_6328())
646                 enetsw_pd.num_ports = ENETSW_PORTS_6328;
647         else if (BCMCPU_IS_6362() || BCMCPU_IS_6368() ||
648                  BCMCPU_VARIANT_IS_63168() || BCMCPU_VARIANT_IS_63169())
649 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
650 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_gpio.h
651 @@ -9,6 +9,8 @@ int __init bcm63xx_gpio_init(void);
652  static inline unsigned long bcm63xx_gpio_count(void)
653  {
654         switch (bcm63xx_get_cpu_id()) {
655 +       case BCM6318_CPU_ID:
656 +               return 50;
657         case BCM6328_CPU_ID:
658                 return 32;
659         case BCM3368_CPU_ID:
660 --- a/arch/mips/bcm63xx/dev-usb-ehci.c
661 +++ b/arch/mips/bcm63xx/dev-usb-ehci.c
662 @@ -81,7 +81,8 @@ static struct platform_device bcm63xx_eh
663  
664  int __init bcm63xx_ehci_register(void)
665  {
666 -       if (!BCMCPU_IS_6328() && !BCMCPU_IS_6358() && !BCMCPU_IS_6362() && !BCMCPU_IS_6368())
667 +       if (!BCMCPU_IS_6318() && !BCMCPU_IS_6328() && !BCMCPU_IS_6358() &&
668 +               !BCMCPU_IS_6362() && !BCMCPU_IS_6368())
669                 return 0;
670  
671         ehci_resources[0].start = bcm63xx_regset_address(RSET_EHCI0);