aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl4965-base.c
diff options
context:
space:
mode:
authorAssaf Krauss <assaf.krauss@intel.com>2008-03-11 19:17:18 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-03-13 19:32:32 -0400
commit6bc913bd965e03b5273a5366eecce5c28c9b01da (patch)
treeebc5aee6b2eb48660ab555af62b4da0119bd8446 /drivers/net/wireless/iwlwifi/iwl4965-base.c
parenteb7ae89cb0b03e6e6e39737b1c8bcc1912281a00 (diff)
iwlwifi: Use eeprom form iwlcore
This patch puts in use eeprom from iwlcore module Signed-off-by: Assaf Krauss <assaf.krauss@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl4965-base.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl4965-base.c84
1 files changed, 3 insertions, 81 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c
index ce1c3f68fde0..d84a7f296d90 100644
--- a/drivers/net/wireless/iwlwifi/iwl4965-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c
@@ -45,6 +45,7 @@
45 45
46#include <asm/div64.h> 46#include <asm/div64.h>
47 47
48#include "iwl-eeprom.h"
48#include "iwl-core.h" 49#include "iwl-core.h"
49#include "iwl-4965.h" 50#include "iwl-4965.h"
50#include "iwl-helpers.h" 51#include "iwl-helpers.h"
@@ -1562,85 +1563,6 @@ static int iwl4965_send_beacon_cmd(struct iwl4965_priv *priv)
1562 1563
1563/****************************************************************************** 1564/******************************************************************************
1564 * 1565 *
1565 * EEPROM related functions
1566 *
1567 ******************************************************************************/
1568
1569static void get_eeprom_mac(struct iwl4965_priv *priv, u8 *mac)
1570{
1571 memcpy(mac, priv->eeprom.mac_address, 6);
1572}
1573
1574static inline void iwl4965_eeprom_release_semaphore(struct iwl4965_priv *priv)
1575{
1576 iwl4965_clear_bit(priv, CSR_HW_IF_CONFIG_REG,
1577 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
1578}
1579
1580/**
1581 * iwl4965_eeprom_init - read EEPROM contents
1582 *
1583 * Load the EEPROM contents from adapter into priv->eeprom
1584 *
1585 * NOTE: This routine uses the non-debug IO access functions.
1586 */
1587int iwl4965_eeprom_init(struct iwl4965_priv *priv)
1588{
1589 u16 *e = (u16 *)&priv->eeprom;
1590 u32 gp = iwl4965_read32(priv, CSR_EEPROM_GP);
1591 u32 r;
1592 int sz = sizeof(priv->eeprom);
1593 int rc;
1594 int i;
1595 u16 addr;
1596
1597 /* The EEPROM structure has several padding buffers within it
1598 * and when adding new EEPROM maps is subject to programmer errors
1599 * which may be very difficult to identify without explicitly
1600 * checking the resulting size of the eeprom map. */
1601 BUILD_BUG_ON(sizeof(priv->eeprom) != IWL_EEPROM_IMAGE_SIZE);
1602
1603 if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) {
1604 IWL_ERROR("EEPROM not found, EEPROM_GP=0x%08x", gp);
1605 return -ENOENT;
1606 }
1607
1608 /* Make sure driver (instead of uCode) is allowed to read EEPROM */
1609 rc = iwl4965_eeprom_acquire_semaphore(priv);
1610 if (rc < 0) {
1611 IWL_ERROR("Failed to acquire EEPROM semaphore.\n");
1612 return -ENOENT;
1613 }
1614
1615 /* eeprom is an array of 16bit values */
1616 for (addr = 0; addr < sz; addr += sizeof(u16)) {
1617 _iwl4965_write32(priv, CSR_EEPROM_REG, addr << 1);
1618 _iwl4965_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD);
1619
1620 for (i = 0; i < IWL_EEPROM_ACCESS_TIMEOUT;
1621 i += IWL_EEPROM_ACCESS_DELAY) {
1622 r = _iwl4965_read_direct32(priv, CSR_EEPROM_REG);
1623 if (r & CSR_EEPROM_REG_READ_VALID_MSK)
1624 break;
1625 udelay(IWL_EEPROM_ACCESS_DELAY);
1626 }
1627
1628 if (!(r & CSR_EEPROM_REG_READ_VALID_MSK)) {
1629 IWL_ERROR("Time out reading EEPROM[%d]", addr);
1630 rc = -ETIMEDOUT;
1631 goto done;
1632 }
1633 e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16));
1634 }
1635 rc = 0;
1636
1637done:
1638 iwl4965_eeprom_release_semaphore(priv);
1639 return rc;
1640}
1641
1642/******************************************************************************
1643 *
1644 * Misc. internal state and helper functions 1566 * Misc. internal state and helper functions
1645 * 1567 *
1646 ******************************************************************************/ 1568 ******************************************************************************/
@@ -8765,13 +8687,13 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
8765 goto out_remove_sysfs; 8687 goto out_remove_sysfs;
8766 } 8688 }
8767 /* Read the EEPROM */ 8689 /* Read the EEPROM */
8768 err = iwl4965_eeprom_init(priv); 8690 err = iwl_eeprom_init(priv);
8769 if (err) { 8691 if (err) {
8770 IWL_ERROR("Unable to init EEPROM\n"); 8692 IWL_ERROR("Unable to init EEPROM\n");
8771 goto out_remove_sysfs; 8693 goto out_remove_sysfs;
8772 } 8694 }
8773 /* MAC Address location in EEPROM same for 3945/4965 */ 8695 /* MAC Address location in EEPROM same for 3945/4965 */
8774 get_eeprom_mac(priv, priv->mac_addr); 8696 iwl_eeprom_get_mac(priv, priv->mac_addr);
8775 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); 8697 IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
8776 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 8698 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
8777 8699