brcm47xx: add initial support for devices with bcma bus.
[openwrt/staging/chunkeey.git] / target / linux / brcm47xx / patches-3.0 / 250-bcma-flash.patch
1 --- a/drivers/mtd/maps/bcm47xx-flash.c
2 +++ b/drivers/mtd/maps/bcm47xx-flash.c
3 @@ -46,11 +46,9 @@
4 #include <linux/mtd/map.h>
5 #include <linux/mtd/partitions.h>
6 #include <linux/crc32.h>
7 -#ifdef CONFIG_SSB
8 -#include <linux/ssb/ssb.h>
9 -#endif
10 #include <asm/io.h>
11 #include <asm/mach-bcm47xx/nvram.h>
12 +#include <asm/mach-bcm47xx/bcm47xx.h>
13 #include <asm/fw/cfe/cfe_api.h>
14
15
16 @@ -90,9 +88,6 @@ struct trx_header {
17 #define ROUTER_NETGEAR_WNR3500L 4
18 #define ROUTER_SIMPLETECH_SIMPLESHARE 5
19
20 -#ifdef CONFIG_SSB
21 -extern struct ssb_bus ssb_bcm47xx;
22 -#endif
23 static struct mtd_info *bcm47xx_mtd;
24
25 static void bcm47xx_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
26 @@ -552,27 +547,42 @@ init_mtd_partitions(struct mtd_info *mtd
27
28 int __init init_bcm47xx_map(void)
29 {
30 -#ifdef CONFIG_SSB
31 - struct ssb_mipscore *mcore = &ssb_bcm47xx.mipscore;
32 +#ifdef CONFIG_BCM47XX_SSB
33 + struct ssb_mipscore *mcore_ssb;
34 +#endif
35 +#ifdef CONFIG_BCM47XX_BCMA
36 + struct bcma_drv_mips *mcore_bcma;
37 #endif
38 size_t size;
39 int ret = 0;
40 + u32 window = 0;
41 + u32 window_size = 0;
42 struct mtd_partition *parts;
43 int i;
44
45 -#ifdef CONFIG_SSB
46 - u32 window = mcore->flash_window;
47 - u32 window_size = mcore->flash_window_size;
48 + switch (bcm47xx_active_bus_type) {
49 +#ifdef CONFIG_BCM47XX_SSB
50 + case BCM47XX_BUS_TYPE_SSB:
51 + mcore_ssb = &bcm47xx_bus.ssb.mipscore;
52 + window = mcore_ssb->flash_window;
53 + window_size = mcore_ssb->flash_window_size;
54 + bcm47xx_map.bankwidth = mcore_ssb->flash_buswidth;
55 + break;
56 +#endif
57 +#ifdef CONFIG_BCM47XX_BCMA
58 + case BCM47XX_BUS_TYPE_BCMA:
59 + mcore_bcma = &bcm47xx_bus.bcma.bus.drv_mips;
60 + window = mcore_bcma->flash_window;
61 + window_size = mcore_bcma->flash_window_size;
62 + bcm47xx_map.bankwidth = mcore_bcma->flash_buswidth;
63 + break;
64 +#endif
65 + }
66
67 printk("flash init: 0x%08x 0x%08x\n", window, window_size);
68 bcm47xx_map.phys = window;
69 bcm47xx_map.size = window_size;
70 - bcm47xx_map.bankwidth = mcore->flash_buswidth;
71 bcm47xx_map.virt = ioremap_nocache(window, window_size);
72 -#else
73 - printk("flash init: 0x%08x 0x%08x\n", WINDOW_ADDR, WINDOW_SIZE);
74 - bcm47xx_map.virt = ioremap_nocache(WINDOW_ADDR, WINDOW_SIZE);
75 -#endif
76
77 if (!bcm47xx_map.virt) {
78 printk("Failed to ioremap\n");