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

Commit 6f7dd16c authored by Luciano Coelho's avatar Luciano Coelho
Browse files

wlcore/wl12xx: add chip-specific identify chip operation



Move the code that identifies the chip ID and selects the appropriate
firmware to an operation implemented by the lower driver.  Also move
the quirks definitions into wlcore.h and rename to WLCORE_QUIRK_*.

Signed-off-by: default avatarLuciano Coelho <coelho@ti.com>
parent 00782136
Loading
Loading
Loading
Loading
+62 −3
Original line number Diff line number Diff line
@@ -29,9 +29,6 @@

#include "reg.h"

static struct wlcore_ops wl12xx_ops = {
};

static struct wlcore_partition_set wl12xx_ptable[PART_TABLE_LEN] = {
	[PART_DOWN] = {
		.mem = {
@@ -131,6 +128,62 @@ static const int wl12xx_rtable[REG_TABLE_LEN] = {
	[REG_RAW_FW_STATUS_ADDR]	= FW_STATUS_ADDR,
};

/* TODO: maybe move to a new header file? */
#define WL127X_FW_NAME_MULTI	"ti-connectivity/wl127x-fw-4-mr.bin"
#define WL127X_FW_NAME_SINGLE	"ti-connectivity/wl127x-fw-4-sr.bin"
#define WL127X_PLT_FW_NAME	"ti-connectivity/wl127x-fw-4-plt.bin"

#define WL128X_FW_NAME_MULTI	"ti-connectivity/wl128x-fw-4-mr.bin"
#define WL128X_FW_NAME_SINGLE	"ti-connectivity/wl128x-fw-4-sr.bin"
#define WL128X_PLT_FW_NAME	"ti-connectivity/wl128x-fw-4-plt.bin"

static int wl12xx_identify_chip(struct wl1271 *wl)
{
	int ret = 0;

	switch (wl->chip.id) {
	case CHIP_ID_1271_PG10:
		wl1271_warning("chip id 0x%x (1271 PG10) support is obsolete",
			       wl->chip.id);

		wl->quirks |= WLCORE_QUIRK_NO_BLOCKSIZE_ALIGNMENT;
		wl->plt_fw_name = WL127X_PLT_FW_NAME;
		wl->sr_fw_name = WL127X_FW_NAME_SINGLE;
		wl->mr_fw_name = WL127X_FW_NAME_MULTI;
		break;

	case CHIP_ID_1271_PG20:
		wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1271 PG20)",
			     wl->chip.id);

		wl->quirks |= WLCORE_QUIRK_NO_BLOCKSIZE_ALIGNMENT;
		wl->plt_fw_name = WL127X_PLT_FW_NAME;
		wl->sr_fw_name = WL127X_FW_NAME_SINGLE;
		wl->mr_fw_name = WL127X_FW_NAME_MULTI;
		break;

	case CHIP_ID_1283_PG20:
		wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1283 PG20)",
			     wl->chip.id);
		wl->plt_fw_name = WL128X_PLT_FW_NAME;
		wl->sr_fw_name = WL128X_FW_NAME_SINGLE;
		wl->mr_fw_name = WL128X_FW_NAME_MULTI;
		break;
	case CHIP_ID_1283_PG10:
	default:
		wl1271_warning("unsupported chip id: 0x%x", wl->chip.id);
		ret = -ENODEV;
		goto out;
	}

out:
	return ret;
}

static struct wlcore_ops wl12xx_ops = {
	.identify_chip = wl12xx_identify_chip,
};

