1 From a1bf12e78294c6cd3d8747e1e07c48977ca1e3e3 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sat, 11 Jun 2011 16:47:38 +0200
4 Subject: [PATCH 01/26] bcma: move parsing of EEPROM into own function.
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Move the parsing of the EEPROM data in scan function for one core into
10 an own function. Now we are able to use it in some other scan function
13 Acked-by: Rafał Miłecki <zajec5@gmail.com>
14 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
16 drivers/bcma/scan.c | 230 ++++++++++++++++++++++++++-------------------------
17 1 files changed, 118 insertions(+), 112 deletions(-)
19 --- a/drivers/bcma/scan.c
20 +++ b/drivers/bcma/scan.c
21 @@ -200,16 +200,124 @@ static s32 bcma_erom_get_addr_desc(struc
25 +static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
26 + struct bcma_device *core)
31 + u8 ports[2], wrappers[2];
34 + cia = bcma_erom_get_ci(bus, eromptr);
36 + bcma_erom_push_ent(eromptr);
37 + if (bcma_erom_is_end(bus, eromptr))
41 + cib = bcma_erom_get_ci(bus, eromptr);
46 + core->id.class = (cia & SCAN_CIA_CLASS) >> SCAN_CIA_CLASS_SHIFT;
47 + core->id.id = (cia & SCAN_CIA_ID) >> SCAN_CIA_ID_SHIFT;
48 + core->id.manuf = (cia & SCAN_CIA_MANUF) >> SCAN_CIA_MANUF_SHIFT;
49 + ports[0] = (cib & SCAN_CIB_NMP) >> SCAN_CIB_NMP_SHIFT;
50 + ports[1] = (cib & SCAN_CIB_NSP) >> SCAN_CIB_NSP_SHIFT;
51 + wrappers[0] = (cib & SCAN_CIB_NMW) >> SCAN_CIB_NMW_SHIFT;
52 + wrappers[1] = (cib & SCAN_CIB_NSW) >> SCAN_CIB_NSW_SHIFT;
53 + core->id.rev = (cib & SCAN_CIB_REV) >> SCAN_CIB_REV_SHIFT;
55 + if (((core->id.manuf == BCMA_MANUF_ARM) &&
56 + (core->id.id == 0xFFF)) ||
58 + bcma_erom_skip_component(bus, eromptr);
62 + /* check if component is a core at all */
63 + if (wrappers[0] + wrappers[1] == 0) {
64 + /* we could save addrl of the router
65 + if (cid == BCMA_CORE_OOB_ROUTER)
67 + bcma_erom_skip_component(bus, eromptr);
71 + if (bcma_erom_is_bridge(bus, eromptr)) {
72 + bcma_erom_skip_component(bus, eromptr);
76 + /* get & parse master ports */
77 + for (i = 0; i < ports[0]; i++) {
78 + u32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
83 + /* get & parse slave ports */
84 + for (i = 0; i < ports[1]; i++) {
85 + for (j = 0; ; j++) {
86 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
87 + SCAN_ADDR_TYPE_SLAVE, i);
89 + /* no more entries for port _i_ */
90 + /* pr_debug("erom: slave port %d "
91 + * "has %d descriptors\n", i, j); */
94 + if (i == 0 && j == 0)
100 + /* get & parse master wrappers */
101 + for (i = 0; i < wrappers[0]; i++) {
102 + for (j = 0; ; j++) {
103 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
104 + SCAN_ADDR_TYPE_MWRAP, i);
106 + /* no more entries for port _i_ */
107 + /* pr_debug("erom: master wrapper %d "
108 + * "has %d descriptors\n", i, j); */
111 + if (i == 0 && j == 0)
117 + /* get & parse slave wrappers */
118 + for (i = 0; i < wrappers[1]; i++) {
119 + u8 hack = (ports[1] == 1) ? 0 : 1;
120 + for (j = 0; ; j++) {
121 + tmp = bcma_erom_get_addr_desc(bus, eromptr,
122 + SCAN_ADDR_TYPE_SWRAP, i + hack);
124 + /* no more entries for port _i_ */
125 + /* pr_debug("erom: master wrapper %d "
126 + * has %d descriptors\n", i, j); */
129 + if (wrappers[0] == 0 && !i && !j)
137 int bcma_bus_scan(struct bcma_bus *bus)
140 u32 __iomem *eromptr, *eromend;
143 - u8 ports[2], wrappers[2];
150 @@ -236,112 +344,13 @@ int bcma_bus_scan(struct bcma_bus *bus)
151 INIT_LIST_HEAD(&core->list);
155 - cia = bcma_erom_get_ci(bus, &eromptr);
157 - bcma_erom_push_ent(&eromptr);
158 - if (bcma_erom_is_end(bus, &eromptr))
163 - cib = bcma_erom_get_ci(bus, &eromptr);
170 - core->id.class = (cia & SCAN_CIA_CLASS) >> SCAN_CIA_CLASS_SHIFT;
171 - core->id.id = (cia & SCAN_CIA_ID) >> SCAN_CIA_ID_SHIFT;
172 - core->id.manuf = (cia & SCAN_CIA_MANUF) >> SCAN_CIA_MANUF_SHIFT;
173 - ports[0] = (cib & SCAN_CIB_NMP) >> SCAN_CIB_NMP_SHIFT;
174 - ports[1] = (cib & SCAN_CIB_NSP) >> SCAN_CIB_NSP_SHIFT;
175 - wrappers[0] = (cib & SCAN_CIB_NMW) >> SCAN_CIB_NMW_SHIFT;
176 - wrappers[1] = (cib & SCAN_CIB_NSW) >> SCAN_CIB_NSW_SHIFT;
177 - core->id.rev = (cib & SCAN_CIB_REV) >> SCAN_CIB_REV_SHIFT;
179 - if (((core->id.manuf == BCMA_MANUF_ARM) &&
180 - (core->id.id == 0xFFF)) ||
182 - bcma_erom_skip_component(bus, &eromptr);
183 + err = bcma_get_next_core(bus, &eromptr, core);
188 - /* check if component is a core at all */
189 - if (wrappers[0] + wrappers[1] == 0) {
190 - /* we could save addrl of the router
191 - if (cid == BCMA_CORE_OOB_ROUTER)
193 - bcma_erom_skip_component(bus, &eromptr);
197 - if (bcma_erom_is_bridge(bus, &eromptr)) {
198 - bcma_erom_skip_component(bus, &eromptr);
202 - /* get & parse master ports */
203 - for (i = 0; i < ports[0]; i++) {
204 - u32 mst_port_d = bcma_erom_get_mst_port(bus, &eromptr);
205 - if (mst_port_d < 0) {
211 - /* get & parse slave ports */
212 - for (i = 0; i < ports[1]; i++) {
213 - for (j = 0; ; j++) {
214 - tmp = bcma_erom_get_addr_desc(bus, &eromptr,
215 - SCAN_ADDR_TYPE_SLAVE, i);
217 - /* no more entries for port _i_ */
218 - /* pr_debug("erom: slave port %d "
219 - * "has %d descriptors\n", i, j); */
222 - if (i == 0 && j == 0)
228 - /* get & parse master wrappers */
229 - for (i = 0; i < wrappers[0]; i++) {
230 - for (j = 0; ; j++) {
231 - tmp = bcma_erom_get_addr_desc(bus, &eromptr,
232 - SCAN_ADDR_TYPE_MWRAP, i);
234 - /* no more entries for port _i_ */
235 - /* pr_debug("erom: master wrapper %d "
236 - * "has %d descriptors\n", i, j); */
239 - if (i == 0 && j == 0)
245 - /* get & parse slave wrappers */
246 - for (i = 0; i < wrappers[1]; i++) {
247 - u8 hack = (ports[1] == 1) ? 0 : 1;
248 - for (j = 0; ; j++) {
249 - tmp = bcma_erom_get_addr_desc(bus, &eromptr,
250 - SCAN_ADDR_TYPE_SWRAP, i + hack);
252 - /* no more entries for port _i_ */
253 - /* pr_debug("erom: master wrapper %d "
254 - * has %d descriptors\n", i, j); */
257 - if (wrappers[0] == 0 && !i && !j)
262 + else if (err == -ESPIPE)
267 pr_info("Core %d found: %s "
268 "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
269 @@ -351,9 +360,6 @@ int bcma_bus_scan(struct bcma_bus *bus)
271 core->core_index = bus->nr_cores++;
272 list_add(&core->list, &bus->cores);