diff options
| author | Juuso Oikarinen <juuso.oikarinen@nokia.com> | 2010-05-07 04:38:58 -0400 |
|---|---|---|
| committer | John W. Linville <linville@tuxdriver.com> | 2010-05-07 14:57:18 -0400 |
| commit | d717fd6188b2ea63cf9dc0a870fd312c312841cd (patch) | |
| tree | 428410070c7ce5aa36f699939344bb3267ad9eed | |
| parent | 2ff6575b1e497f88acf2c7de7e1ba015267b689d (diff) | |
wl1271: Add sysfs file to retrieve HW PG-version and ROM-version
This patch reads the HW PG version (along with a ROM-version, embedded in the
same value) from the wl1271 hardware and publishes the value in a sysfs -file.
Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Reviewed-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
| -rw-r--r-- | drivers/net/wireless/wl12xx/wl1271.h | 2 | ||||
| -rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_boot.c | 12 | ||||
| -rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_boot.h | 3 | ||||
| -rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_main.c | 34 |
4 files changed, 51 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271.h b/drivers/net/wireless/wl12xx/wl1271.h index 75887e74205b..3e1769dd1b55 100644 --- a/drivers/net/wireless/wl12xx/wl1271.h +++ b/drivers/net/wireless/wl12xx/wl1271.h | |||
| @@ -388,6 +388,8 @@ struct wl1271 { | |||
| 388 | size_t fw_len; | 388 | size_t fw_len; |
| 389 | struct wl1271_nvs_file *nvs; | 389 | struct wl1271_nvs_file *nvs; |
| 390 | 390 | ||
| 391 | s8 hw_pg_ver; | ||
| 392 | |||
| 391 | u8 bssid[ETH_ALEN]; | 393 | u8 bssid[ETH_ALEN]; |
| 392 | u8 mac_addr[ETH_ALEN]; | 394 | u8 mac_addr[ETH_ALEN]; |
| 393 | u8 bss_type; | 395 | u8 bss_type; |
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.c b/drivers/net/wireless/wl12xx/wl1271_boot.c index 7e797157783e..139a1e0fc7e3 100644 --- a/drivers/net/wireless/wl12xx/wl1271_boot.c +++ b/drivers/net/wireless/wl12xx/wl1271_boot.c | |||
| @@ -440,11 +440,23 @@ static int wl1271_boot_write_irq_polarity(struct wl1271 *wl) | |||
| 440 | return 0; | 440 | return 0; |
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | static void wl1271_boot_hw_version(struct wl1271 *wl) | ||
| 444 | { | ||
| 445 | u32 fuse; | ||
| 446 | |||
| 447 | fuse = wl1271_top_reg_read(wl, REG_FUSE_DATA_2_1); | ||
| 448 | fuse = (fuse & PG_VER_MASK) >> PG_VER_OFFSET; | ||
| 449 | |||
| 450 | wl->hw_pg_ver = (s8)fuse; | ||
| 451 | } | ||
| 452 | |||
| 443 | int wl1271_boot(struct wl1271 *wl) | 453 | int wl1271_boot(struct wl1271 *wl) |
| 444 | { | 454 | { |
| 445 | int ret = 0; | 455 | int ret = 0; |
| 446 | u32 tmp, clk, pause; | 456 | u32 tmp, clk, pause; |
| 447 | 457 | ||
| 458 | wl1271_boot_hw_version(wl); | ||
| 459 | |||
| 448 | if (REF_CLOCK == 0 || REF_CLOCK == 2 || REF_CLOCK == 4) | 460 | if (REF_CLOCK == 0 || REF_CLOCK == 2 || REF_CLOCK == 4) |
| 449 | /* ref clk: 19.2/38.4/38.4-XTAL */ | 461 | /* ref clk: 19.2/38.4/38.4-XTAL */ |
| 450 | clk = 0x3; | 462 | clk = 0x3; |
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.h b/drivers/net/wireless/wl12xx/wl1271_boot.h index 95ecc5241959..f829699d597e 100644 --- a/drivers/net/wireless/wl12xx/wl1271_boot.h +++ b/drivers/net/wireless/wl12xx/wl1271_boot.h | |||
| @@ -55,6 +55,9 @@ struct wl1271_static_data { | |||
| 55 | #define OCP_REG_CLK_POLARITY 0x0cb2 | 55 | #define OCP_REG_CLK_POLARITY 0x0cb2 |
| 56 | #define OCP_REG_CLK_PULL 0x0cb4 | 56 | #define OCP_REG_CLK_PULL 0x0cb4 |
| 57 | 57 | ||
| 58 | #define REG_FUSE_DATA_2_1 0x050a | ||
| 59 | #define PG_VER_MASK 0x3c | ||
| 60 | #define PG_VER_OFFSET 2 | ||
| 58 | 61 | ||
| 59 | #define CMD_MBOX_ADDRESS 0x407B4 | 62 | #define CMD_MBOX_ADDRESS 0x407B4 |
| 60 | 63 | ||
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c index b0837255de6f..36dfdee5fbfe 100644 --- a/drivers/net/wireless/wl12xx/wl1271_main.c +++ b/drivers/net/wireless/wl12xx/wl1271_main.c | |||
| @@ -2232,6 +2232,29 @@ static DEVICE_ATTR(bt_coex_state, S_IRUGO | S_IWUSR, | |||
| 2232 | wl1271_sysfs_show_bt_coex_state, | 2232 | wl1271_sysfs_show_bt_coex_state, |
| 2233 | wl1271_sysfs_store_bt_coex_state); | 2233 | wl1271_sysfs_store_bt_coex_state); |
| 2234 | 2234 | ||
| 2235 | static ssize_t wl1271_sysfs_show_hw_pg_ver(struct device *dev, | ||
| 2236 | struct device_attribute *attr, | ||
| 2237 | char *buf) | ||
| 2238 | { | ||
| 2239 | struct wl1271 *wl = dev_get_drvdata(dev); | ||
| 2240 | ssize_t len; | ||
| 2241 | |||
| 2242 | /* FIXME: what's the maximum length of buf? page size?*/ | ||
| 2243 | len = 500; | ||
| 2244 | |||
| 2245 | mutex_lock(&wl->mutex); | ||
| 2246 | if (wl->hw_pg_ver >= 0) | ||
| 2247 | len = snprintf(buf, len, "%d\n", wl->hw_pg_ver); | ||
| 2248 | else | ||
| 2249 | len = snprintf(buf, len, "n/a\n"); | ||
| 2250 | mutex_unlock(&wl->mutex); | ||
| 2251 | |||
| 2252 | return len; | ||
| 2253 | } | ||
| 2254 | |||
| 2255 | static DEVICE_ATTR(hw_pg_ver, S_IRUGO | S_IWUSR, | ||
| 2256 | wl1271_sysfs_show_hw_pg_ver, NULL); | ||
| 2257 | |||
| 2235 | int wl1271_register_hw(struct wl1271 *wl) | 2258 | int wl1271_register_hw(struct wl1271 *wl) |
| 2236 | { | 2259 | { |
| 2237 | int ret; | 2260 | int ret; |
| @@ -2351,6 +2374,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void) | |||
| 2351 | wl->vif = NULL; | 2374 | wl->vif = NULL; |
| 2352 | wl->flags = 0; | 2375 | wl->flags = 0; |
| 2353 | wl->sg_enabled = true; | 2376 | wl->sg_enabled = true; |
| 2377 | wl->hw_pg_ver = -1; | ||
| 2354 | 2378 | ||
| 2355 | for (i = 0; i < ACX_TX_DESCRIPTORS; i++) | 2379 | for (i = 0; i < ACX_TX_DESCRIPTORS; i++) |
| 2356 | wl->tx_frames[i] = NULL; | 2380 | wl->tx_frames[i] = NULL; |
| @@ -2380,8 +2404,18 @@ struct ieee80211_hw *wl1271_alloc_hw(void) | |||
| 2380 | goto err_platform; | 2404 | goto err_platform; |
| 2381 | } | 2405 | } |
| 2382 | 2406 | ||
| 2407 | /* Create sysfs file to get HW PG version */ | ||
| 2408 | ret = device_create_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver); | ||
| 2409 | if (ret < 0) { | ||
| 2410 | wl1271_error("failed to create sysfs file hw_pg_ver"); | ||
| 2411 | goto err_bt_coex_state; | ||
| 2412 | } | ||
| 2413 | |||
| 2383 | return hw; | 2414 | return hw; |
| 2384 | 2415 | ||
| 2416 | err_bt_coex_state: | ||
| 2417 | device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); | ||
| 2418 | |||
| 2385 | err_platform: | 2419 | err_platform: |
| 2386 | platform_device_unregister(wl->plat_dev); | 2420 | platform_device_unregister(wl->plat_dev); |
| 2387 | 2421 | ||
