Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d717fd61 authored by Juuso Oikarinen's avatar Juuso Oikarinen Committed by John W. Linville
Browse files

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: default avatarJuuso Oikarinen <juuso.oikarinen@nokia.com>
Reviewed-by: default avatarLuciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: default avatarLuciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 2ff6575b
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -388,6 +388,8 @@ struct wl1271 {
	size_t fw_len;
	size_t fw_len;
	struct wl1271_nvs_file *nvs;
	struct wl1271_nvs_file *nvs;


	s8 hw_pg_ver;

	u8 bssid[ETH_ALEN];
	u8 bssid[ETH_ALEN];
	u8 mac_addr[ETH_ALEN];
	u8 mac_addr[ETH_ALEN];
	u8 bss_type;
	u8 bss_type;
+12 −0
Original line number Original line Diff line number Diff line
@@ -440,11 +440,23 @@ static int wl1271_boot_write_irq_polarity(struct wl1271 *wl)
	return 0;
	return 0;
}
}


static void wl1271_boot_hw_version(struct wl1271 *wl)
{
	u32 fuse;

	fuse = wl1271_top_reg_read(wl, REG_FUSE_DATA_2_1);
	fuse = (fuse & PG_VER_MASK) >> PG_VER_OFFSET;

	wl->hw_pg_ver = (s8)fuse;
}

int wl1271_boot(struct wl1271 *wl)
int wl1271_boot(struct wl1271 *wl)
{
{
	int ret = 0;
	int ret = 0;
	u32 tmp, clk, pause;
	u32 tmp, clk, pause;


	wl1271_boot_hw_version(wl);

	if (REF_CLOCK == 0 || REF_CLOCK == 2 || REF_CLOCK == 4)
	if (REF_CLOCK == 0 || REF_CLOCK == 2 || REF_CLOCK == 4)
		/* ref clk: 19.2/38.4/38.4-XTAL */
		/* ref clk: 19.2/38.4/38.4-XTAL */
		clk = 0x3;
		clk = 0x3;
+3 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,9 @@ struct wl1271_static_data {
#define OCP_REG_CLK_POLARITY 0x0cb2
#define OCP_REG_CLK_POLARITY 0x0cb2
#define OCP_REG_CLK_PULL     0x0cb4
#define OCP_REG_CLK_PULL     0x0cb4


#define REG_FUSE_DATA_2_1    0x050a
#define PG_VER_MASK          0x3c
#define PG_VER_OFFSET        2


#define CMD_MBOX_ADDRESS     0x407B4
#define CMD_MBOX_ADDRESS     0x407B4


+34 −0
Original line number Original line Diff line number Diff line
@@ -2232,6 +2232,29 @@ static DEVICE_ATTR(bt_coex_state, S_IRUGO | S_IWUSR,
		   wl1271_sysfs_show_bt_coex_state,
		   wl1271_sysfs_show_bt_coex_state,
		   wl1271_sysfs_store_bt_coex_state);
		   wl1271_sysfs_store_bt_coex_state);


static ssize_t wl1271_sysfs_show_hw_pg_ver(struct device *dev,
					   struct device_attribute *attr,
					   char *buf)
{
	struct wl1271 *wl = dev_get_drvdata(dev);
	ssize_t len;

	/* FIXME: what's the maximum length of buf? page size?*/
	len = 500;

	mutex_lock(&wl->mutex);
	if (wl->hw_pg_ver >= 0)
		len = snprintf(buf, len, "%d\n", wl->hw_pg_ver);
	else
		len = snprintf(buf, len, "n/a\n");
	mutex_unlock(&wl->mutex);

	return len;
}

static DEVICE_ATTR(hw_pg_ver, S_IRUGO | S_IWUSR,
		   wl1271_sysfs_show_hw_pg_ver, NULL);

int wl1271_register_hw(struct wl1271 *wl)
int wl1271_register_hw(struct wl1271 *wl)
{
{
	int ret;
	int ret;
@@ -2351,6 +2374,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
	wl->vif = NULL;
	wl->vif = NULL;
	wl->flags = 0;
	wl->flags = 0;
	wl->sg_enabled = true;
	wl->sg_enabled = true;
	wl->hw_pg_ver = -1;


	for (i = 0; i < ACX_TX_DESCRIPTORS; i++)
	for (i = 0; i < ACX_TX_DESCRIPTORS; i++)
		wl->tx_frames[i] = NULL;
		wl->tx_frames[i] = NULL;
@@ -2380,8 +2404,18 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
		goto err_platform;
		goto err_platform;
	}
	}


	/* Create sysfs file to get HW PG version */
	ret = device_create_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver);
	if (ret < 0) {
		wl1271_error("failed to create sysfs file hw_pg_ver");
		goto err_bt_coex_state;
	}

	return hw;
	return hw;


err_bt_coex_state:
	device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state);

err_platform:
err_platform:
	platform_device_unregister(wl->plat_dev);
	platform_device_unregister(wl->plat_dev);