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