6 struct hostap_interface *iface;
9 iface = netdev_priv(dev);
14 PDEBUG(DEBUG_EXTRA2,
"%s: no PRI f/w - assuming Aux "
15 "port is already enabled\n", dev->
name);
30 spin_unlock_irqrestore(&local->cmdlock, flags);
31 printk(
"%s: prism2_enable_aux_port - timeout - reg=0x%04x\n",
44 printk(
"prism2_enable_aux_port: was not disabled!?\n");
45 val &= ~HFA384X_AUX_PORT_MASK;
53 printk(
"prism2_enable_aux_port: was not enabled!?\n");
54 val &= ~HFA384X_AUX_PORT_MASK;
74 spin_unlock_irqrestore(&local->cmdlock, flags);
77 printk(
"prism2_enable_aux_port(%d) timed out\n",
86 static int hfa384x_from_aux(
struct net_device *dev,
unsigned int addr,
int len,
90 if (addr & 1 || len & 1)
117 static int hfa384x_to_aux(
struct net_device *dev,
unsigned int addr,
int len,
121 if (addr & 1 || len & 1)
125 offset = addr & 0x7f;
148 static int prism2_pda_ok(
u8 *buf)
154 if (buf[0] == 0xff && buf[1] == 0x00 && buf[2] == 0xff &&
165 if (pdr == 0x0000 && len == 2) {
177 static int prism2_download_aux_dump(
struct net_device *dev,
178 unsigned int addr,
int len,
u8 *buf)
182 prism2_enable_aux_port(dev, 1);
183 res = hfa384x_from_aux(dev, addr, len, buf);
184 prism2_enable_aux_port(dev, 0);
195 int res,
i, found = 0;
196 #define NUM_PDA_ADDRS 4
211 prism2_enable_aux_port(dev, 1);
214 PDEBUG(DEBUG_EXTRA2,
"%s: trying to read PDA from 0x%08x",
215 dev->
name, pda_addr[i]);
219 if (res == 0 && prism2_pda_ok(buf)) {
220 PDEBUG2(DEBUG_EXTRA2,
": OK\n");
224 PDEBUG2(DEBUG_EXTRA2,
": failed\n");
228 prism2_enable_aux_port(dev, 0);
240 static int prism2_download_volatile(
local_info_t *local,
241 struct prism2_download_data *
param)
247 if (local->hw_downloading) {
249 "request\n", dev->
name);
253 local->hw_downloading = 1;
254 if (local->pri_only) {
255 hfa384x_disable_interrupts(dev);
257 prism2_hw_shutdown(dev, 0);
259 if (prism2_hw_init(dev, 0)) {
261 " download\n", dev->
name);
267 if (prism2_enable_aux_port(dev, 1)) {
274 param0 = param->start_addr & 0xffff;
275 param1 = param->start_addr >> 16;
288 for (i = 0; i < param->num_areas; i++) {
289 PDEBUG(DEBUG_EXTRA2,
"%s: Writing %d bytes at 0x%08x\n",
290 dev->
name, param->data[i].len, param->data[i].addr);
291 if (hfa384x_to_aux(dev, param->data[i].addr,
292 param->data[i].len, param->data[i].data)) {
294 "(len=%d) failed\n", dev->
name,
295 param->data[i].addr, param->data[i].len);
316 if (prism2_enable_aux_port(dev, 0)) {
323 local->hw_downloading = 0;
324 if (prism2_hw_config(dev, 2)) {
326 "download failed\n", dev->
name);
332 local->hw_downloading = 0;
337 static int prism2_enable_genesis(
local_info_t *local,
int hcr)
340 u8 initseq[4] = { 0x00, 0xe1, 0xa1, 0xff };
345 local->func->cor_sreset(local);
346 hfa384x_to_aux(dev, 0x7e0038,
sizeof(initseq), initseq);
347 local->func->genesis_reset(local, hcr);
350 hfa384x_from_aux(dev, 0x7e0038,
sizeof(readbuf), readbuf);
351 hfa384x_to_aux(dev, 0x7e0038,
sizeof(initseq), initseq);
352 hfa384x_from_aux(dev, 0x7e0038,
sizeof(readbuf), readbuf);
354 if (
memcmp(initseq, readbuf,
sizeof(initseq)) == 0) {
360 "write %02x %02x %02x %02x read %02x %02x %02x %02x\n",
361 hcr, initseq[0], initseq[1], initseq[2], initseq[3],
362 readbuf[0], readbuf[1], readbuf[2], readbuf[3]);
373 if (prism2_enable_genesis(local, 0x1f) == 0)
375 else if (prism2_enable_genesis(local, 0x0f) == 0)
381 local->func->genesis_reset(local, ret == 16 ? 0x07 : 0x17);
388 struct prism2_download_data *param)
394 if (local->hw_downloading) {
396 "request\n", dev->
name);
400 if (!local->func->genesis_reset || !local->func->cor_sreset) {
402 "with this hwmodel\n", dev->
name);
406 local->hw_downloading = 1;
408 if (prism2_enable_aux_port(dev, 1)) {
415 if (local->sram_type == -1) {
417 if (prism2_enable_genesis(local, 0x1f) == 0) {
419 PDEBUG(DEBUG_EXTRA2,
"%s: Genesis mode OK using x8 "
420 "SRAM\n", dev->
name);
421 }
else if (prism2_enable_genesis(local, 0x0f) == 0) {
423 PDEBUG(DEBUG_EXTRA2,
"%s: Genesis mode OK using x16 "
424 "SRAM\n", dev->
name);
427 "mode\n", dev->
name);
432 if (prism2_enable_genesis(local, local->sram_type == 8 ?
435 "mode (sram_type=%d)\n", dev->
name,
440 ram16 = local->sram_type != 8;
443 for (i = 0; i < param->num_areas; i++) {
444 PDEBUG(DEBUG_EXTRA2,
"%s: Writing %d bytes at 0x%08x\n",
445 dev->
name, param->data[i].len, param->data[i].addr);
446 if (hfa384x_to_aux(dev, param->data[i].addr,
447 param->data[i].len, param->data[i].data)) {
449 "(len=%d) failed\n", dev->
name,
450 param->data[i].addr, param->data[i].len);
456 PDEBUG(DEBUG_EXTRA2,
"Disable genesis mode\n");
457 local->func->genesis_reset(local, ram16 ? 0x07 : 0x17);
458 if (prism2_enable_aux_port(dev, 0)) {
464 local->hw_downloading = 0;
466 PDEBUG(DEBUG_EXTRA2,
"Trying to initialize card\n");
471 hfa384x_disable_interrupts(dev);
472 if (prism2_hw_init(dev, 1)) {
474 "download failed\n", dev->
name);
479 PDEBUG(DEBUG_EXTRA2,
"Card initialized - running PRI only\n");
480 if (prism2_hw_init2(dev, 1)) {
482 "download failed\n", dev->
name);
488 local->hw_downloading = 0;
493 #ifdef PRISM2_NON_VOLATILE_DOWNLOAD
498 static inline int prism2_download_block(
struct net_device *dev,
500 u32 bufaddr,
int rest_len)
505 block_len = rest_len < 4096 ? rest_len : 4096;
507 param0 = addr & 0xffff;
517 "failed\n", dev->
name);
521 if (hfa384x_to_aux(dev, bufaddr, block_len, data)) {
523 "(len=%d) failed\n", dev->
name, addr, block_len);
533 "failed\n", dev->
name);
541 static int prism2_download_nonvolatile(
local_info_t *local,
542 struct prism2_download_data *
dl)
553 if (local->hw_downloading) {
555 "request\n", dev->
name);
564 "parameters\n", dev->
name);
575 local->hw_downloading = 1;
577 if (!local->pri_only) {
578 prism2_hw_shutdown(dev, 0);
580 if (prism2_hw_init(dev, 0)) {
582 " download\n", dev->
name);
588 hfa384x_disable_interrupts(dev);
590 if (prism2_enable_aux_port(dev, 1)) {
598 for (i = 0; i < dl->num_areas; i++) {
599 int rest_len = dl->data[
i].len;
602 while (rest_len > 0) {
605 block_len = prism2_download_block(
606 dev, dl->data[i].addr + data_off,
607 dl->data[i].data + data_off, bufaddr,
615 rest_len -= block_len;
616 data_off += block_len;
630 if (prism2_enable_aux_port(dev, 0)) {
638 local->func->hw_reset(dev);
639 local->hw_downloading = 0;
640 if (prism2_hw_config(dev, 2)) {
642 "download failed\n", dev->
name);
646 "flash download\n", dev->
name);
650 local->hw_downloading = 0;
656 static void prism2_download_free_data(
struct prism2_download_data *dl)
663 for (i = 0; i < dl->num_areas; i++)
664 kfree(dl->data[i].data);
675 struct prism2_download_data *dl =
NULL;
686 dl = kzalloc(
sizeof(*dl) + param->
num_areas *
687 sizeof(
struct prism2_download_data_area),
GFP_KERNEL);
692 dl->dl_cmd = param->
dl_cmd;
697 " area %d: addr=0x%08x len=%d ptr=0x%p\n",
698 i, param->
data[i].addr, param->
data[i].len,
701 dl->data[
i].addr = param->
data[
i].addr;
702 dl->data[
i].len = param->
data[
i].len;
704 total_len += param->
data[
i].len;
712 if (dl->data[i].data ==
NULL) {
718 param->
data[i].len)) {
727 ret = prism2_download_volatile(local, dl);
731 ret = prism2_download_genesis(local, dl);
734 #ifdef PRISM2_NON_VOLATILE_DOWNLOAD
735 ret = prism2_download_nonvolatile(local, dl);
750 if (ret == 0 && dl &&
752 prism2_download_free_data(local->dl_pri);
754 }
else if (ret == 0 && dl &&
756 prism2_download_free_data(local->dl_sec);
759 prism2_download_free_data(dl);