1 From f3c07dd351161cb33f1c8e1ff55a65ae0cc6b661 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sat, 18 Jun 2011 14:30:55 +0200
4 Subject: [PATCH 03/26] bcma: add functions to scan cores needed on SoCs
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 The chip common and mips core have to be setup early in the boot
10 process to get the cpu clock.
11 bcma_bus_early_register() gets pointers to some space to store the core
12 data and searches for the chip common and mips core and initializes
13 chip common. After that was done and the kernel is out of early boot we
14 just have to run bcma_bus_register() and it will search for the other
15 cores, initialize and register them.
16 The cores are getting the same numbers as before.
18 Acked-by: Rafał Miłecki <zajec5@gmail.com>
19 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
21 drivers/bcma/bcma_private.h | 7 ++
22 drivers/bcma/driver_chipcommon.c | 5 ++
23 drivers/bcma/driver_pci.c | 5 ++
24 drivers/bcma/main.c | 46 +++++++++++++
25 drivers/bcma/scan.c | 95 +++++++++++++++++++++++++--
26 include/linux/bcma/bcma.h | 1 +
27 include/linux/bcma/bcma_driver_chipcommon.h | 1 +
28 7 files changed, 154 insertions(+), 6 deletions(-)
30 --- a/drivers/bcma/bcma_private.h
31 +++ b/drivers/bcma/bcma_private.h
32 @@ -15,9 +15,16 @@ struct bcma_bus;
34 int bcma_bus_register(struct bcma_bus *bus);
35 void bcma_bus_unregister(struct bcma_bus *bus);
36 +int __init bcma_bus_early_register(struct bcma_bus *bus,
37 + struct bcma_device *core_cc,
38 + struct bcma_device *core_mips);
41 int bcma_bus_scan(struct bcma_bus *bus);
42 +int __init bcma_bus_scan_early(struct bcma_bus *bus,
43 + struct bcma_device_id *match,
44 + struct bcma_device *core);
45 +void bcma_init_bus(struct bcma_bus *bus);
48 int bcma_sprom_get(struct bcma_bus *bus);
49 --- a/drivers/bcma/driver_chipcommon.c
50 +++ b/drivers/bcma/driver_chipcommon.c
51 @@ -26,6 +26,9 @@ void bcma_core_chipcommon_init(struct bc
58 if (cc->core->id.rev >= 11)
59 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
60 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
61 @@ -52,6 +55,8 @@ void bcma_core_chipcommon_init(struct bc
62 ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
63 (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
66 + cc->setup_done = true;
69 /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
70 --- a/drivers/bcma/driver_pci.c
71 +++ b/drivers/bcma/driver_pci.c
72 @@ -187,6 +187,9 @@ static bool bcma_core_pci_is_in_hostmode
74 void bcma_core_pci_init(struct bcma_drv_pci *pc)
79 if (bcma_core_pci_is_in_hostmode(pc)) {
80 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
81 bcma_core_pci_hostmode_init(pc);
82 @@ -196,6 +199,8 @@ void bcma_core_pci_init(struct bcma_drv_
84 bcma_core_pci_clientmode_init(pc);
87 + pc->setup_done = true;
90 int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
91 --- a/drivers/bcma/main.c
92 +++ b/drivers/bcma/main.c
93 @@ -169,6 +169,52 @@ void bcma_bus_unregister(struct bcma_bus
94 bcma_unregister_cores(bus);
97 +int __init bcma_bus_early_register(struct bcma_bus *bus,
98 + struct bcma_device *core_cc,
99 + struct bcma_device *core_mips)
102 + struct bcma_device *core;
103 + struct bcma_device_id match;
105 + bcma_init_bus(bus);
107 + match.manuf = BCMA_MANUF_BCM;
108 + match.id = BCMA_CORE_CHIPCOMMON;
109 + match.class = BCMA_CL_SIM;
110 + match.rev = BCMA_ANY_REV;
112 + /* Scan for chip common core */
113 + err = bcma_bus_scan_early(bus, &match, core_cc);
115 + pr_err("Failed to scan for common core: %d\n", err);
119 + match.manuf = BCMA_MANUF_MIPS;
120 + match.id = BCMA_CORE_MIPS_74K;
121 + match.class = BCMA_CL_SIM;
122 + match.rev = BCMA_ANY_REV;
124 + /* Scan for mips core */
125 + err = bcma_bus_scan_early(bus, &match, core_mips);
127 + pr_err("Failed to scan for mips core: %d\n", err);
132 + core = bcma_find_core(bus, BCMA_CORE_CHIPCOMMON);
134 + bus->drv_cc.core = core;
135 + bcma_core_chipcommon_init(&bus->drv_cc);
138 + pr_info("Early bus registered\n");
143 int __bcma_driver_register(struct bcma_driver *drv, struct module *owner)
145 drv->drv.name = drv->name;
146 --- a/drivers/bcma/scan.c
147 +++ b/drivers/bcma/scan.c
148 @@ -200,7 +200,20 @@ static s32 bcma_erom_get_addr_desc(struc
152 +static struct bcma_device *bcma_find_core_by_index(struct bcma_bus *bus,
155 + struct bcma_device *core;
157 + list_for_each_entry(core, &bus->cores, list) {
158 + if (core->core_index == index)
164 static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
165 + struct bcma_device_id *match, int core_num,
166 struct bcma_device *core)
169 @@ -251,6 +264,21 @@ static int bcma_get_next_core(struct bcm
173 + if (bcma_find_core_by_index(bus, core_num)) {
174 + bcma_erom_skip_component(bus, eromptr);
178 + if (match && ((match->manuf != BCMA_ANY_MANUF &&
179 + match->manuf != core->id.manuf) ||
180 + (match->id != BCMA_ANY_ID && match->id != core->id.id) ||
181 + (match->rev != BCMA_ANY_REV && match->rev != core->id.rev) ||
182 + (match->class != BCMA_ANY_CLASS && match->class != core->id.class)
184 + bcma_erom_skip_component(bus, eromptr);
188 /* get & parse master ports */
189 for (i = 0; i < ports[0]; i++) {
190 u32 mst_port_d = bcma_erom_get_mst_port(bus, eromptr);
191 @@ -312,10 +340,13 @@ static int bcma_get_next_core(struct bcm
195 -static void bcma_init_bus(struct bcma_bus *bus)
196 +void bcma_init_bus(struct bcma_bus *bus)
200 + if (bus->init_done)
203 INIT_LIST_HEAD(&bus->cores);
206 @@ -325,6 +356,7 @@ static void bcma_init_bus(struct bcma_bu
207 bus->chipinfo.id = (tmp & BCMA_CC_ID_ID) >> BCMA_CC_ID_ID_SHIFT;
208 bus->chipinfo.rev = (tmp & BCMA_CC_ID_REV) >> BCMA_CC_ID_REV_SHIFT;
209 bus->chipinfo.pkg = (tmp & BCMA_CC_ID_PKG) >> BCMA_CC_ID_PKG_SHIFT;
210 + bus->init_done = true;
213 int bcma_bus_scan(struct bcma_bus *bus)
214 @@ -332,7 +364,7 @@ int bcma_bus_scan(struct bcma_bus *bus)
216 u32 __iomem *eromptr, *eromend;
219 + int err, core_num = 0;
223 @@ -349,23 +381,74 @@ int bcma_bus_scan(struct bcma_bus *bus)
224 INIT_LIST_HEAD(&core->list);
227 - err = bcma_get_next_core(bus, &eromptr, core);
229 + err = bcma_get_next_core(bus, &eromptr, NULL, core_num, core);
230 + if (err == -ENODEV) {
233 + } else if (err == -ENXIO)
235 else if (err == -ESPIPE)
240 + core->core_index = core_num++;
243 pr_info("Core %d found: %s "
244 "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
245 - bus->nr_cores, bcma_device_name(&core->id),
246 + core->core_index, bcma_device_name(&core->id),
247 core->id.manuf, core->id.id, core->id.rev,
250 - core->core_index = bus->nr_cores++;
251 list_add(&core->list, &bus->cores);
257 +int __init bcma_bus_scan_early(struct bcma_bus *bus,
258 + struct bcma_device_id *match,
259 + struct bcma_device *core)
262 + u32 __iomem *eromptr, *eromend;
264 + int err, core_num = 0;
266 + erombase = bcma_scan_read32(bus, 0, BCMA_CC_EROM);
267 + eromptr = bus->mmio;
268 + eromend = eromptr + BCMA_CORE_SIZE / sizeof(u32);
270 + bcma_scan_switch_core(bus, erombase);
272 + while (eromptr < eromend) {
273 + memset(core, 0, sizeof(*core));
274 + INIT_LIST_HEAD(&core->list);
277 + err = bcma_get_next_core(bus, &eromptr, match, core_num, core);
278 + if (err == -ENODEV) {
281 + } else if (err == -ENXIO)
283 + else if (err == -ESPIPE)
288 + core->core_index = core_num++;
290 + pr_info("Core %d found: %s "
291 + "(manuf 0x%03X, id 0x%03X, rev 0x%02X, class 0x%X)\n",
292 + core->core_index, bcma_device_name(&core->id),
293 + core->id.manuf, core->id.id, core->id.rev,
296 + list_add(&core->list, &bus->cores);
302 --- a/include/linux/bcma/bcma.h
303 +++ b/include/linux/bcma/bcma.h
304 @@ -190,6 +190,7 @@ struct bcma_bus {
305 struct bcma_device *mapped_core;
306 struct list_head cores;
310 struct bcma_drv_cc drv_cc;
311 struct bcma_drv_pci drv_pci;
312 --- a/include/linux/bcma/bcma_driver_chipcommon.h
313 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
314 @@ -252,6 +252,7 @@ struct bcma_drv_cc {
317 u32 capabilities_ext;
319 /* Fast Powerup Delay constant */
320 u16 fast_pwrup_delay;
321 struct bcma_chipcommon_pmu pmu;