Root/target/linux/brcm47xx/patches-3.0/0001-bcma-move-parsing-of-EEPROM-into-own-function.patch

1From c4fb5adbe45b3a1cfc509a64bb92429ab0d6fc37 Mon Sep 17 00:00:00 2001
2From: Hauke Mehrtens <hauke@hauke-m.de>
3Date: Sat, 11 Jun 2011 16:47:38 +0200
4Subject: [PATCH 01/14] bcma: move parsing of EEPROM into own function.
5
6Move the parsing of the EEPROM data in scan function for one core into
7an own function. Now we are able to use it in some other scan function
8as well.
9
10Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
11---
12 drivers/bcma/scan.c | 230 ++++++++++++++++++++++++++-------------------------
13 1 files changed, 118 insertions(+), 112 deletions(-)
14
15--- a/drivers/bcma/scan.c
16+++ b/drivers/bcma/scan.c
17@@ -200,16 +200,124 @@ static s32 bcma_erom_get_addr_desc(struc
18     return addrl;
19 }
20 
21+static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
22+ struct bcma_device *core)
23+{
24+ s32 tmp;
25+ u8 i, j;
26+ s32 cia, cib;
27+ u8 ports[2], wrappers[2];
28+
29+ /* get CIs */
30+ cia = bcma_erom_get_ci(bus, eromptr);
31+ if (cia < 0) {
32+ bcma_erom_push_ent(eromptr);
33+ if (bcma_erom_is_end(bus, eromptr))
34+ return -ESPIPE;
35+ return -EILSEQ;
36+ }
37+ cib = bcma_erom_get_ci(bus, eromptr);
38+ if (cib < 0)
39+ return -EILSEQ;
40+
41+ /* parse CIs */
42+ core->id.class = (cia & SCAN_CIA_CLASS) >> SCAN_CIA_CLASS_SHIFT;
43+ core->id.id = (cia & SCAN_CIA_ID) >> SCAN_CIA_ID_SHIFT;
44+ core->id.manuf = (cia & SCAN_CIA_MANUF) >> SCAN_CIA_MANUF_SHIFT;
45+ ports[0] = (cib & SCAN_CIB_NMP) >> SCAN_CIB_NMP_SHIFT;
46+ ports[1] = (cib & SCAN_CIB_NSP) >> SCAN_CIB_NSP_SHIFT;
47+ wrappers[0] = (cib & SCAN_CIB_NMW) >> SCAN_CIB_NMW_SHIFT;
48+ wrappers[1] = (cib & SCAN_CIB_NSW) >> SCAN_CIB_NSW_SHIFT;
49+ core->id.rev = (cib & SCAN_CIB_REV) >> SCAN_CIB_REV_SHIFT;
50+
51+ if (((core->id.manuf == BCMA_MANUF_ARM) &&
52+ (core->id.id == 0xFFF)) ||
53+ (ports[1] == 0)) {
54+ bcma_erom_skip_component(bus, eromptr);
55+ return -ENXIO;
56+ }
57+
58+ /* check if component is a core at all */
59+ if (wrappers[0] + wrappers[1] == 0) {
60+ /* we could save addrl of the router
61+ if (cid == BCMA_CORE_OOB_ROUTER)
62+ */
63+ bcma_erom_skip_component(bus, eromptr);
64+ return -ENXIO;
65+ }
66+
67+ if (bcma_erom_is_bridge(bus, eromptr)) {
68+ bcma_erom_skip_component(bus, eromptr);
69+ return -ENXIO;
70+ }
71+
72+ /* get & parse master ports */
73+ for (i = 0; i < ports[0]; i++) {
74+ u32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
75+ if (mst_port_d < 0)
76+ return -EILSEQ;
77+ }
78+
79+ /* get & parse slave ports */
80+ for (i = 0; i < ports[1]; i++) {
81+ for (j = 0; ; j++) {
82+ tmp = bcma_erom_get_addr_desc(bus, eromptr,
83+ SCAN_ADDR_TYPE_SLAVE, i);
84+ if (tmp < 0) {
85+ /* no more entries for port _i_ */
86+ /* pr_debug("erom: slave port %d "
87+ * "has %d descriptors\n", i, j); */
88+ break;
89+ } else {
90+ if (i == 0 && j == 0)
91+ core->addr = tmp;
92+ }
93+ }
94+ }
95+
96+ /* get & parse master wrappers */
97+ for (i = 0; i < wrappers[0]; i++) {
98+ for (j = 0; ; j++) {
99+ tmp = bcma_erom_get_addr_desc(bus, eromptr,
100+ SCAN_ADDR_TYPE_MWRAP, i);
101+ if (tmp < 0) {
102+ /* no more entries for port _i_ */
103+ /* pr_debug("erom: master wrapper %d "
104+ * "has %d descriptors\n", i, j); */
105+ break;
106+ } else {
107+ if (i == 0 && j == 0)
108+ core->wrap = tmp;
109+ }
110+ }
111+ }
112+
113+ /* get & parse slave wrappers */
114+ for (i = 0; i < wrappers[1]; i++) {
115+ u8 hack = (ports[1] == 1) ? 0 : 1;
116+ for (j = 0; ; j++) {
117+ tmp = bcma_erom_get_addr_desc(bus, eromptr,
118+ SCAN_ADDR_TYPE_SWRAP, i + hack);
119+ if (tmp < 0) {
120+ /* no more entries for port _i_ */
121+ /* pr_debug("erom: master wrapper %d "
122+ * has %d descriptors\n", i, j); */
123+ break;
124+ } else {
125+ if (wrappers[0] == 0 && !i && !j)
126+ core->wrap = tmp;
127+ }
128+ }
129+ }
130+ return 0;
131+}
132+
133 int bcma_bus_scan(struct bcma_bus *bus)
134 {
135     u32 erombase;
136     u32 __iomem *eromptr, *eromend;
137 
138- s32 cia, cib;
139- u8 ports[2], wrappers[2];
140-
141     s32 tmp;
142- u8 i, j;
143 
144     int err;
145 
146@@ -236,112 +344,13 @@ int bcma_bus_scan(struct bcma_bus *bus)
147         INIT_LIST_HEAD(&core->list);
148         core->bus = bus;
149 
150- /* get CIs */
151- cia = bcma_erom_get_ci(bus, &eromptr);
152- if (cia < 0) {
153- bcma_erom_push_ent(&eromptr);
154- if (bcma_erom_is_end(bus, &eromptr))
155- break;
156- err= -EILSEQ;
157- goto out;
158- }
159- cib = bcma_erom_get_ci(bus, &eromptr);
160- if (cib < 0) {
161- err= -EILSEQ;
162- goto out;
163- }
164-
165- /* parse CIs */
166- core->id.class = (cia & SCAN_CIA_CLASS) >> SCAN_CIA_CLASS_SHIFT;
167- core->id.id = (cia & SCAN_CIA_ID) >> SCAN_CIA_ID_SHIFT;
168- core->id.manuf = (cia & SCAN_CIA_MANUF) >> SCAN_CIA_MANUF_SHIFT;
169- ports[0] = (cib & SCAN_CIB_NMP) >> SCAN_CIB_NMP_SHIFT;
170- ports[1] = (cib & SCAN_CIB_NSP) >> SCAN_CIB_NSP_SHIFT;
171- wrappers[0] = (cib & SCAN_CIB_NMW) >> SCAN_CIB_NMW_SHIFT;
172- wrappers[1] = (cib & SCAN_CIB_NSW) >> SCAN_CIB_NSW_SHIFT;
173- core->id.rev = (cib & SCAN_CIB_REV) >> SCAN_CIB_REV_SHIFT;
174-
175- if (((core->id.manuf == BCMA_MANUF_ARM) &&
176- (core->id.id == 0xFFF)) ||
177- (ports[1] == 0)) {
178- bcma_erom_skip_component(bus, &eromptr);
179+ err = bcma_get_next_core(bus, &eromptr, core);
180+ if (err == -ENXIO)
181             continue;
182- }
183-
184- /* check if component is a core at all */
185- if (wrappers[0] + wrappers[1] == 0) {
186- /* we could save addrl of the router
187- if (cid == BCMA_CORE_OOB_ROUTER)
188- */
189- bcma_erom_skip_component(bus, &eromptr);
190- continue;
191- }
192-
193- if (bcma_erom_is_bridge(bus, &eromptr)) {
194- bcma_erom_skip_component(bus, &eromptr);
195- continue;
196- }
197-
198- /* get & parse master ports */
199- for (i = 0; i < ports[0]; i++) {
200- u32 mst_port_d = bcma_erom_get_mst_port(bus, &eromptr);
201- if (mst_port_d < 0) {
202- err= -EILSEQ;
203- goto out;
204- }
205- }
206-
207- /* get & parse slave ports */
208- for (i = 0; i < ports[1]; i++) {
209- for (j = 0; ; j++) {
210- tmp = bcma_erom_get_addr_desc(bus, &eromptr,
211- SCAN_ADDR_TYPE_SLAVE, i);
212- if (tmp < 0) {
213- /* no more entries for port _i_ */
214- /* pr_debug("erom: slave port %d "
215- * "has %d descriptors\n", i, j); */
216- break;
217- } else {
218- if (i == 0 && j == 0)
219- core->addr = tmp;
220- }
221- }
222- }
223-
224- /* get & parse master wrappers */
225- for (i = 0; i < wrappers[0]; i++) {
226- for (j = 0; ; j++) {
227- tmp = bcma_erom_get_addr_desc(bus, &eromptr,
228- SCAN_ADDR_TYPE_MWRAP, i);
229- if (tmp < 0) {
230- /* no more entries for port _i_ */
231- /* pr_debug("erom: master wrapper %d "
232- * "has %d descriptors\n", i, j); */
233- break;
234- } else {
235- if (i == 0 && j == 0)
236- core->wrap = tmp;
237- }
238- }
239- }
240-
241- /* get & parse slave wrappers */
242- for (i = 0; i < wrappers[1]; i++) {
243- u8 hack = (ports[1] == 1) ? 0 : 1;
244- for (j = 0; ; j++) {
245- tmp = bcma_erom_get_addr_desc(bus, &eromptr,
246- SCAN_ADDR_TYPE_SWRAP, i + hack);
247- if (tmp < 0) {
248- /* no more entries for port _i_ */
249- /* pr_debug("erom: master wrapper %d "
250- * has %d descriptors\n", i, j); */
251- break;
252- } else {
253- if (wrappers[0] == 0 && !i && !j)
254- core->wrap = tmp;
255- }
256- }
257- }
258+ else if (err == -ESPIPE)
259+ break;
260+ else if (err < 0)
261+ return err;
262 
263         pr_info("Core %d found: %s "
264             "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
265@@ -351,9 +360,6 @@ int bcma_bus_scan(struct bcma_bus *bus)
266 
267         core->core_index = bus->nr_cores++;
268         list_add(&core->list, &bus->cores);
269- continue;
270-out:
271- return err;
272     }
273 
274     return 0;
275

Archive Download this file



interactive