diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2011-08-30 06:45:25 -0400 |
---|---|---|
committer | Stanislaw Gruszka <sgruszka@redhat.com> | 2011-11-15 06:41:50 -0500 |
commit | 56e7a8cca0fd9e096acd2233f0e9f95df6423071 (patch) | |
tree | 5b3ab9aac094f50c92b3e5539dc16f5d96337d0b /drivers/net/wireless/iwlegacy/4965.c | |
parent | ecce1f09e847351d18e503e533000f781cac1d41 (diff) |
iwlegacy: merge iwl-4965-eeprom.c into 4965.c
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/4965.c')
-rw-r--r-- | drivers/net/wireless/iwlegacy/4965.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 8f68b94fd74b..a4b42cc4c4c7 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c | |||
@@ -47,6 +47,80 @@ | |||
47 | #include "iwl-4965.h" | 47 | #include "iwl-4965.h" |
48 | #include "iwl-4965-debugfs.h" | 48 | #include "iwl-4965-debugfs.h" |
49 | 49 | ||
50 | /****************************************************************************** | ||
51 | * | ||
52 | * EEPROM related functions | ||
53 | * | ||
54 | ******************************************************************************/ | ||
55 | |||
56 | /* | ||
57 | * The device's EEPROM semaphore prevents conflicts between driver and uCode | ||
58 | * when accessing the EEPROM; each access is a series of pulses to/from the | ||
59 | * EEPROM chip, not a single event, so even reads could conflict if they | ||
60 | * weren't arbitrated by the semaphore. | ||
61 | */ | ||
62 | int il4965_eeprom_acquire_semaphore(struct il_priv *il) | ||
63 | { | ||
64 | u16 count; | ||
65 | int ret; | ||
66 | |||
67 | for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { | ||
68 | /* Request semaphore */ | ||
69 | il_set_bit(il, CSR_HW_IF_CONFIG_REG, | ||
70 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); | ||
71 | |||
72 | /* See if we got it */ | ||
73 | ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, | ||
74 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, | ||
75 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, | ||
76 | EEPROM_SEM_TIMEOUT); | ||
77 | if (ret >= 0) | ||
78 | return ret; | ||
79 | } | ||
80 | |||
81 | return ret; | ||
82 | } | ||
83 | |||
84 | void il4965_eeprom_release_semaphore(struct il_priv *il) | ||
85 | { | ||
86 | il_clear_bit(il, CSR_HW_IF_CONFIG_REG, | ||
87 | CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); | ||
88 | |||
89 | } | ||
90 | |||
91 | int il4965_eeprom_check_version(struct il_priv *il) | ||
92 | { | ||
93 | u16 eeprom_ver; | ||
94 | u16 calib_ver; | ||
95 | |||
96 | eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); | ||
97 | calib_ver = il_eeprom_query16(il, | ||
98 | EEPROM_4965_CALIB_VERSION_OFFSET); | ||
99 | |||
100 | if (eeprom_ver < il->cfg->eeprom_ver || | ||
101 | calib_ver < il->cfg->eeprom_calib_ver) | ||
102 | goto err; | ||
103 | |||
104 | IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", | ||
105 | eeprom_ver, calib_ver); | ||
106 | |||
107 | return 0; | ||
108 | err: | ||
109 | IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " | ||
110 | "CALIB=0x%x < 0x%x\n", | ||
111 | eeprom_ver, il->cfg->eeprom_ver, | ||
112 | calib_ver, il->cfg->eeprom_calib_ver); | ||
113 | return -EINVAL; | ||
114 | |||
115 | } | ||
116 | |||
117 | void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) | ||
118 | { | ||
119 | const u8 *addr = il_eeprom_query_addr(il, | ||
120 | EEPROM_MAC_ADDRESS); | ||
121 | memcpy(mac, addr, ETH_ALEN); | ||
122 | } | ||
123 | |||
50 | /* Send led command */ | 124 | /* Send led command */ |
51 | static int | 125 | static int |
52 | il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) | 126 | il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) |