7de051dad9f34be31e48b1845e387dad65dd6057
[openwrt.git] / target / linux / brcm47xx / patches-3.3 / 028-bcm47xx-register-flash-drivers.patch
1 --- a/arch/mips/bcm47xx/Kconfig
2 +++ b/arch/mips/bcm47xx/Kconfig
3 @@ -9,6 +9,7 @@ config BCM47XX_SSB
4         select SSB_EMBEDDED
5         select SSB_B43_PCI_BRIDGE if PCI
6         select SSB_PCICORE_HOSTMODE if PCI
7 +       select SSB_SFLASH
8         default y
9         help
10          Add support for old Broadcom BCM47xx boards with Sonics Silicon Backplane support.
11 @@ -23,6 +24,7 @@ config BCM47XX_BCMA
12         select BCMA_DRIVER_MIPS
13         select BCMA_HOST_PCI if PCI
14         select BCMA_DRIVER_PCI_HOSTMODE if PCI
15 +       select BCMA_SFLASH
16         default y
17         help
18          Add support for new Broadcom BCM47xx boards with Broadcom specific Advanced Microcontroller Bus.
19 --- a/arch/mips/bcm47xx/setup.c
20 +++ b/arch/mips/bcm47xx/setup.c
21 @@ -31,10 +31,12 @@
22  #include <linux/ssb/ssb.h>
23  #include <linux/ssb/ssb_embedded.h>
24  #include <linux/bcma/bcma_soc.h>
25 +#include <linux/platform_device.h>
26  #include <asm/bootinfo.h>
27  #include <asm/reboot.h>
28  #include <asm/time.h>
29  #include <bcm47xx.h>
30 +#include <bus.h>
31  #include <asm/mach-bcm47xx/nvram.h>
32  
33  union bcm47xx_bus bcm47xx_bus;
34 @@ -45,6 +47,32 @@ EXPORT_SYMBOL(bcm47xx_bus_type);
35  
36  struct bcm47xx_sflash bcm47xx_sflash;
37  
38 +static struct resource bcm47xx_pflash_resource = {
39 +       .name   = "bcm47xx_pflash",
40 +       .start  = 0,
41 +       .end    = 0,
42 +       .flags  = 0,
43 +};
44 +
45 +static struct platform_device bcm47xx_pflash_dev = {
46 +       .name           = "bcm47xx_pflash",
47 +       .resource       = &bcm47xx_pflash_resource,
48 +       .num_resources  = 1,
49 +};
50 +
51 +static struct resource bcm47xx_sflash_resource = {
52 +       .name   = "bcm47xx_sflash",
53 +       .start  = 0,
54 +       .end    = 0,
55 +       .flags  = 0,
56 +};
57 +
58 +static struct platform_device bcm47xx_sflash_dev = {
59 +       .name           = "bcm47xx_sflash",
60 +       .resource       = &bcm47xx_sflash_resource,
61 +       .num_resources  = 1,
62 +};
63 +
64  static void bcm47xx_machine_restart(char *command)
65  {
66         printk(KERN_ALERT "Please stand by while rebooting the system...\n");
67 @@ -156,6 +184,24 @@ static void __init bcm47xx_register_ssb(
68                 }
69         }
70  }
71 +
72 +static int __init bcm47xx_register_flash_ssb(void)
73 +{
74 +       struct ssb_chipcommon *chipco = &bcm47xx_bus.ssb.chipco;
75 +
76 +       switch (chipco->flash_type) {
77 +       case SSB_PFLASH:
78 +               bcm47xx_pflash_resource.start = chipco->pflash.window;
79 +               bcm47xx_pflash_resource.end = chipco->pflash.window + chipco->pflash.window_size;
80 +               return platform_device_register(&bcm47xx_pflash_dev);
81 +       case SSB_SFLASH:
82 +               bcm47xx_sflash_dev.dev.platform_data = &bcm47xx_sflash;
83 +               return platform_device_register(&bcm47xx_sflash_dev);
84 +       default:
85 +               printk(KERN_ERR "No flash device found\n");
86 +               return -1;
87 +       }
88 +}
89  #endif
90  
91  #ifdef CONFIG_BCM47XX_BCMA
92 @@ -205,6 +251,24 @@ static void __init bcm47xx_register_bcma
93  
94         bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo, NULL);
95  }
96 +
97 +static int __init bcm47xx_register_flash_bcma(void)
98 +{
99 +       struct bcma_drv_cc *drv_cc = &bcm47xx_bus.bcma.bus.drv_cc;
100 +
101 +       switch (drv_cc->flash_type) {
102 +       case BCMA_PFLASH:
103 +               bcm47xx_pflash_resource.start = drv_cc->pflash.window;
104 +               bcm47xx_pflash_resource.end = drv_cc->pflash.window + drv_cc->pflash.window_size;
105 +               return platform_device_register(&bcm47xx_pflash_dev);
106 +       case BCMA_SFLASH:
107 +               bcm47xx_sflash_dev.dev.platform_data = &bcm47xx_sflash;
108 +               return platform_device_register(&bcm47xx_sflash_dev);
109 +       default:
110 +               printk(KERN_ERR "No flash device found\n");
111 +               return -1;
112 +       }
113 +}
114  #endif
115  
116  void __init plat_mem_setup(void)
117 @@ -247,3 +311,19 @@ static int __init bcm47xx_register_bus_c
118         return 0;
119  }
120  device_initcall(bcm47xx_register_bus_complete);
121 +
122 +static int __init bcm47xx_register_flash(void)
123 +{
124 +       switch (bcm47xx_bus_type) {
125 +#ifdef CONFIG_BCM47XX_SSB
126 +       case BCM47XX_BUS_TYPE_SSB:
127 +               return bcm47xx_register_flash_ssb();
128 +#endif
129 +#ifdef CONFIG_BCM47XX_BCMA
130 +       case BCM47XX_BUS_TYPE_BCMA:
131 +               return bcm47xx_register_flash_bcma();
132 +#endif
133 +       }
134 +       return -1;
135 +}
136 +fs_initcall(bcm47xx_register_flash);