1 From c4fb5adbe45b3a1cfc509a64bb92429ab0d6fc37 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/14] bcma: move parsing of EEPROM into own function.
6 Move the parsing of the EEPROM data in scan function for one core into
7 an own function. Now we are able to use it in some other scan function
10 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
12 drivers/bcma/scan.c | 230 ++++++++++++++++++++++++++-------------------------
13 1 files changed, 118 insertions(+), 112 deletions(-)
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
21 +static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
22 + struct bcma_device *core)
27 + u8 ports[2], wrappers[2];
30 + cia = bcma_erom_get_ci(bus, eromptr);
32 + bcma_erom_push_ent(eromptr);
33 + if (bcma_erom_is_end(bus, eromptr))
37 + cib = bcma_erom_get_ci(bus, eromptr);
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;
51 + if (((core->id.manuf == BCMA_MANUF_ARM) &&
52 + (core->id.id == 0xFFF)) ||
54 + bcma_erom_skip_component(bus, eromptr);
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)
63 + bcma_erom_skip_component(bus, eromptr);
67 + if (bcma_erom_is_bridge(bus, eromptr)) {
68 + bcma_erom_skip_component(bus, eromptr);
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);
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);
85 + /* no more entries for port _i_ */
86 + /* pr_debug("erom: slave port %d "
87 + * "has %d descriptors\n", i, j); */
90 + if (i == 0 && j == 0)
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);
102 + /* no more entries for port _i_ */
103 + /* pr_debug("erom: master wrapper %d "
104 + * "has %d descriptors\n", i, j); */
107 + if (i == 0 && j == 0)
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);
120 + /* no more entries for port _i_ */
121 + /* pr_debug("erom: master wrapper %d "
122 + * has %d descriptors\n", i, j); */
125 + if (wrappers[0] == 0 && !i && !j)
133 int bcma_bus_scan(struct bcma_bus *bus)
136 u32 __iomem *eromptr, *eromend;
139 - u8 ports[2], wrappers[2];
146 @@ -236,112 +344,13 @@ int bcma_bus_scan(struct bcma_bus *bus)
147 INIT_LIST_HEAD(&core->list);
151 - cia = bcma_erom_get_ci(bus, &eromptr);
153 - bcma_erom_push_ent(&eromptr);
154 - if (bcma_erom_is_end(bus, &eromptr))
159 - cib = bcma_erom_get_ci(bus, &eromptr);
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;
175 - if (((core->id.manuf == BCMA_MANUF_ARM) &&
176 - (core->id.id == 0xFFF)) ||
178 - bcma_erom_skip_component(bus, &eromptr);
179 + err = bcma_get_next_core(bus, &eromptr, core);
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)
189 - bcma_erom_skip_component(bus, &eromptr);
193 - if (bcma_erom_is_bridge(bus, &eromptr)) {
194 - bcma_erom_skip_component(bus, &eromptr);
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) {
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);
213 - /* no more entries for port _i_ */
214 - /* pr_debug("erom: slave port %d "
215 - * "has %d descriptors\n", i, j); */
218 - if (i == 0 && j == 0)
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);
230 - /* no more entries for port _i_ */
231 - /* pr_debug("erom: master wrapper %d "
232 - * "has %d descriptors\n", i, j); */
235 - if (i == 0 && j == 0)
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);
248 - /* no more entries for port _i_ */
249 - /* pr_debug("erom: master wrapper %d "
250 - * has %d descriptors\n", i, j); */
253 - if (wrappers[0] == 0 && !i && !j)
258 + else if (err == -ESPIPE)
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)
267 core->core_index = bus->nr_cores++;
268 list_add(&core->list, &bus->cores);