Linux-libre 4.19.123-gnu
[librecmc/linux-libre.git] / include / linux / platform_data / brcmfmac.h
1 /*
2  * Copyright (c) 201 Broadcom Corporation
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef _LINUX_BRCMFMAC_PLATFORM_H
18 #define _LINUX_BRCMFMAC_PLATFORM_H
19
20
21 #define BRCMFMAC_PDATA_NAME             "brcmfmac"
22
23 #define BRCMFMAC_COUNTRY_BUF_SZ         4
24
25
26 /*
27  * Platform specific driver functions and data. Through the platform specific
28  * device data functions and data can be provided to help the brcmfmac driver to
29  * operate with the device in combination with the used platform.
30  */
31
32
33 /**
34  * Note: the brcmfmac can be loaded as module or be statically built-in into
35  * the kernel. If built-in then do note that it uses module_init (and
36  * module_exit) routines which equal device_initcall. So if you intend to
37  * create a module with the platform specific data for the brcmfmac and have
38  * it built-in to the kernel then use a higher initcall then device_initcall
39  * (see init.h). If this is not done then brcmfmac will load without problems
40  * but will not pickup the platform data.
41  *
42  * When the driver does not "detect" platform driver data then it will continue
43  * without reporting anything and just assume there is no data needed. Which is
44  * probably true for most platforms.
45  */
46
47 /**
48  * enum brcmf_bus_type - Bus type identifier. Currently SDIO, USB and PCIE are
49  *                       supported.
50  */
51 enum brcmf_bus_type {
52         BRCMF_BUSTYPE_SDIO,
53         BRCMF_BUSTYPE_USB,
54         BRCMF_BUSTYPE_PCIE
55 };
56
57
58 /**
59  * struct brcmfmac_sdio_pd - SDIO Device specific platform data.
60  *
61  * @txglomsz:           SDIO txglom size. Use 0 if default of driver is to be
62  *                      used.
63  * @drive_strength:     is the preferred drive_strength to be used for the SDIO
64  *                      pins. If 0 then a default value will be used. This is
65  *                      the target drive strength, the exact drive strength
66  *                      which will be used depends on the capabilities of the
67  *                      device.
68  * @oob_irq_supported:  does the board have support for OOB interrupts. SDIO
69  *                      in-band interrupts are relatively slow and for having
70  *                      less overhead on interrupt processing an out of band
71  *                      interrupt can be used. If the HW supports this then
72  *                      enable this by setting this field to true and configure
73  *                      the oob related fields.
74  * @oob_irq_nr,
75  * @oob_irq_flags:      the OOB interrupt information. The values are used for
76  *                      registering the irq using request_irq function.
77  * @broken_sg_support:  flag for broken sg list support of SDIO host controller.
78  *                      Set this to true if the SDIO host controller has higher
79  *                      align requirement than 32 bytes for each scatterlist
80  *                      item.
81  * @sd_head_align:      alignment requirement for start of data buffer.
82  * @sd_sgentry_align:   length alignment requirement for each sg entry.
83  * @reset:              This function can get called if the device communication
84  *                      broke down. This functionality is particularly useful in
85  *                      case of SDIO type devices. It is possible to reset a
86  *                      dongle via sdio data interface, but it requires that
87  *                      this is fully functional. This function is chip/module
88  *                      specific and this function should return only after the
89  *                      complete reset has completed.
90  */
91 struct brcmfmac_sdio_pd {
92         int             txglomsz;
93         unsigned int    drive_strength;
94         bool            oob_irq_supported;
95         unsigned int    oob_irq_nr;
96         unsigned long   oob_irq_flags;
97         bool            broken_sg_support;
98         unsigned short  sd_head_align;
99         unsigned short  sd_sgentry_align;
100         void            (*reset)(void);
101 };
102
103 /**
104  * struct brcmfmac_pd_cc_entry - Struct for translating user space country code
105  *                               (iso3166) to firmware country code and
106  *                               revision.
107  *
108  * @iso3166:    iso3166 alpha 2 country code string.
109  * @cc:         firmware country code string.
110  * @rev:        firmware country code revision.
111  */
112 struct brcmfmac_pd_cc_entry {
113         char    iso3166[BRCMFMAC_COUNTRY_BUF_SZ];
114         char    cc[BRCMFMAC_COUNTRY_BUF_SZ];
115         s32     rev;
116 };
117
118 /**
119  * struct brcmfmac_pd_cc - Struct for translating country codes as set by user
120  *                         space to a country code and rev which can be used by
121  *                         firmware.
122  *
123  * @table_size: number of entries in table (> 0)
124  * @table:      array of 1 or more elements with translation information.
125  */
126 struct brcmfmac_pd_cc {
127         int                             table_size;
128         struct brcmfmac_pd_cc_entry     table[0];
129 };
130
131 /**
132  * struct brcmfmac_pd_device - Device specific platform data. (id/rev/bus_type)
133  *                             is the unique identifier of the device.
134  *
135  * @id:                 ID of the device for which this data is. In case of SDIO
136  *                      or PCIE this is the chipid as identified by chip.c In
137  *                      case of USB this is the chipid as identified by the
138  *                      device query.
139  * @rev:                chip revision, see id.
140  * @bus_type:           The type of bus. Some chipid/rev exist for different bus
141  *                      types. Each bus type has its own set of settings.
142  * @feature_disable:    Bitmask of features to disable (override), See feature.c
143  *                      in brcmfmac for details.
144  * @country_codes:      If available, pointer to struct for translating country
145  *                      codes.
146  * @bus:                Bus specific (union) device settings. Currently only
147  *                      SDIO.
148  */
149 struct brcmfmac_pd_device {
150         unsigned int            id;
151         unsigned int            rev;
152         enum brcmf_bus_type     bus_type;
153         unsigned int            feature_disable;
154         struct brcmfmac_pd_cc   *country_codes;
155         union {
156                 struct brcmfmac_sdio_pd sdio;
157         } bus;
158 };
159
160 /**
161  * struct brcmfmac_platform_data - BRCMFMAC specific platform data.
162  *
163  * @power_on:   This function is called by the brcmfmac driver when the module
164  *              gets loaded. This can be particularly useful for low power
165  *              devices. The platform spcific routine may for example decide to
166  *              power up the complete device. If there is no use-case for this
167  *              function then provide NULL.
168  * @power_off:  This function is called by the brcmfmac when the module gets
169  *              unloaded. At this point the devices can be powered down or
170  *              otherwise be reset. So if an actual power_off is not supported
171  *              but reset is supported by the devices then reset the devices
172  *              when this function gets called. This can be particularly useful
173  *              for low power devices. If there is no use-case for this
174  *              function then provide NULL.
175  */
176 struct brcmfmac_platform_data {
177         void    (*power_on)(void);
178         void    (*power_off)(void);
179         char    *fw_alternative_path;
180         int     device_count;
181         struct brcmfmac_pd_device devices[0];
182 };
183
184
185 #endif /* _LINUX_BRCMFMAC_PLATFORM_H */