static int __devinit wl12xx_probe(struct platform_device *pdev)
{
	struct wl1271 *wl;
@@ -180,3 +233,9 @@ module_exit(wl12xx_exit);

MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
MODULE_FIRMWARE(WL127X_FW_NAME_SINGLE);
MODULE_FIRMWARE(WL127X_FW_NAME_MULTI);
MODULE_FIRMWARE(WL127X_PLT_FW_NAME);
MODULE_FIRMWARE(WL128X_FW_NAME_SINGLE);
MODULE_FIRMWARE(WL128X_FW_NAME_MULTI);
MODULE_FIRMWARE(WL128X_PLT_FW_NAME);
+0 −1
Original line number Diff line number Diff line
@@ -447,7 +447,6 @@ b12-b0 - Supported Rate indicator bits as defined below.
#define CLK_REQ_OUTN_SEL       0x700

#define WU_COUNTER_PAUSE_VAL 0x3FF
#define WELP_ARM_COMMAND_VAL 0x4

/* PLL configuration algorithm for wl128x */
#define SYS_CLK_CFG_REG              0x2200
+3 −3
Original line number Diff line number Diff line
@@ -58,11 +58,11 @@ static unsigned int wl12xx_get_fw_ver_quirks(struct wl1271 *wl)
	/* Only new station firmwares support routing fw logs to the host */
	if ((fw_ver[FW_VER_IF_TYPE] == FW_VER_IF_TYPE_STA) &&
	    (fw_ver[FW_VER_MINOR] < FW_VER_MINOR_FWLOG_STA_MIN))
		quirks |= WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED;
		quirks |= WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED;

	/* This feature is not yet supported for AP mode */
	if (fw_ver[FW_VER_IF_TYPE] == FW_VER_IF_TYPE_AP)
		quirks |= WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED;
		quirks |= WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED;

	return quirks;
}
@@ -641,7 +641,7 @@ static int wl127x_boot_clk(struct wl1271 *wl)
	u32 clk;

	if (WL127X_PG_GET_MAJOR(wl->hw_pg_ver) < 3)
		wl->quirks |= WL12XX_QUIRK_END_OF_TRANSACTION;
		wl->quirks |= WLCORE_QUIRK_END_OF_TRANSACTION;

	if (wl->ref_clock == CONF_REF_CLK_19_2_E ||
	    wl->ref_clock == CONF_REF_CLK_38_4_E ||
+2 −2
Original line number Diff line number Diff line
@@ -318,7 +318,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl)
{
	int ret;

	if (wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED)
	if (wl->quirks & WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED)
		return 0;

	ret = wl12xx_cmd_config_fwlog(wl);
@@ -500,7 +500,7 @@ int wl1271_chip_specific_init(struct wl1271 *wl)
	if (wl->chip.id == CHIP_ID_1283_PG20) {
		u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;

		if (!(wl->quirks & WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT))
		if (!(wl->quirks & WLCORE_QUIRK_NO_BLOCKSIZE_ALIGNMENT))
			/* Enable SDIO padding */
			host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;

+11 −46
Original line number Diff line number Diff line
@@ -1055,10 +1055,7 @@ static int wl12xx_fetch_firmware(struct wl1271 *wl, bool plt)

	if (plt) {
		fw_type = WL12XX_FW_TYPE_PLT;
		if (wl->chip.id == CHIP_ID_1283_PG20)
			fw_name = WL128X_PLT_FW_NAME;
		else
			fw_name	= WL127X_PLT_FW_NAME;
		fw_name = wl->plt_fw_name;
	} else {
		/*
		 * we can't call wl12xx_get_vif_count() here because
@@ -1066,16 +1063,10 @@ static int wl12xx_fetch_firmware(struct wl1271 *wl, bool plt)
		 */
		if (wl->last_vif_count > 1) {
			fw_type = WL12XX_FW_TYPE_MULTI;
			if (wl->chip.id == CHIP_ID_1283_PG20)
				fw_name = WL128X_FW_NAME_MULTI;
			else
				fw_name = WL127X_FW_NAME_MULTI;
			fw_name = wl->mr_fw_name;
		} else {
			fw_type = WL12XX_FW_TYPE_NORMAL;
			if (wl->chip.id == CHIP_ID_1283_PG20)
				fw_name = WL128X_FW_NAME_SINGLE;
			else
				fw_name = WL127X_FW_NAME_SINGLE;
			fw_name = wl->sr_fw_name;
		}
	}

@@ -1182,7 +1173,7 @@ static void wl12xx_read_fwlog_panic(struct wl1271 *wl)
	u32 first_addr;
	u8 *block;

	if ((wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED) ||
	if ((wl->quirks & WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED) ||
	    (wl->conf.fwlog.mode != WL12XX_FWLOG_ON_DEMAND) ||
	    (wl->conf.fwlog.mem_blocks == 0))
		return;
@@ -1356,43 +1347,17 @@ static int wl12xx_chip_wakeup(struct wl1271 *wl, bool plt)
	 * chip types.
	 */
	if (!wl1271_set_block_size(wl))
		wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT;

	switch (wl->chip.id) {
	case CHIP_ID_1271_PG10:
		wl1271_warning("chip id 0x%x (1271 PG10) support is obsolete",
			       wl->chip.id);
		wl->quirks |= WLCORE_QUIRK_NO_BLOCKSIZE_ALIGNMENT;

		ret = wl1271_setup(wl);
	ret = wl->ops->identify_chip(wl);
	if (ret < 0)
		goto out;
		wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT;
		break;

	case CHIP_ID_1271_PG20:
		wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1271 PG20)",
			     wl->chip.id);
	/* TODO: make sure the lower driver has set things up correctly */

	ret = wl1271_setup(wl);
	if (ret < 0)
		goto out;
		wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT;
		break;

	case CHIP_ID_1283_PG20:
		wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1283 PG20)",
			     wl->chip.id);

		ret = wl1271_setup(wl);
		if (ret < 0)
			goto out;
		break;
	case CHIP_ID_1283_PG10:
	default:
		wl1271_warning("unsupported chip id: 0x%x", wl->chip.id);
		ret = -ENODEV;
		goto out;
	}

	ret = wl12xx_fetch_firmware(wl, plt);
	if (ret < 0)
Loading