15b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/*
25b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * Copyright (c) 2010 Broadcom Corporation
35b435de0d786869c95d1962121af0d7df2542009Arend van Spriel *
45b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * Permission to use, copy, modify, and/or distribute this software for any
55b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * purpose with or without fee is hereby granted, provided that the above
65b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * copyright notice and this permission notice appear in all copies.
75b435de0d786869c95d1962121af0d7df2542009Arend van Spriel *
85b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
95b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
105b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
115b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
125b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
135b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
145b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
155b435de0d786869c95d1962121af0d7df2542009Arend van Spriel */
165b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
175b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/*
185b435de0d786869c95d1962121af0d7df2542009Arend van Spriel * phy_shim.h: stuff defined in phy_shim.c and included only by the phy
195b435de0d786869c95d1962121af0d7df2542009Arend van Spriel */
205b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
215b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#ifndef _BRCM_PHY_SHIM_H_
225b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define _BRCM_PHY_SHIM_H_
235b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
245b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#include "types.h"
255b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
265b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_NONE		0	/* Radar type None */
275b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_ETSI_1	1	/* ETSI 1 Radar type */
285b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_ETSI_2	2	/* ETSI 2 Radar type */
295b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_ETSI_3	3	/* ETSI 3 Radar type */
305b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_ITU_E	4	/* ITU E Radar type */
315b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_ITU_K	5	/* ITU K Radar type */
325b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_UNCLASSIFIED	6	/* Unclassified Radar type  */
335b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_BIN5		7	/* long pulse radar type */
345b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_STG2		8	/* staggered-2 radar */
355b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_STG3		9	/* staggered-3 radar */
365b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define RADAR_TYPE_FRA		10	/* French radar */
375b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
385b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* French radar pulse widths */
395b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define FRA_T1_20MHZ	52770
405b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define FRA_T2_20MHZ	61538
415b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define FRA_T3_20MHZ	66002
425b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define FRA_T1_40MHZ	105541
435b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define FRA_T2_40MHZ	123077
445b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define FRA_T3_40MHZ	132004
455b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define FRA_ERR_20MHZ	60
465b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define FRA_ERR_40MHZ	120
475b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
485b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define ANTSEL_NA		0 /* No boardlevel selection available */
495b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define ANTSEL_2x4		1 /* 2x4 boardlevel selection available */
505b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define ANTSEL_2x3		2 /* 2x3 CB2 boardlevel selection available */
515b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
525b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Rx Antenna diversity control values */
535b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define	ANT_RX_DIV_FORCE_0	0	/* Use antenna 0 */
545b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define	ANT_RX_DIV_FORCE_1	1	/* Use antenna 1 */
555b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define	ANT_RX_DIV_START_1	2	/* Choose starting with 1 */
565b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define	ANT_RX_DIV_START_0	3	/* Choose starting with 0 */
575b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define	ANT_RX_DIV_ENABLE	3	/* APHY bbConfig Enable RX Diversity */
585b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define ANT_RX_DIV_DEF		ANT_RX_DIV_START_0 /* default antdiv setting */
595b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
605b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_ANT_RX_MAX		2	/* max 2 receive antennas */
615b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_ANT_HT_RX_MAX	3	/* max 3 receive antennas/cores */
625b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_ANT_IDX_1		0	/* antenna index 1 */
635b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_ANT_IDX_2		1	/* antenna index 2 */
645b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
655b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* values for n_preamble_type */
665b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define BRCMS_N_PREAMBLE_MIXEDMODE	0
675b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define BRCMS_N_PREAMBLE_GF		1
685b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define BRCMS_N_PREAMBLE_GF_BRCM          2
695b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
705b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_RATES_LEGACY	45
715b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS20_FIRST	        12
725b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS20_NUM	        16
735b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS40_FIRST	        28
745b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS40_NUM	        17
755b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
765b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
775b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_RATES	       101
785b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_CCK_FIRST	       0
795b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_CCK_NUM	       4
805b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 20MHz OFDM SISO rate */
815b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_OFDM_FIRST	       4
825b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 20MHz OFDM CDD rate */
835b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_OFDM20_CDD_FIRST   12
845b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 40MHz OFDM SISO rate */
855b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_OFDM40_SISO_FIRST  52
865b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 40MHz OFDM CDD rate */
875b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_OFDM40_CDD_FIRST   60
885b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_OFDM_NUM	       8
895b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 20MHz MCS SISO rate */
905b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS20_SISO_FIRST   20
915b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 20MHz MCS CDD rate */
925b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS20_CDD_FIRST    28
935b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 20MHz MCS STBC rate */
945b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS20_STBC_FIRST   36
955b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 20MHz MCS SDM rate */
965b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS20_SDM_FIRST    44
975b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 40MHz MCS SISO rate */
985b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS40_SISO_FIRST   68
995b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 40MHz MCS CDD rate */
1005b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS40_CDD_FIRST    76
1015b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 40MHz MCS STBC rate */
1025b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS40_STBC_FIRST   84
1035b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 40MHz MCS SDM rate */
1045b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS40_SDM_FIRST    92
1055b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS_1_STREAM_NUM   8
1065b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS_2_STREAM_NUM   8
1075b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for 40MHz rate MCS 32 */
1085b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS_32	       100
1095b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS_32_NUM	       1
1105b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
1115b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* sslpnphy specifics */
1125b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* Index for first 20MHz MCS SISO rate */
1135b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_MCS20_SISO_FIRST_SSN   12
1145b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
1155b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* struct tx_power::flags bits */
1165b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_F_ENABLED	1
1175b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_F_HW	2
1185b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_F_MIMO	4
1195b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define WL_TX_POWER_F_SISO	8
1205b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
1215b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* values to force tx/rx chain */
1225b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define BRCMS_N_TXRX_CHAIN0		0
1235b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#define BRCMS_N_TXRX_CHAIN1		1
1245b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
1255b435de0d786869c95d1962121af0d7df2542009Arend van Sprielstruct brcms_phy;
1265b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
1279bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesstruct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw,
1289bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches					  struct brcms_info *wl,
1299bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches					  struct brcms_c_info *wlc);
1309bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlc_phy_shim_detach(struct phy_shim_info *physhim);
1315b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
1325b435de0d786869c95d1962121af0d7df2542009Arend van Spriel/* PHY to WL utility functions */
1339bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesstruct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim,
1349bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches				     void (*fn)(struct brcms_phy *pi),
1359bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches				     void *arg, const char *name);
1369bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_free_timer(struct wlapi_timer *t);
1379bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_add_timer(struct wlapi_timer *t, uint ms, int periodic);
1389bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesbool wlapi_del_timer(struct wlapi_timer *t);
1399bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_intrson(struct phy_shim_info *physhim);
1409bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesu32 wlapi_intrsoff(struct phy_shim_info *physhim);
1419bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_intrsrestore(struct phy_shim_info *physhim, u32 macintmask);
1429bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches
1439bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_write_shm(struct phy_shim_info *physhim, uint offset, u16 v);
1449bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesu16 wlapi_bmac_read_shm(struct phy_shim_info *physhim, uint offset);
1459bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_mhf(struct phy_shim_info *physhim, u8 idx, u16 mask, u16 val,
1469bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches		    int bands);
1479bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_corereset(struct phy_shim_info *physhim, u32 flags);
1489bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_suspend_mac_and_wait(struct phy_shim_info *physhim);
1499bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_switch_macfreq(struct phy_shim_info *physhim, u8 spurmode);
1509bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_enable_mac(struct phy_shim_info *physhim);
1519bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_mctrl(struct phy_shim_info *physhim, u32 mask, u32 val);
1529bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_phy_reset(struct phy_shim_info *physhim);
1539bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_bw_set(struct phy_shim_info *physhim, u16 bw);
1549bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_phyclk_fgc(struct phy_shim_info *physhim, bool clk);
1559bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_macphyclk_set(struct phy_shim_info *physhim, bool clk);
1569bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_core_phypll_ctl(struct phy_shim_info *physhim, bool on);
1579bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_core_phypll_reset(struct phy_shim_info *physhim);
1589bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_ucode_wake_override_phyreg_set(struct phy_shim_info *physhim);
1599bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_ucode_wake_override_phyreg_clear(struct phy_shim_info *physhim);
1609bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_bmac_write_template_ram(struct phy_shim_info *physhim, int o,
1619bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches				   int len, void *buf);
1629bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesu16 wlapi_bmac_rate_shm_offset(struct phy_shim_info *physhim, u8 rate);
1639bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_ucode_sample_init(struct phy_shim_info *physhim);
1649bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_copyfrom_objmem(struct phy_shim_info *physhim, uint, void *buf,
1659bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches			   int, u32 sel);
1669bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_copyto_objmem(struct phy_shim_info *physhim, uint, const void *buf,
1679bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches			 int, u32);
1689bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perches
1699bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesvoid wlapi_high_update_phy_mode(struct phy_shim_info *physhim, u32 phy_mode);
1709bd91f3c00bd8dd54339499a9253b31c6bac7c7bJoe Perchesu16 wlapi_bmac_get_txant(struct phy_shim_info *physhim);
1715b435de0d786869c95d1962121af0d7df2542009Arend van Spriel
1725b435de0d786869c95d1962121af0d7df2542009Arend van Spriel#endif				/* _BRCM_PHY_SHIM_H_ */
173