Home | History | Annotate | Line # | Download | only in ic
bwfmvar.h revision 1.1
      1  1.1  jmcneill /* $NetBSD: bwfmvar.h,v 1.1 2017/10/19 23:58:41 jmcneill Exp $ */
      2  1.1  jmcneill /* $OpenBSD: bwfmvar.h,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
      3  1.1  jmcneill /*
      4  1.1  jmcneill  * Copyright (c) 2010-2016 Broadcom Corporation
      5  1.1  jmcneill  * Copyright (c) 2016,2017 Patrick Wildt <patrick (at) blueri.se>
      6  1.1  jmcneill  *
      7  1.1  jmcneill  * Permission to use, copy, modify, and/or distribute this software for any
      8  1.1  jmcneill  * purpose with or without fee is hereby granted, provided that the above
      9  1.1  jmcneill  * copyright notice and this permission notice appear in all copies.
     10  1.1  jmcneill  *
     11  1.1  jmcneill  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12  1.1  jmcneill  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13  1.1  jmcneill  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14  1.1  jmcneill  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15  1.1  jmcneill  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16  1.1  jmcneill  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17  1.1  jmcneill  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18  1.1  jmcneill  */
     19  1.1  jmcneill 
     20  1.1  jmcneill /* Chipcommon Core Chip IDs */
     21  1.1  jmcneill #define BRCM_CC_43143_CHIP_ID		43143
     22  1.1  jmcneill #define BRCM_CC_43235_CHIP_ID		43235
     23  1.1  jmcneill #define BRCM_CC_43236_CHIP_ID		43236
     24  1.1  jmcneill #define BRCM_CC_43238_CHIP_ID		43238
     25  1.1  jmcneill #define BRCM_CC_43241_CHIP_ID		0x4324
     26  1.1  jmcneill #define BRCM_CC_43242_CHIP_ID		43242
     27  1.1  jmcneill #define BRCM_CC_4329_CHIP_ID		0x4329
     28  1.1  jmcneill #define BRCM_CC_4330_CHIP_ID		0x4330
     29  1.1  jmcneill #define BRCM_CC_4334_CHIP_ID		0x4334
     30  1.1  jmcneill #define BRCM_CC_43340_CHIP_ID		43340
     31  1.1  jmcneill #define BRCM_CC_43362_CHIP_ID		43362
     32  1.1  jmcneill #define BRCM_CC_4335_CHIP_ID		0x4335
     33  1.1  jmcneill #define BRCM_CC_4339_CHIP_ID		0x4339
     34  1.1  jmcneill #define BRCM_CC_43430_CHIP_ID		43430
     35  1.1  jmcneill #define BRCM_CC_4345_CHIP_ID		0x4345
     36  1.1  jmcneill #define BRCM_CC_4350_CHIP_ID		0x4350
     37  1.1  jmcneill #define BRCM_CC_4354_CHIP_ID		0x4354
     38  1.1  jmcneill #define BRCM_CC_4356_CHIP_ID		0x4356
     39  1.1  jmcneill #define BRCM_CC_43566_CHIP_ID		43566
     40  1.1  jmcneill #define BRCM_CC_43567_CHIP_ID		43567
     41  1.1  jmcneill #define BRCM_CC_43569_CHIP_ID		43569
     42  1.1  jmcneill #define BRCM_CC_43570_CHIP_ID		43570
     43  1.1  jmcneill #define BRCM_CC_4358_CHIP_ID		0x4358
     44  1.1  jmcneill #define BRCM_CC_4359_CHIP_ID		0x4359
     45  1.1  jmcneill #define BRCM_CC_43602_CHIP_ID		43602
     46  1.1  jmcneill #define BRCM_CC_4365_CHIP_ID		0x4365
     47  1.1  jmcneill #define BRCM_CC_4366_CHIP_ID		0x4366
     48  1.1  jmcneill #define BRCM_CC_4371_CHIP_ID		0x4371
     49  1.1  jmcneill 
     50  1.1  jmcneill /* Defaults */
     51  1.1  jmcneill #define BWFM_DEFAULT_SCAN_CHANNEL_TIME	40
     52  1.1  jmcneill #define BWFM_DEFAULT_SCAN_UNASSOC_TIME	40
     53  1.1  jmcneill #define BWFM_DEFAULT_SCAN_PASSIVE_TIME	120
     54  1.1  jmcneill 
     55  1.1  jmcneill #define	BWFM_TASK_COUNT			32
     56  1.1  jmcneill 
     57  1.1  jmcneill 
     58  1.1  jmcneill struct bwfm_softc;
     59  1.1  jmcneill 
     60  1.1  jmcneill struct bwfm_core {
     61  1.1  jmcneill 	uint16_t	 co_id;
     62  1.1  jmcneill 	uint16_t	 co_rev;
     63  1.1  jmcneill 	uint32_t	 co_base;
     64  1.1  jmcneill 	uint32_t	 co_wrapbase;
     65  1.1  jmcneill 	LIST_ENTRY(bwfm_core) co_link;
     66  1.1  jmcneill };
     67  1.1  jmcneill 
     68  1.1  jmcneill struct bwfm_chip {
     69  1.1  jmcneill 	uint32_t	 ch_chip;
     70  1.1  jmcneill 	uint32_t	 ch_chiprev;
     71  1.1  jmcneill 	uint32_t	 ch_cc_caps;
     72  1.1  jmcneill 	uint32_t	 ch_cc_caps_ext;
     73  1.1  jmcneill 	uint32_t	 ch_pmucaps;
     74  1.1  jmcneill 	uint32_t	 ch_pmurev;
     75  1.1  jmcneill 	uint32_t	 ch_rambase;
     76  1.1  jmcneill 	uint32_t	 ch_ramsize;
     77  1.1  jmcneill 	uint32_t	 ch_srsize;
     78  1.1  jmcneill 	char		 ch_name[8];
     79  1.1  jmcneill 	LIST_HEAD(,bwfm_core) ch_list;
     80  1.1  jmcneill 	int (*ch_core_isup)(struct bwfm_softc *, struct bwfm_core *);
     81  1.1  jmcneill 	void (*ch_core_disable)(struct bwfm_softc *, struct bwfm_core *,
     82  1.1  jmcneill 	    uint32_t prereset, uint32_t reset);
     83  1.1  jmcneill 	void (*ch_core_reset)(struct bwfm_softc *, struct bwfm_core *,
     84  1.1  jmcneill 	    uint32_t prereset, uint32_t reset, uint32_t postreset);
     85  1.1  jmcneill };
     86  1.1  jmcneill 
     87  1.1  jmcneill struct bwfm_bus_ops {
     88  1.1  jmcneill 	void (*bs_init)(struct bwfm_softc *);
     89  1.1  jmcneill 	void (*bs_stop)(struct bwfm_softc *);
     90  1.1  jmcneill 	int (*bs_txdata)(struct bwfm_softc *, struct mbuf *);
     91  1.1  jmcneill 	int (*bs_txctl)(struct bwfm_softc *, char *, size_t);
     92  1.1  jmcneill 	int (*bs_rxctl)(struct bwfm_softc *, char *, size_t *);
     93  1.1  jmcneill };
     94  1.1  jmcneill 
     95  1.1  jmcneill struct bwfm_buscore_ops {
     96  1.1  jmcneill 	uint32_t (*bc_read)(struct bwfm_softc *, uint32_t);
     97  1.1  jmcneill 	void (*bc_write)(struct bwfm_softc *, uint32_t, uint32_t);
     98  1.1  jmcneill 	int (*bc_prepare)(struct bwfm_softc *);
     99  1.1  jmcneill 	int (*bc_reset)(struct bwfm_softc *);
    100  1.1  jmcneill 	int (*bc_setup)(struct bwfm_softc *);
    101  1.1  jmcneill 	void (*bc_activate)(struct bwfm_softc *, uint32_t);
    102  1.1  jmcneill };
    103  1.1  jmcneill 
    104  1.1  jmcneill struct bwfm_proto_ops {
    105  1.1  jmcneill 	int (*proto_query_dcmd)(struct bwfm_softc *, int, int,
    106  1.1  jmcneill 	    char *, size_t *);
    107  1.1  jmcneill 	int (*proto_set_dcmd)(struct bwfm_softc *, int, int,
    108  1.1  jmcneill 	    char *, size_t);
    109  1.1  jmcneill };
    110  1.1  jmcneill extern struct bwfm_proto_ops bwfm_proto_bcdc_ops;
    111  1.1  jmcneill 
    112  1.1  jmcneill enum bwfm_task_cmd {
    113  1.1  jmcneill 	BWFM_TASK_NEWSTATE,
    114  1.1  jmcneill 	BWFM_TASK_KEY_SET,
    115  1.1  jmcneill 	BWFM_TASK_KEY_DELETE,
    116  1.1  jmcneill };
    117  1.1  jmcneill 
    118  1.1  jmcneill struct bwfm_cmd_newstate {
    119  1.1  jmcneill 	enum ieee80211_state	 state;
    120  1.1  jmcneill 	int			 arg;
    121  1.1  jmcneill };
    122  1.1  jmcneill 
    123  1.1  jmcneill struct bwfm_cmd_key {
    124  1.1  jmcneill 	const struct ieee80211_key *key;
    125  1.1  jmcneill 	uint8_t			 mac[IEEE80211_ADDR_LEN];
    126  1.1  jmcneill };
    127  1.1  jmcneill 
    128  1.1  jmcneill struct bwfm_task {
    129  1.1  jmcneill 	struct work		 t_work;
    130  1.1  jmcneill 	struct bwfm_softc	*t_sc;
    131  1.1  jmcneill 	enum bwfm_task_cmd	 t_cmd;
    132  1.1  jmcneill 	union {
    133  1.1  jmcneill 		struct bwfm_cmd_newstate	newstate;
    134  1.1  jmcneill 		struct bwfm_cmd_key		key;
    135  1.1  jmcneill 	} t_u;
    136  1.1  jmcneill #define	t_newstate	t_u.newstate
    137  1.1  jmcneill #define	t_key		t_u.key
    138  1.1  jmcneill };
    139  1.1  jmcneill 
    140  1.1  jmcneill struct bwfm_softc {
    141  1.1  jmcneill 	device_t		 sc_dev;
    142  1.1  jmcneill 	struct ieee80211com	 sc_ic;
    143  1.1  jmcneill 	struct ethercom		 sc_ec;
    144  1.1  jmcneill #define	sc_if			 sc_ec.ec_if
    145  1.1  jmcneill 
    146  1.1  jmcneill 	struct bwfm_bus_ops	*sc_bus_ops;
    147  1.1  jmcneill 	struct bwfm_buscore_ops	*sc_buscore_ops;
    148  1.1  jmcneill 	struct bwfm_proto_ops	*sc_proto_ops;
    149  1.1  jmcneill 	struct bwfm_chip	 sc_chip;
    150  1.1  jmcneill 	uint8_t			 sc_io_type;
    151  1.1  jmcneill #define		BWFM_IO_TYPE_D11N		1
    152  1.1  jmcneill #define		BWFM_IO_TYPE_D11AC		2
    153  1.1  jmcneill 
    154  1.1  jmcneill 	int			 sc_tx_timer;
    155  1.1  jmcneill 
    156  1.1  jmcneill 	bool			 sc_if_attached;
    157  1.1  jmcneill 	struct bwfm_task	 sc_task[BWFM_TASK_COUNT];
    158  1.1  jmcneill 	pcq_t			*sc_freetask;
    159  1.1  jmcneill 	struct workqueue	*sc_taskq;
    160  1.1  jmcneill 
    161  1.1  jmcneill 	int			(*sc_newstate)(struct ieee80211com *,
    162  1.1  jmcneill 				    enum ieee80211_state, int);
    163  1.1  jmcneill };
    164  1.1  jmcneill 
    165  1.1  jmcneill void bwfm_attach(struct bwfm_softc *);
    166  1.1  jmcneill int bwfm_detach(struct bwfm_softc *, int);
    167  1.1  jmcneill int bwfm_chip_attach(struct bwfm_softc *);
    168  1.1  jmcneill struct bwfm_core *bwfm_chip_get_core(struct bwfm_softc *, int);
    169  1.1  jmcneill struct bwfm_core *bwfm_chip_get_pmu(struct bwfm_softc *);
    170  1.1  jmcneill void bwfm_rx(struct bwfm_softc *, char *, size_t);
    171