kernel: ssb/bcma: update to version from wireless-testing tag master-2012-05-16-2
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / patches-3.3 / 024-brcm47xx-add-common-interface-for-sflash.patch
1 --- a/arch/mips/bcm47xx/Makefile
2 +++ b/arch/mips/bcm47xx/Makefile
3 @@ -3,5 +3,5 @@
4 # under Linux.
5 #
6
7 -obj-y += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o
8 +obj-y += gpio.o irq.o nvram.o prom.o serial.o setup.o time.o bus.o
9 obj-$(CONFIG_BCM47XX_SSB) += wgt634u.o
10 --- /dev/null
11 +++ b/arch/mips/bcm47xx/bus.c
12 @@ -0,0 +1,82 @@
13 +/*
14 + * BCM947xx nvram variable access
15 + *
16 + * Copyright (C) 2011 Hauke Mehrtens <hauke@hauke-m.de>
17 + *
18 + * This program is free software; you can redistribute it and/or modify it
19 + * under the terms of the GNU General Public License as published by the
20 + * Free Software Foundation; either version 2 of the License, or (at your
21 + * option) any later version.
22 + */
23 +
24 +#include <bus.h>
25 +
26 +static int bcm47xx_sflash_bcma_read(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf)
27 +{
28 + return bcma_sflash_read(dev->bcc, offset, len, buf);
29 +}
30 +
31 +static int bcm47xx_sflash_bcma_poll(struct bcm47xx_sflash *dev, u32 offset)
32 +{
33 + return bcma_sflash_poll(dev->bcc, offset);
34 +}
35 +
36 +static int bcm47xx_sflash_bcma_write(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf)
37 +{
38 + return bcma_sflash_write(dev->bcc, offset, len, buf);
39 +}
40 +
41 +static int bcm47xx_sflash_bcma_erase(struct bcm47xx_sflash *dev, u32 offset)
42 +{
43 + return bcma_sflash_erase(dev->bcc, offset);
44 +}
45 +
46 +void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc)
47 +{
48 + sflash->sflash_type = BCM47XX_BUS_TYPE_BCMA;
49 + sflash->bcc = bcc;
50 +
51 + sflash->read = bcm47xx_sflash_bcma_read;
52 + sflash->poll = bcm47xx_sflash_bcma_poll;
53 + sflash->write = bcm47xx_sflash_bcma_write;
54 + sflash->erase = bcm47xx_sflash_bcma_erase;
55 +
56 + sflash->blocksize = bcc->sflash.blocksize;
57 + sflash->numblocks = bcc->sflash.numblocks;
58 + sflash->size = bcc->sflash.size;
59 +}
60 +
61 +static int bcm47xx_sflash_ssb_read(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf)
62 +{
63 + return ssb_sflash_read(dev->scc, offset, len, buf);
64 +}
65 +
66 +static int bcm47xx_sflash_ssb_poll(struct bcm47xx_sflash *dev, u32 offset)
67 +{
68 + return ssb_sflash_poll(dev->scc, offset);
69 +}
70 +
71 +static int bcm47xx_sflash_ssb_write(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf)
72 +{
73 + return ssb_sflash_write(dev->scc, offset, len, buf);
74 +}
75 +
76 +static int bcm47xx_sflash_ssb_erase(struct bcm47xx_sflash *dev, u32 offset)
77 +{
78 + return ssb_sflash_erase(dev->scc, offset);
79 +}
80 +
81 +void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc)
82 +{
83 + sflash->sflash_type = BCM47XX_BUS_TYPE_SSB;
84 + sflash->scc = scc;
85 +
86 + sflash->read = bcm47xx_sflash_ssb_read;
87 + sflash->poll = bcm47xx_sflash_ssb_poll;
88 + sflash->write = bcm47xx_sflash_ssb_write;
89 + sflash->erase = bcm47xx_sflash_ssb_erase;
90 +
91 + sflash->blocksize = scc->sflash.blocksize;
92 + sflash->numblocks = scc->sflash.numblocks;
93 + sflash->size = scc->sflash.size;
94 +}
95 --- a/arch/mips/bcm47xx/setup.c
96 +++ b/arch/mips/bcm47xx/setup.c
97 @@ -43,6 +43,8 @@ EXPORT_SYMBOL(bcm47xx_bus);
98 enum bcm47xx_bus_type bcm47xx_bus_type;
99 EXPORT_SYMBOL(bcm47xx_bus_type);
100
101 +struct bcm47xx_sflash bcm47xx_sflash;
102 +
103 static void bcm47xx_machine_restart(char *command)
104 {
105 printk(KERN_ALERT "Please stand by while rebooting the system...\n");
106 @@ -291,6 +293,9 @@ static void __init bcm47xx_register_ssb(
107 if (err)
108 panic("Failed to initialize SSB bus (err %d)", err);
109
110 + if (bcm47xx_bus.ssb.chipco.flash_type == SSB_SFLASH)
111 + bcm47xx_sflash_struct_ssb_init(&bcm47xx_sflash, &bcm47xx_bus.ssb.chipco);
112 +
113 mcore = &bcm47xx_bus.ssb.mipscore;
114 if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
115 if (strstr(buf, "console=ttyS1")) {
116 @@ -315,6 +320,9 @@ static void __init bcm47xx_register_bcma
117 err = bcma_host_soc_register(&bcm47xx_bus.bcma);
118 if (err)
119 panic("Failed to initialize BCMA bus (err %d)", err);
120 +
121 + if (bcm47xx_bus.bcma.bus.drv_cc.flash_type == BCMA_SFLASH)
122 + bcm47xx_sflash_struct_bcma_init(&bcm47xx_sflash, &bcm47xx_bus.bcma.bus.drv_cc);
123 }
124 #endif
125
126 --- /dev/null
127 +++ b/arch/mips/include/asm/mach-bcm47xx/bus.h
128 @@ -0,0 +1,36 @@
129 +/*
130 + * BCM947xx nvram variable access
131 + *
132 + * Copyright (C) 2011 Hauke Mehrtens <hauke@hauke-m.de>
133 + *
134 + * This program is free software; you can redistribute it and/or modify it
135 + * under the terms of the GNU General Public License as published by the
136 + * Free Software Foundation; either version 2 of the License, or (at your
137 + * option) any later version.
138 + */
139 +
140 +#include <linux/ssb/ssb.h>
141 +#include <linux/bcma/bcma.h>
142 +#include <bcm47xx.h>
143 +
144 +struct bcm47xx_sflash {
145 + enum bcm47xx_bus_type sflash_type;
146 + union {
147 + struct ssb_chipcommon *scc;
148 + struct bcma_drv_cc *bcc;
149 + };
150 +
151 + int (*read)(struct bcm47xx_sflash *dev, u32 offset, u32 len, u8 *buf);
152 + int (*poll)(struct bcm47xx_sflash *dev, u32 offset);
153 + int (*write)(struct bcm47xx_sflash *dev, u32 offset, u32 len, const u8 *buf);
154 + int (*erase)(struct bcm47xx_sflash *dev, u32 offset);
155 +
156 + u32 blocksize; /* Block size */
157 + u32 numblocks; /* Number of blocks */
158 + u32 size; /* Total size in bytes */
159 +};
160 +
161 +void bcm47xx_sflash_struct_bcma_init(struct bcm47xx_sflash *sflash, struct bcma_drv_cc *bcc);
162 +void bcm47xx_sflash_struct_ssb_init(struct bcm47xx_sflash *sflash, struct ssb_chipcommon *scc);
163 +
164 +extern struct bcm47xx_sflash bcm47xx_sflash;