Skip to content

Commit 9920322

Browse files
Prameela Rani GarnepudiKalle Valo
authored andcommitted
rsi: add tx frame for common device configuration
After successful loading of firmware, a CARD READY indication is received by host. Common device configuration parameters are sent to the device after this. It includes information like device operating mode (Wi-Fi alone or BT coex), power save related parameters, GPIO information etc. As device supports BT coex, this frame is send in COEX queue initially. Based on the operating mode, CARD READY indication is received from each protocol module in firmware i.e. WLAN, BT. Signed-off-by: Prameela Rani Garnepudi <[email protected]> Signed-off-by: Amitkumar Karwar <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 1b1bed0 commit 9920322

File tree

5 files changed

+178
-14
lines changed

5 files changed

+178
-14
lines changed

drivers/net/wireless/rsi/rsi_91x_hal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ int rsi_hal_device_init(struct rsi_hw *adapter)
718718
{
719719
struct rsi_common *common = adapter->priv;
720720

721-
common->coex_mode = 1;
721+
common->coex_mode = RSI_DEV_COEX_MODE_WIFI_ALONE;
722+
common->oper_mode = RSI_DEV_OPMODE_WIFI_ALONE;
722723
adapter->device_model = RSI_DEV_9113;
723724

724725
switch (adapter->device_model) {

drivers/net/wireless/rsi/rsi_91x_mgmt.c

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ static void rsi_set_default_parameters(struct rsi_common *common)
224224
common->fsm_state = FSM_CARD_NOT_READY;
225225
common->iface_down = true;
226226
common->endpoint = EP_2GHZ_20MHZ;
227+
common->driver_mode = 1; /* End to end mode */
228+
common->lp_ps_handshake_mode = 0; /* Default no handShake mode*/
229+
common->ulp_ps_handshake_mode = 2; /* Default PKT handShake mode*/
230+
common->rf_power_val = 0; /* Default 1.9V */
231+
common->wlan_rf_power_mode = 0;
232+
common->obm_ant_sel_val = 2;
227233
}
228234

229235
/**
@@ -761,6 +767,53 @@ int rsi_hal_load_key(struct rsi_common *common,
761767
return rsi_send_internal_mgmt_frame(common, skb);
762768
}
763769

770+
/*
771+
* This function sends the common device configuration parameters to device.
772+
* This frame includes the useful information to make device works on
773+
* specific operating mode.
774+
*/
775+
static int rsi_send_common_dev_params(struct rsi_common *common)
776+
{
777+
struct sk_buff *skb;
778+
u16 frame_len;
779+
struct rsi_config_vals *dev_cfgs;
780+
781+
frame_len = sizeof(struct rsi_config_vals);
782+
783+
rsi_dbg(MGMT_TX_ZONE, "Sending common device config params\n");
784+
skb = dev_alloc_skb(frame_len);
785+
if (!skb) {
786+
rsi_dbg(ERR_ZONE, "%s: Unable to allocate skb\n", __func__);
787+
return -ENOMEM;
788+
}
789+
790+
memset(skb->data, 0, frame_len);
791+
792+
dev_cfgs = (struct rsi_config_vals *)skb->data;
793+
memset(dev_cfgs, 0, (sizeof(struct rsi_config_vals)));
794+
795+
rsi_set_len_qno(&dev_cfgs->len_qno, (frame_len - FRAME_DESC_SZ),
796+
RSI_COEX_Q);
797+
dev_cfgs->pkt_type = COMMON_DEV_CONFIG;
798+
799+
dev_cfgs->lp_ps_handshake = common->lp_ps_handshake_mode;
800+
dev_cfgs->ulp_ps_handshake = common->ulp_ps_handshake_mode;
801+
802+
dev_cfgs->unused_ulp_gpio = RSI_UNUSED_ULP_GPIO_BITMAP;
803+
dev_cfgs->unused_soc_gpio_bitmap =
804+
cpu_to_le32(RSI_UNUSED_SOC_GPIO_BITMAP);
805+
806+
dev_cfgs->opermode = common->oper_mode;
807+
dev_cfgs->wlan_rf_pwr_mode = common->wlan_rf_power_mode;
808+
dev_cfgs->driver_mode = common->driver_mode;
809+
dev_cfgs->region_code = NL80211_DFS_FCC;
810+
dev_cfgs->antenna_sel_val = common->obm_ant_sel_val;
811+
812+
skb_put(skb, frame_len);
813+
814+
return rsi_send_internal_mgmt_frame(common, skb);
815+
}
816+
764817
/*
765818
* rsi_load_bootup_params() - This function send bootup params to the firmware.
766819
* @common: Pointer to the driver private structure.
@@ -1493,6 +1546,40 @@ static int rsi_handle_ta_confirm_type(struct rsi_common *common,
14931546
return -EINVAL;
14941547
}
14951548

1549+
static int rsi_handle_card_ready(struct rsi_common *common, u8 *msg)
1550+
{
1551+
switch (common->fsm_state) {
1552+
case FSM_CARD_NOT_READY:
1553+
rsi_dbg(INIT_ZONE, "Card ready indication from Common HAL\n");
1554+
rsi_set_default_parameters(common);
1555+
if (rsi_send_common_dev_params(common) < 0)
1556+
return -EINVAL;
1557+
common->fsm_state = FSM_COMMON_DEV_PARAMS_SENT;
1558+
break;
1559+
case FSM_COMMON_DEV_PARAMS_SENT:
1560+
rsi_dbg(INIT_ZONE, "Card ready indication from WLAN HAL\n");
1561+
1562+
/* Get usb buffer status register address */
1563+
common->priv->usb_buffer_status_reg = *(u32 *)&msg[8];
1564+
rsi_dbg(INFO_ZONE, "USB buffer status register = %x\n",
1565+
common->priv->usb_buffer_status_reg);
1566+
1567+
if (rsi_load_bootup_params(common)) {
1568+
common->fsm_state = FSM_CARD_NOT_READY;
1569+
return -EINVAL;
1570+
}
1571+
common->fsm_state = FSM_BOOT_PARAMS_SENT;
1572+
break;
1573+
default:
1574+
rsi_dbg(ERR_ZONE,
1575+
"%s: card ready indication in invalid state %d.\n",
1576+
__func__, common->fsm_state);
1577+
return -EINVAL;
1578+
}
1579+
1580+
return 0;
1581+
}
1582+
14961583
/**
14971584
* rsi_mgmt_pkt_recv() - This function processes the management packets
14981585
* recieved from the hardware.
@@ -1505,7 +1592,6 @@ int rsi_mgmt_pkt_recv(struct rsi_common *common, u8 *msg)
15051592
{
15061593
s32 msg_len = (le16_to_cpu(*(__le16 *)&msg[0]) & 0x0fff);
15071594
u16 msg_type = (msg[2]);
1508-
int ret;
15091595

15101596
rsi_dbg(FSM_ZONE, "%s: Msg Len: %d, Msg Type: %4x\n",
15111597
__func__, msg_len, msg_type);
@@ -1515,17 +1601,7 @@ int rsi_mgmt_pkt_recv(struct rsi_common *common, u8 *msg)
15151601
} else if (msg_type == CARD_READY_IND) {
15161602
rsi_dbg(FSM_ZONE, "%s: Card ready indication received\n",
15171603
__func__);
1518-
if (common->fsm_state == FSM_CARD_NOT_READY) {
1519-
rsi_set_default_parameters(common);
1520-
1521-
ret = rsi_load_bootup_params(common);
1522-
if (ret)
1523-
return ret;
1524-
else
1525-
common->fsm_state = FSM_BOOT_PARAMS_SENT;
1526-
} else {
1527-
return -EINVAL;
1528-
}
1604+
return rsi_handle_card_ready(common, msg);
15291605
} else if (msg_type == TX_STATUS_IND) {
15301606
if (msg[15] == PROBEREQ_CONFIRM) {
15311607
common->mgmt_q_block = false;

drivers/net/wireless/rsi/rsi_hal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363

6464
#define COMMAN_HAL_WAIT_FOR_CARD_READY 1
6565

66+
#define RSI_DEV_OPMODE_WIFI_ALONE 1
67+
#define RSI_DEV_COEX_MODE_WIFI_ALONE 1
68+
6669
struct bl_header {
6770
__le32 flags;
6871
__le32 image_no;

drivers/net/wireless/rsi/rsi_main.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
enum RSI_FSM_STATES {
3535
FSM_FW_NOT_LOADED,
3636
FSM_CARD_NOT_READY,
37+
FSM_COMMON_DEV_PARAMS_SENT,
3738
FSM_BOOT_PARAMS_SENT,
3839
FSM_EEPROM_READ_MAC_ADDR,
3940
FSM_RESET_MAC_SENT,
@@ -210,8 +211,14 @@ struct rsi_common {
210211
struct cqm_info cqm_info;
211212

212213
bool hw_data_qs_blocked;
214+
u8 driver_mode;
213215
u8 coex_mode;
214-
216+
u16 oper_mode;
217+
u8 lp_ps_handshake_mode;
218+
u8 ulp_ps_handshake_mode;
219+
u8 rf_power_val;
220+
u8 wlan_rf_power_mode;
221+
u8 obm_ant_sel_val;
215222
int tx_power;
216223
u8 ant_in_use;
217224
};
@@ -234,6 +241,7 @@ struct rsi_hw {
234241

235242
enum host_intf rsi_host_intf;
236243
u16 block_size;
244+
u32 usb_buffer_status_reg;
237245
#ifdef CONFIG_RSI_DEBUGFS
238246
struct rsi_debugfs *dfsentry;
239247
u8 num_debugfs_entries;

drivers/net/wireless/rsi/rsi_mgmt.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ enum cmd_frame_type {
205205
CW_MODE_REQ,
206206
PER_CMD_PKT,
207207
ANT_SEL_FRAME = 0x20,
208+
COMMON_DEV_CONFIG = 0x28,
208209
RADIO_PARAMS_UPDATE = 0x29
209210
};
210211

@@ -282,6 +283,76 @@ struct rsi_radio_caps {
282283
__le16 preamble_type;
283284
} __packed;
284285

286+
/* ULP GPIO flags */
287+
#define RSI_GPIO_MOTION_SENSOR_ULP_WAKEUP BIT(0)
288+
#define RSI_GPIO_SLEEP_IND_FROM_DEVICE BIT(1)
289+
#define RSI_GPIO_2_ULP BIT(2)
290+
#define RSI_GPIO_PUSH_BUTTON_ULP_WAKEUP BIT(3)
291+
292+
/* SOC GPIO flags */
293+
#define RSI_GPIO_0_PSPI_CSN_0 BIT(0)
294+
#define RSI_GPIO_1_PSPI_CSN_1 BIT(1)
295+
#define RSI_GPIO_2_HOST_WAKEUP_INTR BIT(2)
296+
#define RSI_GPIO_3_PSPI_DATA_0 BIT(3)
297+
#define RSI_GPIO_4_PSPI_DATA_1 BIT(4)
298+
#define RSI_GPIO_5_PSPI_DATA_2 BIT(5)
299+
#define RSI_GPIO_6_PSPI_DATA_3 BIT(6)
300+
#define RSI_GPIO_7_I2C_SCL BIT(7)
301+
#define RSI_GPIO_8_I2C_SDA BIT(8)
302+
#define RSI_GPIO_9_UART1_RX BIT(9)
303+
#define RSI_GPIO_10_UART1_TX BIT(10)
304+
#define RSI_GPIO_11_UART1_RTS_I2S_CLK BIT(11)
305+
#define RSI_GPIO_12_UART1_CTS_I2S_WS BIT(12)
306+
#define RSI_GPIO_13_DBG_UART_RX_I2S_DIN BIT(13)
307+
#define RSI_GPIO_14_DBG_UART_RX_I2S_DOUT BIT(14)
308+
#define RSI_GPIO_15_LP_WAKEUP_BOOT_BYPASS BIT(15)
309+
#define RSI_GPIO_16_LED_0 BIT(16)
310+
#define RSI_GPIO_17_BTCOEX_WLAN_ACT_EXT_ANT_SEL BIT(17)
311+
#define RSI_GPIO_18_BTCOEX_BT_PRIO_EXT_ANT_SEL BIT(18)
312+
#define RSI_GPIO_19_BTCOEX_BT_ACT_EXT_ON_OFF BIT(19)
313+
#define RSI_GPIO_20_RF_RESET BIT(20)
314+
#define RSI_GPIO_21_SLEEP_IND_FROM_DEVICE BIT(21)
315+
316+
#define RSI_UNUSED_SOC_GPIO_BITMAP (RSI_GPIO_9_UART1_RX | \
317+
RSI_GPIO_10_UART1_TX | \
318+
RSI_GPIO_11_UART1_RTS_I2S_CLK | \
319+
RSI_GPIO_12_UART1_CTS_I2S_WS | \
320+
RSI_GPIO_13_DBG_UART_RX_I2S_DIN | \
321+
RSI_GPIO_14_DBG_UART_RX_I2S_DOUT | \
322+
RSI_GPIO_15_LP_WAKEUP_BOOT_BYPASS | \
323+
RSI_GPIO_17_BTCOEX_WLAN_ACT_EXT_ANT_SEL | \
324+
RSI_GPIO_18_BTCOEX_BT_PRIO_EXT_ANT_SEL | \
325+
RSI_GPIO_19_BTCOEX_BT_ACT_EXT_ON_OFF | \
326+
RSI_GPIO_21_SLEEP_IND_FROM_DEVICE)
327+
328+
#define RSI_UNUSED_ULP_GPIO_BITMAP (RSI_GPIO_MOTION_SENSOR_ULP_WAKEUP | \
329+
RSI_GPIO_SLEEP_IND_FROM_DEVICE | \
330+
RSI_GPIO_2_ULP | \
331+
RSI_GPIO_PUSH_BUTTON_ULP_WAKEUP);
332+
struct rsi_config_vals {
333+
__le16 len_qno;
334+
u8 pkt_type;
335+
u8 misc_flags;
336+
__le16 reserved1[6];
337+
u8 lp_ps_handshake;
338+
u8 ulp_ps_handshake;
339+
u8 sleep_config_params; /* 0 for no handshake,
340+
* 1 for GPIO based handshake,
341+
* 2 packet handshake
342+
*/
343+
u8 unused_ulp_gpio;
344+
__le32 unused_soc_gpio_bitmap;
345+
u8 ext_pa_or_bt_coex_en;
346+
u8 opermode;
347+
u8 wlan_rf_pwr_mode;
348+
u8 bt_rf_pwr_mode;
349+
u8 zigbee_rf_pwr_mode;
350+
u8 driver_mode;
351+
u8 region_code;
352+
u8 antenna_sel_val;
353+
u8 reserved2[16];
354+
} __packed;
355+
285356
static inline u32 rsi_get_queueno(u8 *addr, u16 offset)
286357
{
287358
return (le16_to_cpu(*(__le16 *)&addr[offset]) & 0x7000) >> 12;
@@ -307,6 +378,11 @@ static inline u8 rsi_get_channel(u8 *addr)
307378
return *(char *)(addr + 15);
308379
}
309380

381+
static inline void rsi_set_len_qno(__le16 *addr, u16 len, u8 qno)
382+
{
383+
*addr = cpu_to_le16(len | ((qno & 7) << 12));
384+
}
385+
310386
int rsi_mgmt_pkt_recv(struct rsi_common *common, u8 *msg);
311387
int rsi_set_vap_capabilities(struct rsi_common *common, enum opmode mode,
312388
u8 vap_status);

0 commit comments

Comments
 (0)