Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 201 Broadcom Corporation
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
0011  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
0013  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
0014  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #ifndef _LINUX_BRCMFMAC_PLATFORM_H
0018 #define _LINUX_BRCMFMAC_PLATFORM_H
0019 
0020 
0021 #define BRCMFMAC_PDATA_NAME     "brcmfmac"
0022 
0023 #define BRCMFMAC_COUNTRY_BUF_SZ     4
0024 
0025 
0026 /*
0027  * Platform specific driver functions and data. Through the platform specific
0028  * device data functions and data can be provided to help the brcmfmac driver to
0029  * operate with the device in combination with the used platform.
0030  */
0031 
0032 
0033 /**
0034  * Note: the brcmfmac can be loaded as module or be statically built-in into
0035  * the kernel. If built-in then do note that it uses module_init (and
0036  * module_exit) routines which equal device_initcall. So if you intend to
0037  * create a module with the platform specific data for the brcmfmac and have
0038  * it built-in to the kernel then use a higher initcall then device_initcall
0039  * (see init.h). If this is not done then brcmfmac will load without problems
0040  * but will not pickup the platform data.
0041  *
0042  * When the driver does not "detect" platform driver data then it will continue
0043  * without reporting anything and just assume there is no data needed. Which is
0044  * probably true for most platforms.
0045  */
0046 
0047 /**
0048  * enum brcmf_bus_type - Bus type identifier. Currently SDIO, USB and PCIE are
0049  *           supported.
0050  */
0051 enum brcmf_bus_type {
0052     BRCMF_BUSTYPE_SDIO,
0053     BRCMF_BUSTYPE_USB,
0054     BRCMF_BUSTYPE_PCIE
0055 };
0056 
0057 
0058 /**
0059  * struct brcmfmac_sdio_pd - SDIO Device specific platform data.
0060  *
0061  * @txglomsz:       SDIO txglom size. Use 0 if default of driver is to be
0062  *          used.
0063  * @drive_strength: is the preferred drive_strength to be used for the SDIO
0064  *          pins. If 0 then a default value will be used. This is
0065  *          the target drive strength, the exact drive strength
0066  *          which will be used depends on the capabilities of the
0067  *          device.
0068  * @oob_irq_supported:  does the board have support for OOB interrupts. SDIO
0069  *          in-band interrupts are relatively slow and for having
0070  *          less overhead on interrupt processing an out of band
0071  *          interrupt can be used. If the HW supports this then
0072  *          enable this by setting this field to true and configure
0073  *          the oob related fields.
0074  * @oob_irq_nr,
0075  * @oob_irq_flags:  the OOB interrupt information. The values are used for
0076  *          registering the irq using request_irq function.
0077  * @broken_sg_support:  flag for broken sg list support of SDIO host controller.
0078  *          Set this to true if the SDIO host controller has higher
0079  *          align requirement than 32 bytes for each scatterlist
0080  *          item.
0081  * @sd_head_align:  alignment requirement for start of data buffer.
0082  * @sd_sgentry_align:   length alignment requirement for each sg entry.
0083  * @reset:      This function can get called if the device communication
0084  *          broke down. This functionality is particularly useful in
0085  *          case of SDIO type devices. It is possible to reset a
0086  *          dongle via sdio data interface, but it requires that
0087  *          this is fully functional. This function is chip/module
0088  *          specific and this function should return only after the
0089  *          complete reset has completed.
0090  */
0091 struct brcmfmac_sdio_pd {
0092     int     txglomsz;
0093     unsigned int    drive_strength;
0094     bool        oob_irq_supported;
0095     unsigned int    oob_irq_nr;
0096     unsigned long   oob_irq_flags;
0097     bool        broken_sg_support;
0098     unsigned short  sd_head_align;
0099     unsigned short  sd_sgentry_align;
0100     void        (*reset)(void);
0101 };
0102 
0103 /**
0104  * struct brcmfmac_pd_cc_entry - Struct for translating user space country code
0105  *               (iso3166) to firmware country code and
0106  *               revision.
0107  *
0108  * @iso3166:    iso3166 alpha 2 country code string.
0109  * @cc:     firmware country code string.
0110  * @rev:    firmware country code revision.
0111  */
0112 struct brcmfmac_pd_cc_entry {
0113     char    iso3166[BRCMFMAC_COUNTRY_BUF_SZ];
0114     char    cc[BRCMFMAC_COUNTRY_BUF_SZ];
0115     s32 rev;
0116 };
0117 
0118 /**
0119  * struct brcmfmac_pd_cc - Struct for translating country codes as set by user
0120  *             space to a country code and rev which can be used by
0121  *             firmware.
0122  *
0123  * @table_size: number of entries in table (> 0)
0124  * @table:  array of 1 or more elements with translation information.
0125  */
0126 struct brcmfmac_pd_cc {
0127     int             table_size;
0128     struct brcmfmac_pd_cc_entry table[];
0129 };
0130 
0131 /**
0132  * struct brcmfmac_pd_device - Device specific platform data. (id/rev/bus_type)
0133  *                 is the unique identifier of the device.
0134  *
0135  * @id:         ID of the device for which this data is. In case of SDIO
0136  *          or PCIE this is the chipid as identified by chip.c In
0137  *          case of USB this is the chipid as identified by the
0138  *          device query.
0139  * @rev:        chip revision, see id.
0140  * @bus_type:       The type of bus. Some chipid/rev exist for different bus
0141  *          types. Each bus type has its own set of settings.
0142  * @feature_disable:    Bitmask of features to disable (override), See feature.c
0143  *          in brcmfmac for details.
0144  * @country_codes:  If available, pointer to struct for translating country
0145  *          codes.
0146  * @bus:        Bus specific (union) device settings. Currently only
0147  *          SDIO.
0148  */
0149 struct brcmfmac_pd_device {
0150     unsigned int        id;
0151     unsigned int        rev;
0152     enum brcmf_bus_type bus_type;
0153     unsigned int        feature_disable;
0154     struct brcmfmac_pd_cc   *country_codes;
0155     union {
0156         struct brcmfmac_sdio_pd sdio;
0157     } bus;
0158 };
0159 
0160 /**
0161  * struct brcmfmac_platform_data - BRCMFMAC specific platform data.
0162  *
0163  * @power_on:   This function is called by the brcmfmac driver when the module
0164  *      gets loaded. This can be particularly useful for low power
0165  *      devices. The platform spcific routine may for example decide to
0166  *      power up the complete device. If there is no use-case for this
0167  *      function then provide NULL.
0168  * @power_off:  This function is called by the brcmfmac when the module gets
0169  *      unloaded. At this point the devices can be powered down or
0170  *      otherwise be reset. So if an actual power_off is not supported
0171  *      but reset is supported by the devices then reset the devices
0172  *      when this function gets called. This can be particularly useful
0173  *      for low power devices. If there is no use-case for this
0174  *      function then provide NULL.
0175  */
0176 struct brcmfmac_platform_data {
0177     void    (*power_on)(void);
0178     void    (*power_off)(void);
0179     char    *fw_alternative_path;
0180     int device_count;
0181     struct brcmfmac_pd_device devices[];
0182 };
0183 
0184 
0185 #endif /* _LINUX_BRCMFMAC_PLATFORM_H */