aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorWey-Yi Guy <wey-yi.w.guy@intel.com>2010-05-10 17:15:25 -0400
committerReinette Chatre <reinette.chatre@intel.com>2010-05-13 13:45:36 -0400
commitdb41dd27a079ec498fab9dc788094375ea0d1761 (patch)
treea4a6d4645b252f0376dfa129ba5664f3d7c58908 /drivers/net
parentc213d745b25b24b68f790fe55fc0a2159218a079 (diff)
iwlwifi: move ucode related function to iwl-agn-ucode.c
Cleanup the code and move all the uCode related functions specific to _agn devices to iwl-agn-ucode.c Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c123
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c124
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h1
4 files changed, 124 insertions, 125 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index 637286c396fe..6f77441cb65a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -423,3 +423,126 @@ int iwlagn_alive_notify(struct iwl_priv *priv)
423 423
424 return 0; 424 return 0;
425} 425}
426
427
428/**
429 * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host,
430 * using sample data 100 bytes apart. If these sample points are good,
431 * it's a pretty good bet that everything between them is good, too.
432 */
433static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len)
434{
435 u32 val;
436 int ret = 0;
437 u32 errcnt = 0;
438 u32 i;
439
440 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
441
442 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
443 /* read data comes through single port, auto-incr addr */
444 /* NOTE: Use the debugless read so we don't flood kernel log
445 * if IWL_DL_IO is set */
446 iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR,
447 i + IWLAGN_RTC_INST_LOWER_BOUND);
448 val = _iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
449 if (val != le32_to_cpu(*image)) {
450 ret = -EIO;
451 errcnt++;
452 if (errcnt >= 3)
453 break;
454 }
455 }
456
457 return ret;
458}
459
460/**
461 * iwlcore_verify_inst_full - verify runtime uCode image in card vs. host,
462 * looking at all data.
463 */
464static int iwl_verify_inst_full(struct iwl_priv *priv, __le32 *image,
465 u32 len)
466{
467 u32 val;
468 u32 save_len = len;
469 int ret = 0;
470 u32 errcnt;
471
472 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
473
474 iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR,
475 IWLAGN_RTC_INST_LOWER_BOUND);
476
477 errcnt = 0;
478 for (; len > 0; len -= sizeof(u32), image++) {
479 /* read data comes through single port, auto-incr addr */
480 /* NOTE: Use the debugless read so we don't flood kernel log
481 * if IWL_DL_IO is set */
482 val = _iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
483 if (val != le32_to_cpu(*image)) {
484 IWL_ERR(priv, "uCode INST section is invalid at "
485 "offset 0x%x, is 0x%x, s/b 0x%x\n",
486 save_len - len, val, le32_to_cpu(*image));
487 ret = -EIO;
488 errcnt++;
489 if (errcnt >= 20)
490 break;
491 }
492 }
493
494 if (!errcnt)
495 IWL_DEBUG_INFO(priv,
496 "ucode image in INSTRUCTION memory is good\n");
497
498 return ret;
499}
500
501/**
502 * iwl_verify_ucode - determine which instruction image is in SRAM,
503 * and verify its contents
504 */
505int iwl_verify_ucode(struct iwl_priv *priv)
506{
507 __le32 *image;
508 u32 len;
509 int ret;
510
511 /* Try bootstrap */
512 image = (__le32 *)priv->ucode_boot.v_addr;
513 len = priv->ucode_boot.len;
514 ret = iwlcore_verify_inst_sparse(priv, image, len);
515 if (!ret) {
516 IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n");
517 return 0;
518 }
519
520 /* Try initialize */
521 image = (__le32 *)priv->ucode_init.v_addr;
522 len = priv->ucode_init.len;
523 ret = iwlcore_verify_inst_sparse(priv, image, len);
524 if (!ret) {
525 IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n");
526 return 0;
527 }
528
529 /* Try runtime/protocol */
530 image = (__le32 *)priv->ucode_code.v_addr;
531 len = priv->ucode_code.len;
532 ret = iwlcore_verify_inst_sparse(priv, image, len);
533 if (!ret) {
534 IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n");
535 return 0;
536 }
537
538 IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
539
540 /* Since nothing seems to match, show first several data entries in
541 * instruction SRAM, so maybe visual inspection will give a clue.
542 * Selection of bootstrap image (vs. other images) is arbitrary. */
543 image = (__le32 *)priv->ucode_boot.v_addr;
544 len = priv->ucode_boot.len;
545 ret = iwl_verify_inst_full(priv, image, len);
546
547 return ret;
548}
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 2ebbe811ddab..f7ef8939cd26 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -130,6 +130,7 @@ void iwlagn_rx_calib_complete(struct iwl_priv *priv,
130 struct iwl_rx_mem_buffer *rxb); 130 struct iwl_rx_mem_buffer *rxb);
131void iwlagn_init_alive_start(struct iwl_priv *priv); 131void iwlagn_init_alive_start(struct iwl_priv *priv);
132int iwlagn_alive_notify(struct iwl_priv *priv); 132int iwlagn_alive_notify(struct iwl_priv *priv);
133int iwl_verify_ucode(struct iwl_priv *priv);
133 134
134/* lib */ 135/* lib */
135void iwl_check_abort_status(struct iwl_priv *priv, 136void iwl_check_abort_status(struct iwl_priv *priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 10ce00854af4..4a50c042e54e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1460,130 +1460,6 @@ int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear)
1460} 1460}
1461EXPORT_SYMBOL(iwl_send_statistics_request); 1461EXPORT_SYMBOL(iwl_send_statistics_request);
1462 1462
1463/**
1464 * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host,
1465 * using sample data 100 bytes apart. If these sample points are good,
1466 * it's a pretty good bet that everything between them is good, too.
1467 */
1468static int iwlcore_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len)
1469{
1470 u32 val;
1471 int ret = 0;
1472 u32 errcnt = 0;
1473 u32 i;
1474
1475 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
1476
1477 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
1478 /* read data comes through single port, auto-incr addr */
1479 /* NOTE: Use the debugless read so we don't flood kernel log
1480 * if IWL_DL_IO is set */
1481 iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR,
1482 i + IWL49_RTC_INST_LOWER_BOUND);
1483 val = _iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
1484 if (val != le32_to_cpu(*image)) {
1485 ret = -EIO;
1486 errcnt++;
1487 if (errcnt >= 3)
1488 break;
1489 }
1490 }
1491
1492 return ret;
1493}
1494
1495/**
1496 * iwlcore_verify_inst_full - verify runtime uCode image in card vs. host,
1497 * looking at all data.
1498 */
1499static int iwl_verify_inst_full(struct iwl_priv *priv, __le32 *image,
1500 u32 len)
1501{
1502 u32 val;
1503 u32 save_len = len;
1504 int ret = 0;
1505 u32 errcnt;
1506
1507 IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len);
1508
1509 iwl_write_direct32(priv, HBUS_TARG_MEM_RADDR,
1510 IWL49_RTC_INST_LOWER_BOUND);
1511
1512 errcnt = 0;
1513 for (; len > 0; len -= sizeof(u32), image++) {
1514 /* read data comes through single port, auto-incr addr */
1515 /* NOTE: Use the debugless read so we don't flood kernel log
1516 * if IWL_DL_IO is set */
1517 val = _iwl_read_direct32(priv, HBUS_TARG_MEM_RDAT);
1518 if (val != le32_to_cpu(*image)) {
1519 IWL_ERR(priv, "uCode INST section is invalid at "
1520 "offset 0x%x, is 0x%x, s/b 0x%x\n",
1521 save_len - len, val, le32_to_cpu(*image));
1522 ret = -EIO;
1523 errcnt++;
1524 if (errcnt >= 20)
1525 break;
1526 }
1527 }
1528
1529 if (!errcnt)
1530 IWL_DEBUG_INFO(priv,
1531 "ucode image in INSTRUCTION memory is good\n");
1532
1533 return ret;
1534}
1535
1536/**
1537 * iwl_verify_ucode - determine which instruction image is in SRAM,
1538 * and verify its contents
1539 */
1540int iwl_verify_ucode(struct iwl_priv *priv)
1541{
1542 __le32 *image;
1543 u32 len;
1544 int ret;
1545
1546 /* Try bootstrap */
1547 image = (__le32 *)priv->ucode_boot.v_addr;
1548 len = priv->ucode_boot.len;
1549 ret = iwlcore_verify_inst_sparse(priv, image, len);
1550 if (!ret) {
1551 IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n");
1552 return 0;
1553 }
1554
1555 /* Try initialize */
1556 image = (__le32 *)priv->ucode_init.v_addr;
1557 len = priv->ucode_init.len;
1558 ret = iwlcore_verify_inst_sparse(priv, image, len);
1559 if (!ret) {
1560 IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n");
1561 return 0;
1562 }
1563
1564 /* Try runtime/protocol */
1565 image = (__le32 *)priv->ucode_code.v_addr;
1566 len = priv->ucode_code.len;
1567 ret = iwlcore_verify_inst_sparse(priv, image, len);
1568 if (!ret) {
1569 IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n");
1570 return 0;
1571 }
1572
1573 IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
1574
1575 /* Since nothing seems to match, show first several data entries in
1576 * instruction SRAM, so maybe visual inspection will give a clue.
1577 * Selection of bootstrap image (vs. other images) is arbitrary. */
1578 image = (__le32 *)priv->ucode_boot.v_addr;
1579 len = priv->ucode_boot.len;
1580 ret = iwl_verify_inst_full(priv, image, len);
1581
1582 return ret;
1583}
1584EXPORT_SYMBOL(iwl_verify_ucode);
1585
1586
1587void iwl_rf_kill_ct_config(struct iwl_priv *priv) 1463void iwl_rf_kill_ct_config(struct iwl_priv *priv)
1588{ 1464{
1589 struct iwl_ct_kill_config cmd; 1465 struct iwl_ct_kill_config cmd;
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 63229dcb8eb1..d3b61dc2c43e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -689,7 +689,6 @@ extern void iwl_rf_kill_ct_config(struct iwl_priv *priv);
689extern void iwl_send_bt_config(struct iwl_priv *priv); 689extern void iwl_send_bt_config(struct iwl_priv *priv);
690extern int iwl_send_statistics_request(struct iwl_priv *priv, 690extern int iwl_send_statistics_request(struct iwl_priv *priv,
691 u8 flags, bool clear); 691 u8 flags, bool clear);
692extern int iwl_verify_ucode(struct iwl_priv *priv);
693extern int iwl_send_lq_cmd(struct iwl_priv *priv, 692extern int iwl_send_lq_cmd(struct iwl_priv *priv,
694 struct iwl_link_quality_cmd *lq, u8 flags, bool init); 693 struct iwl_link_quality_cmd *lq, u8 flags, bool init);
695void iwl_apm_stop(struct iwl_priv *priv); 694void iwl_apm_stop(struct iwl_priv *priv);