xref: /openbmc/linux/drivers/net/wireless/purelifi/plfxlc/chip.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1*68d57a07SSrinivasan Raju /* SPDX-License-Identifier: GPL-2.0-only */
2*68d57a07SSrinivasan Raju /*
3*68d57a07SSrinivasan Raju  * Copyright (c) 2021 pureLiFi
4*68d57a07SSrinivasan Raju  */
5*68d57a07SSrinivasan Raju 
6*68d57a07SSrinivasan Raju #ifndef PLFXLC_CHIP_H
7*68d57a07SSrinivasan Raju #define PLFXLC_CHIP_H
8*68d57a07SSrinivasan Raju 
9*68d57a07SSrinivasan Raju #include <net/mac80211.h>
10*68d57a07SSrinivasan Raju 
11*68d57a07SSrinivasan Raju #include "usb.h"
12*68d57a07SSrinivasan Raju 
13*68d57a07SSrinivasan Raju enum unit_type {
14*68d57a07SSrinivasan Raju 	STA = 0,
15*68d57a07SSrinivasan Raju 	AP = 1,
16*68d57a07SSrinivasan Raju };
17*68d57a07SSrinivasan Raju 
18*68d57a07SSrinivasan Raju enum {
19*68d57a07SSrinivasan Raju 	PLFXLC_RADIO_OFF = 0,
20*68d57a07SSrinivasan Raju 	PLFXLC_RADIO_ON = 1,
21*68d57a07SSrinivasan Raju };
22*68d57a07SSrinivasan Raju 
23*68d57a07SSrinivasan Raju struct plfxlc_chip {
24*68d57a07SSrinivasan Raju 	struct plfxlc_usb usb;
25*68d57a07SSrinivasan Raju 	struct mutex mutex; /* lock to protect chip data */
26*68d57a07SSrinivasan Raju 	enum unit_type unit_type;
27*68d57a07SSrinivasan Raju 	u16 link_led;
28*68d57a07SSrinivasan Raju 	u8 beacon_set;
29*68d57a07SSrinivasan Raju 	u16 beacon_interval;
30*68d57a07SSrinivasan Raju };
31*68d57a07SSrinivasan Raju 
32*68d57a07SSrinivasan Raju struct plfxlc_mc_hash {
33*68d57a07SSrinivasan Raju 	u32 low;
34*68d57a07SSrinivasan Raju 	u32 high;
35*68d57a07SSrinivasan Raju };
36*68d57a07SSrinivasan Raju 
37*68d57a07SSrinivasan Raju #define plfxlc_chip_dev(chip) (&(chip)->usb.intf->dev)
38*68d57a07SSrinivasan Raju 
39*68d57a07SSrinivasan Raju void plfxlc_chip_init(struct plfxlc_chip *chip,
40*68d57a07SSrinivasan Raju 		      struct ieee80211_hw *hw,
41*68d57a07SSrinivasan Raju 		      struct usb_interface *intf);
42*68d57a07SSrinivasan Raju 
43*68d57a07SSrinivasan Raju void plfxlc_chip_release(struct plfxlc_chip *chip);
44*68d57a07SSrinivasan Raju 
45*68d57a07SSrinivasan Raju void plfxlc_chip_disable_rxtx(struct plfxlc_chip *chip);
46*68d57a07SSrinivasan Raju 
47*68d57a07SSrinivasan Raju int plfxlc_chip_init_hw(struct plfxlc_chip *chip);
48*68d57a07SSrinivasan Raju 
49*68d57a07SSrinivasan Raju int plfxlc_chip_enable_rxtx(struct plfxlc_chip *chip);
50*68d57a07SSrinivasan Raju 
51*68d57a07SSrinivasan Raju int plfxlc_chip_set_rate(struct plfxlc_chip *chip, u8 rate);
52*68d57a07SSrinivasan Raju 
53*68d57a07SSrinivasan Raju int plfxlc_set_beacon_interval(struct plfxlc_chip *chip, u16 interval,
54*68d57a07SSrinivasan Raju 			       u8 dtim_period, int type);
55*68d57a07SSrinivasan Raju 
56*68d57a07SSrinivasan Raju int plfxlc_chip_switch_radio(struct plfxlc_chip *chip, u16 value);
57*68d57a07SSrinivasan Raju 
plfxlc_usb_to_chip(struct plfxlc_usb * usb)58*68d57a07SSrinivasan Raju static inline struct plfxlc_chip *plfxlc_usb_to_chip(struct plfxlc_usb
59*68d57a07SSrinivasan Raju 							 *usb)
60*68d57a07SSrinivasan Raju {
61*68d57a07SSrinivasan Raju 	return container_of(usb, struct plfxlc_chip, usb);
62*68d57a07SSrinivasan Raju }
63*68d57a07SSrinivasan Raju 
plfxlc_mc_add_all(struct plfxlc_mc_hash * hash)64*68d57a07SSrinivasan Raju static inline void plfxlc_mc_add_all(struct plfxlc_mc_hash *hash)
65*68d57a07SSrinivasan Raju {
66*68d57a07SSrinivasan Raju 	hash->low  = 0xffffffff;
67*68d57a07SSrinivasan Raju 	hash->high = 0xffffffff;
68*68d57a07SSrinivasan Raju }
69*68d57a07SSrinivasan Raju 
70*68d57a07SSrinivasan Raju #endif /* PLFXLC_CHIP_H */
71